Skip to content

Commit 476f7a5

Browse files
committed
refactor: single script for CI code coverage
1 parent ab66c15 commit 476f7a5

File tree

4 files changed

+20
-9
lines changed

4 files changed

+20
-9
lines changed

.github/workflows/after-merge.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,8 @@ jobs:
105105
with:
106106
node-version: ${{ matrix.node-version }}
107107

108-
- name: generate coverage for all tests
109-
run: 'yarn test:c8-all || :'
110-
- name: generate coverage/html reports
111-
run: mkdir -p coverage/tmp && yarn c8 report --all --include 'packages/*/{src,tools}' --reporter=html-spa --reports-dir=coverage/html --temp-directory=coverage/tmp
108+
- name: generate test coverage report
109+
run: ./scripts/ci/generage-test-coverage-report.sh
112110
- uses: actions/upload-artifact@v4
113111
with:
114112
name: coverage

COVERAGE.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ source-to-source transforms (such as `@endo/bundle-source`,
1212
Coverage reports for the current main branch are
1313
published by CI to: https://agoric-sdk-coverage.netlify.app
1414

15-
It's made by a CI job calling `test:c8-all` in the project root. That in turn
16-
calls `test:c8` in each package, with `$C8_OPTIONS` set to a common coverage
17-
directory and to leave temp files so they can accumulate. The job then uses that
18-
output in another call to c8 to generate a report.
15+
See `scripts/ci/generate-test-coverage-report.sh`
1916

2017
## Per package
2118
You can create a report in any package:

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
"lint": "run-s --continue-on-error lint:*",
6666
"lint:packages": "yarn lerna run --no-bail lint",
6767
"test": "yarn lerna run --no-bail test",
68-
"test:c8-all": "rm -rf coverage/tmp && C8_OPTIONS=\"--clean=false --temp-directory=$PWD/coverage/tmp\" lerna run test:c8",
6968
"test:xs": "yarn workspaces run test:xs",
7069
"build": "yarn workspaces run build && scripts/agd-builder.sh stamp yarn-built",
7170
"postinstall": "patch-package && scripts/agd-builder.sh stamp yarn-installed",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
# CI artifact export expects the files to be under `coverage` (same for /html below)
4+
export NODE_V8_COVERAGE="$PWD/coverage/tmp"
5+
6+
# clear out old coverage. c8 usually does this but we have to clean=false below so it accumulates across packages
7+
rm -rf "$NODE_V8_COVERAGE"
8+
mkdir -p "$NODE_V8_COVERAGE"
9+
10+
# the package test:c8 commands will include this
11+
export C8_OPTIONS="--clean=false"
12+
13+
# XXX uses lerna when `yarn workspaces run` should work, but in v1 it always bails on missing script
14+
yarn lerna run test:c8
15+
16+
# report over all src and tools files, not just the ones that were loaded during tests
17+
yarn c8 report --all --include 'packages/*/{src,tools}' --reporter=html-spa --reports-dir=coverage/html

0 commit comments

Comments
 (0)