Skip to content

Commit

Permalink
chore: enhance ci reports (#497)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasgriffintn authored May 6, 2024
1 parent bd9855b commit eded17a
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 5 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/annotate-test-reports.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Annotate CI run with test results
on:
workflow_run:
workflows:
- "Run Tests"
types:
- completed
permissions:
actions: read
contents: read
checks: write
pull-requests: write

jobs:
annotate:
name: Annotate CI run with test results
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion != 'cancelled' }}
strategy:
fail-fast: false
matrix:
node-version: [18.x, 20.x, 22.x]
timeout-minutes: 5
steps:
- name: Annotate CI run with test results
uses: dorny/test-reporter@v1.8.0
with:
artifact: test-reports-${{ matrix.node-version }}
name: Test Results (${{matrix.node-version}}
path: "test-results.json"
reporter: mocha-json
42 changes: 42 additions & 0 deletions .github/workflows/pr-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Comment PR Coverage
on:
pull_request:
branches:
- 'main'
permissions:
contents: read
pull-requests: write

jobs:
coverage_report:
name: Generate coverage report
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
steps:
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install Node Modules
run: npm ci

- name: Run Coverage Check
run: npm run lcov

- name: Setup LCOV
uses: hrishikesh-kadam/setup-lcov@v1

- name: Report code coverage
uses: zgosalvez/github-actions-report-lcov@v3
with:
coverage-files: coverage/lcov.info
minimum-coverage: 90
artifact-name: code-coverage-report
github-token: ${{ secrets.GITHUB_TOKEN }}
update-comment: true
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:
- main
permissions:
contents: read
checks: write
pull-requests: write

jobs:
build:
Expand All @@ -34,7 +36,7 @@ jobs:
- name: Run Tests and Linting
run: npm run test

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: test-reports-${{ matrix.node-version }}
path: test/reports/
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"build": "npm run clean && npm run compile && npm run add-package-jsons",
"watch": "tsc --watch",
"prepublishOnly": "npm run build",
"test:unit": "mocha --recursive --full-trace --exit",
"test:unit": "mocha --recursive --full-trace --exit --reporter json > test/reports/test-results.json",
"pretest:integration:init": "npm run build",
"test:integration:init": "sh ./test/scripts/initIntTests.sh",
"test:integration": "npm run test:integration:init && cucumber-js --config ./test/config/cucumber.mjs",
Expand Down
6 changes: 3 additions & 3 deletions test/config/cucumber.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default {
parallel: 0,
format: ['html:test/reports/cucumber-report.html'],
paths: ['test/features'],
forceExit: true
format: ["json:test/reports/cucumber-report.json"],
paths: ["test/features"],
forceExit: true,
};

0 comments on commit eded17a

Please sign in to comment.