Skip to content

Commit eded17a

Browse files
authoredMay 6, 2024··
chore: enhance ci reports (#497)
1 parent bd9855b commit eded17a

File tree

5 files changed

+80
-5
lines changed

5 files changed

+80
-5
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Annotate CI run with test results
2+
on:
3+
workflow_run:
4+
workflows:
5+
- "Run Tests"
6+
types:
7+
- completed
8+
permissions:
9+
actions: read
10+
contents: read
11+
checks: write
12+
pull-requests: write
13+
14+
jobs:
15+
annotate:
16+
name: Annotate CI run with test results
17+
runs-on: ubuntu-latest
18+
if: ${{ github.event.workflow_run.conclusion != 'cancelled' }}
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
node-version: [18.x, 20.x, 22.x]
23+
timeout-minutes: 5
24+
steps:
25+
- name: Annotate CI run with test results
26+
uses: dorny/test-reporter@v1.8.0
27+
with:
28+
artifact: test-reports-${{ matrix.node-version }}
29+
name: Test Results (${{matrix.node-version}}
30+
path: "test-results.json"
31+
reporter: mocha-json

‎.github/workflows/pr-coverage.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Comment PR Coverage
2+
on:
3+
pull_request:
4+
branches:
5+
- 'main'
6+
permissions:
7+
contents: read
8+
pull-requests: write
9+
10+
jobs:
11+
coverage_report:
12+
name: Generate coverage report
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
node-version: [20.x]
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Use Node.js ${{ matrix.node-version }}
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
cache: 'npm'
25+
26+
- name: Install Node Modules
27+
run: npm ci
28+
29+
- name: Run Coverage Check
30+
run: npm run lcov
31+
32+
- name: Setup LCOV
33+
uses: hrishikesh-kadam/setup-lcov@v1
34+
35+
- name: Report code coverage
36+
uses: zgosalvez/github-actions-report-lcov@v3
37+
with:
38+
coverage-files: coverage/lcov.info
39+
minimum-coverage: 90
40+
artifact-name: code-coverage-report
41+
github-token: ${{ secrets.GITHUB_TOKEN }}
42+
update-comment: true

‎.github/workflows/test.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ on:
88
- main
99
permissions:
1010
contents: read
11+
checks: write
12+
pull-requests: write
1113

1214
jobs:
1315
build:
@@ -34,7 +36,7 @@ jobs:
3436
- name: Run Tests and Linting
3537
run: npm run test
3638

37-
- uses: actions/upload-artifact@v3
39+
- uses: actions/upload-artifact@v4
3840
with:
3941
name: test-reports-${{ matrix.node-version }}
4042
path: test/reports/

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"build": "npm run clean && npm run compile && npm run add-package-jsons",
2828
"watch": "tsc --watch",
2929
"prepublishOnly": "npm run build",
30-
"test:unit": "mocha --recursive --full-trace --exit",
30+
"test:unit": "mocha --recursive --full-trace --exit --reporter json > test/reports/test-results.json",
3131
"pretest:integration:init": "npm run build",
3232
"test:integration:init": "sh ./test/scripts/initIntTests.sh",
3333
"test:integration": "npm run test:integration:init && cucumber-js --config ./test/config/cucumber.mjs",

‎test/config/cucumber.mjs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export default {
22
parallel: 0,
3-
format: ['html:test/reports/cucumber-report.html'],
4-
paths: ['test/features'],
5-
forceExit: true
3+
format: ["json:test/reports/cucumber-report.json"],
4+
paths: ["test/features"],
5+
forceExit: true,
66
};

0 commit comments

Comments
 (0)
Please sign in to comment.