diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c5d41ae..25a200a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,3 +37,40 @@ jobs: with: name: test-coverage-${{ matrix.node-version }} path: test/coverage + + test-coverage: + name: Test coverage + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + - name: Set up Node.js + uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0 + with: + node-version: '26.x' + cache: 'npm' + - name: Install npm dependencies + run: npm install + - name: Run tests + run: | + set -o pipefail + npm test -- --ci --coverage --runInBand 2>&1 | + tee "$RUNNER_TEMP/tests.txt" + # Reported in its own step so the summary is still written when the suite + # fails, which is when the test results are most worth reading. + - name: Report test results & coverage + if: ${{ !cancelled() }} + run: | + { + echo '## Tests' + echo + echo '```' + grep -E '^(Test Suites|Tests|Snapshots|Time):' "$RUNNER_TEMP/tests.txt" + echo '```' + echo + echo '## Test coverage' + echo + echo '```' + awk '/^-+\|/ { f = 1 } /^Test Suites:/ { f = 0 } f' "$RUNNER_TEMP/tests.txt" + echo '```' + } >> "$GITHUB_STEP_SUMMARY"