From cb0dbbde2a82046ca7773caa40040e261837a718 Mon Sep 17 00:00:00 2001 From: Justin Stayton Date: Thu, 27 Aug 2026 12:33:23 -0400 Subject: [PATCH] Report test results in the CI run summary too MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The coverage job ran the tests and reported only coverage, so the test results stayed in the job log. Node prints its own summary block right before the coverage report, so surfacing it costs one more `grep`. Reporting now happens in its own step. The default shell is `bash -e`, so `set -o pipefail` made a failing suite abort the step before it wrote the summary — the run lost both the results and the coverage report at the one moment they were most worth reading. Node emits both even when tests fail, so `if: ${{ !cancelled() }}` is enough to keep them. This matches the shape of the job in queryql: https://github.com/TRUEPIC/queryql/pull/96 Co-Authored-By: Claude Opus 5 --- .github/workflows/ci.yml | 18 +++++++++++++++--- AGENTS.md | 4 ++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cab502a..0a57674 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,15 +43,27 @@ jobs: cache: 'npm' - name: Install npm dependencies run: npm install - - name: Report coverage + - name: Run tests run: | set -o pipefail - npm run test:coverage | tee "$RUNNER_TEMP/coverage.txt" + npm run test:coverage | 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. Node + # prints both its summary and the coverage report even on failure. + - name: Report test results & coverage + if: ${{ !cancelled() }} + run: | { + echo '## Tests' + echo + echo '```' + grep -E '^ℹ (tests|suites|pass|fail|cancelled|skipped|todo|duration_ms) ' "$RUNNER_TEMP/tests.txt" | sed 's/^ℹ //' + echo '```' + echo echo '## Test coverage' echo echo '```' - awk '/start of coverage report/{f=1;next} /end of coverage report/{f=0} f' "$RUNNER_TEMP/coverage.txt" | sed 's/^ℹ //' + awk '/start of coverage report/{f=1;next} /end of coverage report/{f=0} f' "$RUNNER_TEMP/tests.txt" | sed 's/^ℹ //' echo '```' } >> "$GITHUB_STEP_SUMMARY" - name: Upload coverage report diff --git a/AGENTS.md b/AGENTS.md index 179c102..ad81f4c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -10,8 +10,8 @@ code in this repository. - `npm test -- --watch` — re-run tests on file change. - `npm run test:coverage` — run the suite with coverage, printing a report and writing `coverage/lcov.info`. CI runs this in a separate job that posts the - report to the run summary and uploads it as an artifact. There is no - threshold: coverage is reported, not enforced. + test results and coverage report to the run summary and uploads the report as + an artifact. There is no threshold: coverage is reported, not enforced. - `node --test src/main.test.js` — run a single test file. Add `--test-name-pattern ''` to filter by test name. - `npm run lint` — Prettier format check + ESLint. `npm run lint:format:fix` and