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