Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -90,7 +93,9 @@ jobs:
.github/.cache/buster-for-unit-tests

- name: Run Tests
run: make unit-test
run: |
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
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
Expand All @@ -104,10 +109,21 @@ jobs:
path: ${{ github.workspace }}/cover.html
if: always()

- 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 --annotate
env:
GITHUB_TOKEN: ${{ secrets.NGINX_PAT }}
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
Expand All @@ -125,6 +141,12 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}

- name: Test Report
uses: EnricoMi/publish-unit-test-result-action@v2
with:
files: ${{ github.workspace }}/internal/mode/static/nginx/modules/njs-unit-tests.xml
if: always()

binary:
name: Build Binary
runs-on: ubuntu-24.04
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,7 @@ internal/mode/static/nginx/modules/coverage
# temporary files used for manifest generation
config/base/deploy.yaml
config/base/deploy.yaml.bak

# test reports
ctrf-report.json
njs-unit-tests.xml
2 changes: 1 addition & 1 deletion internal/mode/static/nginx/modules/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 2 additions & 0 deletions internal/mode/static/nginx/modules/test/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
},
Expand Down
Loading