From 42e97fd7316c75a18c1eb52f285e6184e9c95139 Mon Sep 17 00:00:00 2001 From: kaiiorg Date: Tue, 2 Jan 2024 13:42:05 -0600 Subject: [PATCH 1/2] [CI] Add make target to execute tests, actions job to execute tests, and modified readme --- .github/workflows/test.yml | 33 +++++++++++++++++++++++++++++++++ Makefile | 5 ++++- README.md | 5 +++-- 3 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..a9b8d2a --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,33 @@ +name: Run integration tests + +on: + # Runs when a push is made the main branch + push: + branches: [ "main" ] + # Runs when a PR is targeting the main branch + pull_request: + branches: [ "main" ] + # Manual activation + workflow_dispatch: + +jobs: + go_test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: ">=1.21.3" + - name: Tidy modules + run: go mod tidy + - name: Run tests + run: go test -v -coverprofile coverage.csv ./... + - name: Create coverage report + run: go tool cover -html=coverage.csv -o coverage.html + - name: Upload coverage report + uses: actions/upload-artifact@v3 + with: + name: coverage.html + path: coverage.html diff --git a/Makefile b/Makefile index 2772318..f5bcb1a 100644 --- a/Makefile +++ b/Makefile @@ -24,4 +24,7 @@ clean: rm -rf ui/build/* vet: - go vet \ No newline at end of file + go vet + +test: + go test ./... diff --git a/README.md b/README.md index 848a6a9..d62f60d 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ If you do not wish to use this, you can just rename `.example.env` to `.env` and 1. Run `make prep` 2. Run `make clean` -3. Run `make build`
+3. Run `make test` +4. Run `make build` -Your binary should now be built and you can run it with `bin/go-fast-cdn-linux` or `bin/go-fast-cdn-windows` or `bin/go-fast-cdn-darwin` +Your binary should now be tested, built, and you can run it with `bin/go-fast-cdn-linux` or `bin/go-fast-cdn-windows` or `bin/go-fast-cdn-darwin` From 8aae3df0f3fedee5e70bc2dde34beb586e706ea4 Mon Sep 17 00:00:00 2001 From: kaiiorg Date: Tue, 2 Jan 2024 15:20:19 -0600 Subject: [PATCH 2/2] Build UI before trying to run tests --- .github/workflows/test.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a9b8d2a..ae49466 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,19 +13,42 @@ on: jobs: go_test: runs-on: ubuntu-latest + strategy: + matrix: + node-version: [ 18 ] steps: - name: Checkout uses: actions/checkout@v3 + + - name: Setup pnpm + uses: pnpm/action-setup@v2 + with: + version: 8.x + + - name: Setup Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: "pnpm" + cache-dependency-path: ui/pnpm-lock.yaml + + - name: Build UI Dashboard + run: pnpm --dir=./ui install && pnpm --dir=./ui build + - name: Set up Go uses: actions/setup-go@v3 with: go-version: ">=1.21.3" + - name: Tidy modules run: go mod tidy + - name: Run tests run: go test -v -coverprofile coverage.csv ./... + - name: Create coverage report run: go tool cover -html=coverage.csv -o coverage.html + - name: Upload coverage report uses: actions/upload-artifact@v3 with: