chore(test): Add test shortcut to Makefile

Also rename `.github/workflows/lint.yml` to `.github/workflows/test.yml`
This commit is contained in:
Christian Ditaputratama 2024-07-07 00:51:54 +07:00
parent 02a4728574
commit be43734663
No known key found for this signature in database
GPG key ID: 31D3D06D77950979
4 changed files with 64 additions and 20 deletions

View file

@ -1,19 +0,0 @@
on:
push:
branches:
- main
pull_request:
name: Test
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.22.x
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
version: latest

51
.github/workflows/test.yml vendored Normal file
View file

@ -0,0 +1,51 @@
on:
push:
branches:
- main
pull_request:
name: Test
jobs:
test:
name: test
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.22.x
- name: Cache Go modules
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run lint
uses: golangci/golangci-lint-action@v4
with:
version: latest
- name: setup NodeJS
uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
- name: Cache node modules
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Build UI
run: make ui
- name: Run test
run: make test

View file

@ -65,6 +65,18 @@ clean:
rm -rfv ./bin
rm -rf ./frontend/build
.PHONY: lint
lint:
golangci-lint run ./...
.PHONY: test
test:
go test -race -cover ./...
.PHONY: bench
bench:
go test ./... -bench=. -benchmem -run=^#
# Deploying new binary file to server and probers host
# The deploy-* command doesn't build the binary file, so you need to run `make build` first.
# And make sure the inventory and deploy-*.yml file is properly configured.

View file

@ -1,6 +1,6 @@
# XMR Remote Nodes
[![Lint](https://github.com/ditatompel/xmr-remote-nodes/actions/workflows/lint.yml/badge.svg)](https://github.com/ditatompel/xmr-remote-nodes/actions/workflows/lint.yml)
[![Test](https://github.com/ditatompel/xmr-remote-nodes/actions/workflows/test.yml/badge.svg)](https://github.com/ditatompel/xmr-remote-nodes/actions/workflows/test.yml)
[![BUild](https://github.com/ditatompel/xmr-remote-nodes/actions/workflows/build.yml/badge.svg)](https://github.com/ditatompel/xmr-remote-nodes/actions/workflows/build.yml)
[![Release Binaries](https://github.com/ditatompel/xmr-remote-nodes/actions/workflows/release.yml/badge.svg)](https://github.com/ditatompel/xmr-remote-nodes/actions/workflows/release.yml)