From be43734663b3799e6926d452d80beedf3b488dcc Mon Sep 17 00:00:00 2001 From: Christian Ditaputratama Date: Sun, 7 Jul 2024 00:51:54 +0700 Subject: [PATCH] chore(test): Add test shortcut to Makefile Also rename `.github/workflows/lint.yml` to `.github/workflows/test.yml` --- .github/workflows/lint.yml | 19 -------------- .github/workflows/test.yml | 51 ++++++++++++++++++++++++++++++++++++++ Makefile | 12 +++++++++ README.md | 2 +- 4 files changed, 64 insertions(+), 20 deletions(-) delete mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index c36f8d0..0000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..604ce7d --- /dev/null +++ b/.github/workflows/test.yml @@ -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 diff --git a/Makefile b/Makefile index ab5ce85..957b357 100644 --- a/Makefile +++ b/Makefile @@ -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. diff --git a/README.md b/README.md index 68f29cb..c5f5bd1 100644 --- a/README.md +++ b/README.md @@ -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)