From 958c5eebf720467589452567ce7b536b10595932 Mon Sep 17 00:00:00 2001 From: Luca Comellini Date: Mon, 23 Sep 2024 16:42:03 -0700 Subject: [PATCH 01/11] Unit tests report --- .github/workflows/ci.yml | 16 ++++++++++++++++ .gitignore | 5 +++++ .../static/nginx/modules/test/vitest.config.ts | 2 ++ 3 files changed, 23 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 58faabaa6d..9eab58c53e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -104,6 +104,14 @@ jobs: path: ${{ github.workspace }}/cover.html if: always() + - name: Test Report + uses: dorny/test-reporter@v1 + with: + name: Unit Tests Report + path: unit-tests.xml + reporter: jest-junit + if: always() + njs-unit-tests: name: NJS Unit Tests runs-on: ubuntu-24.04 @@ -125,6 +133,14 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} + - name: Test Report + uses: dorny/test-reporter@v1 + with: + name: Unit Tests Report + path: njs-unit-tests.xml + reporter: jest-junit + if: always() + binary: name: Build Binary runs-on: ubuntu-24.04 diff --git a/.gitignore b/.gitignore index 3615727c6d..a77d40be2e 100644 --- a/.gitignore +++ b/.gitignore @@ -58,3 +58,8 @@ internal/mode/static/nginx/modules/coverage # temporary files used for manifest generation config/base/deploy.yaml config/base/deploy.yaml.bak + +# test reports +unit-tests.xml +unit-tests.json +njs-unit-tests.xml diff --git a/internal/mode/static/nginx/modules/test/vitest.config.ts b/internal/mode/static/nginx/modules/test/vitest.config.ts index b951a942f7..ed26bb90b2 100644 --- a/internal/mode/static/nginx/modules/test/vitest.config.ts +++ b/internal/mode/static/nginx/modules/test/vitest.config.ts @@ -2,6 +2,8 @@ import { defineConfig } from 'vitest/config'; export default defineConfig({ test: { + reporters: ['verbose', 'junit'], + outputFile: './njs-unit-tests.xml', coverage: { reporter: ['text', 'json', 'html'], }, From 1f07b115638e1546a84d073125c3ce412555f108 Mon Sep 17 00:00:00 2001 From: Luca Comellini Date: Mon, 23 Sep 2024 16:42:03 -0700 Subject: [PATCH 02/11] Unit tests report --- .github/workflows/ci.yml | 12 ++++++++++-- internal/mode/static/nginx/modules/package.json | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9eab58c53e..b84ed32709 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -77,6 +77,9 @@ jobs: name: Unit Tests runs-on: ubuntu-24.04 needs: vars + permissions: + checks: write + pull-requests: write steps: - name: Checkout Repository uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 @@ -109,13 +112,17 @@ jobs: with: name: Unit Tests Report path: unit-tests.xml - reporter: jest-junit + reporter: java-junit + only-summary: true if: always() njs-unit-tests: name: NJS Unit Tests runs-on: ubuntu-24.04 needs: vars + permissions: + checks: write + pull-requests: write steps: - name: Checkout Repository uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 @@ -137,8 +144,9 @@ jobs: uses: dorny/test-reporter@v1 with: name: Unit Tests Report - path: njs-unit-tests.xml + path: ${{ github.workspace }}/internal/mode/static/nginx/modules/njs-unit-tests.xml reporter: jest-junit + only-summary: true if: always() binary: diff --git a/internal/mode/static/nginx/modules/package.json b/internal/mode/static/nginx/modules/package.json index 1fc2f65398..81f8b686d3 100644 --- a/internal/mode/static/nginx/modules/package.json +++ b/internal/mode/static/nginx/modules/package.json @@ -6,7 +6,7 @@ "scripts": { "format": "prettier -w src/ test/", "lint": "prettier -c src/ test/", - "test": "vitest run --coverage", + "test": "vitest run --coverage --config test/vitest.config.ts", "clean": "rm -rf node_modules coverage" }, "devDependencies": { From 8e05d0c3165573e5f29d28ee07648e69c5ea6722 Mon Sep 17 00:00:00 2001 From: Luca Comellini Date: Mon, 23 Sep 2024 18:36:45 -0700 Subject: [PATCH 03/11] change action --- .github/workflows/ci.yml | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b84ed32709..761d019605 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -108,12 +108,9 @@ jobs: if: always() - name: Test Report - uses: dorny/test-reporter@v1 + uses: EnricoMi/publish-unit-test-result-action@v2 with: - name: Unit Tests Report - path: unit-tests.xml - reporter: java-junit - only-summary: true + files: unit-tests.xml if: always() njs-unit-tests: @@ -141,12 +138,9 @@ jobs: token: ${{ secrets.CODECOV_TOKEN }} - name: Test Report - uses: dorny/test-reporter@v1 + uses: EnricoMi/publish-unit-test-result-action@v2 with: - name: Unit Tests Report - path: ${{ github.workspace }}/internal/mode/static/nginx/modules/njs-unit-tests.xml - reporter: jest-junit - only-summary: true + files: ${{ github.workspace }}/internal/mode/static/nginx/modules/njs-unit-tests.xml if: always() binary: From 854a0efb3208087c24f9fb942eb53fa4f2f1311e Mon Sep 17 00:00:00 2001 From: Luca Comellini Date: Thu, 26 Sep 2024 17:58:06 -0700 Subject: [PATCH 04/11] ctrf --- .github/workflows/ci.yml | 10 +++++----- .gitignore | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 761d019605..9fbf2e773b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -93,7 +93,9 @@ jobs: .github/.cache/buster-for-unit-tests - name: Run Tests - run: make unit-test + run: | + go test ./cmd/... ./internal/... -buildvcs -race -shuffle=on -coverprofile=coverage.out -covermode=atomic -json | go run github.com/ctrf-io/go-ctrf-json-reporter/cmd/go-ctrf-json-reporter@latest -output ctrf-report.json + go tool cover -html=coverage.out -o cover.html - name: Upload coverage reports to Codecov uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0 @@ -107,10 +109,8 @@ jobs: path: ${{ github.workspace }}/cover.html if: always() - - name: Test Report - uses: EnricoMi/publish-unit-test-result-action@v2 - with: - files: unit-tests.xml + - name: Publish CTRF Detailed Test Summary Results + run: npx github-actions-ctrf tests ctrf-report.json if: always() njs-unit-tests: diff --git a/.gitignore b/.gitignore index a77d40be2e..b730e0aed4 100644 --- a/.gitignore +++ b/.gitignore @@ -60,6 +60,5 @@ config/base/deploy.yaml config/base/deploy.yaml.bak # test reports -unit-tests.xml -unit-tests.json +ctrf-report.json njs-unit-tests.xml From 61f44dbf3fc8c9d640ecd574dc00e8d624e63c80 Mon Sep 17 00:00:00 2001 From: Luca Comellini Date: Thu, 26 Sep 2024 18:14:58 -0700 Subject: [PATCH 05/11] normal --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9fbf2e773b..87a681ce24 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -110,7 +110,7 @@ jobs: if: always() - name: Publish CTRF Detailed Test Summary Results - run: npx github-actions-ctrf tests ctrf-report.json + run: npx github-actions-ctrf ctrf-report.json if: always() njs-unit-tests: From 9bb19376a927f93e5a410000c7182c0c57d5edcd Mon Sep 17 00:00:00 2001 From: Luca Comellini Date: Thu, 26 Sep 2024 18:25:13 -0700 Subject: [PATCH 06/11] failed --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 87a681ce24..ce5837a365 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -110,7 +110,7 @@ jobs: if: always() - name: Publish CTRF Detailed Test Summary Results - run: npx github-actions-ctrf ctrf-report.json + run: npx github-actions-ctrf failed ctrf-report.json if: always() njs-unit-tests: From e824d3e93f1fdfb4f18e74782d4d9028068e785a Mon Sep 17 00:00:00 2001 From: Luca Comellini Date: Thu, 26 Sep 2024 18:34:00 -0700 Subject: [PATCH 07/11] two --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ce5837a365..dca9dbe708 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -110,7 +110,7 @@ jobs: if: always() - name: Publish CTRF Detailed Test Summary Results - run: npx github-actions-ctrf failed ctrf-report.json + run: npx github-actions-ctrf summary failed ctrf-report.json if: always() njs-unit-tests: From f17b6d1d62597937f0d6b2a49280468ddd09839b Mon Sep 17 00:00:00 2001 From: Luca Comellini Date: Thu, 26 Sep 2024 18:41:07 -0700 Subject: [PATCH 08/11] multiple --- .github/workflows/ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dca9dbe708..1de60926cc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -110,7 +110,10 @@ jobs: if: always() - name: Publish CTRF Detailed Test Summary Results - run: npx github-actions-ctrf summary failed ctrf-report.json + run: | + npx github-actions-ctrf summary ctrf-report.json + npx github-actions-ctrf failed ctrf-report.json --pr-comment --on-fail-only + npx github-actions-ctrf annotate ctrf-report.json if: always() njs-unit-tests: From ea5f9a03cc134156f45dff4546dc7965a0fdf1cb Mon Sep 17 00:00:00 2001 From: Luca Comellini Date: Thu, 26 Sep 2024 18:45:26 -0700 Subject: [PATCH 09/11] fail --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1de60926cc..9ab4ac7029 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -94,7 +94,7 @@ jobs: - name: Run Tests run: | - go test ./cmd/... ./internal/... -buildvcs -race -shuffle=on -coverprofile=coverage.out -covermode=atomic -json | go run github.com/ctrf-io/go-ctrf-json-reporter/cmd/go-ctrf-json-reporter@latest -output ctrf-report.json + go test ./cmd/... ./internal/... -race -shuffle=on -coverprofile=coverage.out -covermode=atomic -json | go run github.com/ctrf-io/go-ctrf-json-reporter/cmd/go-ctrf-json-reporter@latest -output ctrf-report.json go tool cover -html=coverage.out -o cover.html - name: Upload coverage reports to Codecov From 447829f965764a83a62eeab5e505ccec15d1ef4e Mon Sep 17 00:00:00 2001 From: Luca Comellini Date: Thu, 26 Sep 2024 18:52:12 -0700 Subject: [PATCH 10/11] pat --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9ab4ac7029..890f513332 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -114,6 +114,8 @@ jobs: npx github-actions-ctrf summary ctrf-report.json npx github-actions-ctrf failed ctrf-report.json --pr-comment --on-fail-only npx github-actions-ctrf annotate ctrf-report.json + env: + GITHUB_TOKEN: ${{ secrets.NGINX_PAT }} if: always() njs-unit-tests: From b722ce49bec111cd7fc51e0e1200517705091f8a Mon Sep 17 00:00:00 2001 From: Luca Comellini Date: Thu, 26 Sep 2024 18:57:11 -0700 Subject: [PATCH 11/11] annotate --- .github/workflows/ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 890f513332..688d43ae54 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -112,8 +112,7 @@ jobs: - name: Publish CTRF Detailed Test Summary Results run: | npx github-actions-ctrf summary ctrf-report.json - npx github-actions-ctrf failed ctrf-report.json --pr-comment --on-fail-only - npx github-actions-ctrf annotate ctrf-report.json + npx github-actions-ctrf failed ctrf-report.json --pr-comment --on-fail-only --annotate env: GITHUB_TOKEN: ${{ secrets.NGINX_PAT }} if: always()