|
| 1 | +--- |
| 2 | +main_commit: e5850df75 |
| 3 | +analyzed_date: 2026-09-15 |
| 4 | +key_files: |
| 5 | + - .github/workflows/test-smokes.yml |
| 6 | + - .github/workflows/test-smokes-parallel.yml |
| 7 | + - .github/workflows/test-ff-matrix.yml |
| 8 | + - src/tools/github.ts |
| 9 | + - tests/test.ts |
| 10 | + - tests/gha-grouping.ts |
| 11 | + - tests/integration/playwright-tests.test.ts |
| 12 | + - tests/tools/check-gha-log.ts |
| 13 | +--- |
| 14 | + |
| 15 | +# GitHub Actions test reporting |
| 16 | + |
| 17 | +Quarto's test harness groups full-run logs by test file and reports failures |
| 18 | +through annotations and the GitHub Actions step summary. Bucketed workflows |
| 19 | +already group each bucket and emit bucket-level annotations in their shell |
| 20 | +loops, so the harness must not emit competing workflow commands. |
| 21 | + |
| 22 | +## Ownership |
| 23 | + |
| 24 | +There are two execution paths: |
| 25 | + |
| 26 | +- **Harness-owned:** `QUARTO_TESTS_GHA_ORCHESTRATED` is unset. The harness |
| 27 | + emits groups, annotations, and step-summary entries. This does not imply a |
| 28 | + single `deno test` process: `run-tests.sh`'s timing mode (`QUARTO_TEST_TIMING`, |
| 29 | + used by `test-smokes.yml`) invokes separate `deno test` processes for test |
| 30 | + files, and invokes `smoke-all.test.ts` separately for each smoke-all document. |
| 31 | + It leaves the flag unset, so each invocation is independently harness-owned. |
| 32 | +- **Orchestrated:** A workflow loop invokes `run-tests` once per file (or |
| 33 | + bucket of files) and sets `QUARTO_TESTS_GHA_ORCHESTRATED=1`. The loop owns |
| 34 | + groups and bucket-level annotations; the harness emits only step-summary |
| 35 | + entries. A direct test runner can still emit its own file-specific |
| 36 | + annotations. |
| 37 | + |
| 38 | +`harnessOwnsStep()` in `src/tools/github.ts` implements this distinction. |
| 39 | +Workflow commands are otherwise gated by `GITHUB_ACTIONS`. |
| 40 | + |
| 41 | +Step-summary entries are emitted in both paths. A bucketed step can contain many |
| 42 | +harness processes, all appending to the same summary file. |
| 43 | + |
| 44 | +## Log grouping |
| 45 | + |
| 46 | +GitHub Actions groups cannot nest. Starting a group while another is open |
| 47 | +implicitly closes the first, and the later `::endgroup::` leaves subsequent |
| 48 | +output ungrouped. Each execution path must therefore have one group owner. |
| 49 | + |
| 50 | +For harness-owned runs: |
| 51 | + |
| 52 | +1. The first `test()` registration in a file opens the group before Deno prints |
| 53 | + that file's reporter header. The file URL is recovered from the V8 call |
| 54 | + stack. |
| 55 | +2. The test body opens or corrects the group from `context.origin`, which is |
| 56 | + authoritative. This is also the fallback when stack parsing fails. |
| 57 | +3. A failure closes the group before teardown, annotation output, and Deno's |
| 58 | + `FAILED` line. |
| 59 | +4. The file's `unload` handler closes a passing file's group before Deno prints |
| 60 | + the next file or the final `ERRORS` and `FAILURES` sections. |
| 61 | + |
| 62 | +Deno creates a separate module graph for each test file and fires `unload` once |
| 63 | +per file. Module-level grouping and summary state is therefore per file, not per |
| 64 | +`deno test` process. |
| 65 | + |
| 66 | +Workflow command markers must start at column 0 and end with a newline. ANSI |
| 67 | +color is valid in group bodies but must be removed from annotations and step |
| 68 | +summaries. |
| 69 | + |
| 70 | +## Failure reporting |
| 71 | + |
| 72 | +`tests/test.ts` reports each harness failure once, after cleanup and teardown. |
| 73 | +When a primary test failure and a teardown or cleanup failure both occur, the |
| 74 | +report includes both while preserving the primary exception. |
| 75 | + |
| 76 | +Each failure contributes: |
| 77 | + |
| 78 | +- A summary table row with a short navigation label, file, test name, and |
| 79 | + duration. |
| 80 | +- A clustered detail block containing the reproduction command and a bounded |
| 81 | + output excerpt. |
| 82 | +- A `::error` annotation when the harness owns the step and the annotation |
| 83 | + budget allows it. |
| 84 | + |
| 85 | +Rows are written immediately. Detail blocks are buffered until the file's |
| 86 | +`unload` event because GitHub-flavored Markdown ends a table at the first |
| 87 | +non-row line. Failures with the same first three non-empty excerpt lines share |
| 88 | +one detail block. The block renders only the first member's excerpt and says |
| 89 | +so, because later lines (for `noErrorsOrWarnings`, the stack and any further |
| 90 | +messages) can differ; the step log stays the complete record. `pendingClusters` is a module-level map, and Deno gives each |
| 91 | +test-file execution its own module graph, so this clustering only merges |
| 92 | +failures within one module instance, not across the step. |
| 93 | + |
| 94 | +Summary writes are best-effort and limited to 512 KiB, leaving margin below |
| 95 | +GitHub's 1 MiB per-step limit. Full rows degrade to name-only rows when |
| 96 | +necessary. If no candidate fits, the harness emits one truncation notice and |
| 97 | +leaves the complete failure record in the step log. Individual excerpts are also |
| 98 | +byte-limited so one long line cannot consume the summary budget. |
| 99 | + |
| 100 | +## Annotation budget and labels |
| 101 | + |
| 102 | +GitHub displays at most 10 error annotations per step. The harness emits nine |
| 103 | +per-test annotations, then one aggregate annotation when the tenth failure is |
| 104 | +recorded. |
| 105 | + |
| 106 | +The count must span test-file module instances. `AnnotationBudget` stores it in |
| 107 | +a sidecar file derived from `GITHUB_STEP_SUMMARY`, which is unique to the step |
| 108 | +and writable by the runner. Tests run serially, so no locking is needed. If the |
| 109 | +sidecar cannot be read or written, reporting remains best-effort and falls back |
| 110 | +to local counting. |
| 111 | + |
| 112 | +Failure labels combine: |
| 113 | + |
| 114 | +- `RUNNER_OS`, reduced to `L`, `W`, `M`, or `X`; |
| 115 | +- `QUARTO_TESTS_GHA_LABEL_TAG`, supplied by the reusable-workflow caller; |
| 116 | +- the step-wide failure ordinal. |
| 117 | + |
| 118 | +The run summary concatenates summaries from multiple jobs. Every reusable |
| 119 | +workflow call that can share an OS with another call in the same run must |
| 120 | +therefore pass a distinct `label-tag`. Per-OS jobs may share a tag because the |
| 121 | +OS prefix already distinguishes them. |
| 122 | + |
| 123 | +## Workflow contract |
| 124 | + |
| 125 | +When editing the smoke workflows: |
| 126 | + |
| 127 | +- Set `QUARTO_TESTS_GHA_ORCHESTRATED=1` on loops that emit their own `::group::` |
| 128 | + or `::error` commands. |
| 129 | +- Pass `label-tag` at every `test-smokes.yml` and `test-ff-matrix.yml` call |
| 130 | + site. |
| 131 | +- Keep tags short and alphanumeric. `failureLabel()` discards other characters |
| 132 | + and keeps at most eight. |
| 133 | +- Do not add `deno test --parallel`; interleaved workflow commands would corrupt |
| 134 | + grouping. Parallel support would require buffered, atomic output. |
| 135 | + |
| 136 | +## Verification |
| 137 | + |
| 138 | +Unit coverage is in: |
| 139 | + |
| 140 | +- `tests/unit/gha-grouping.test.ts` |
| 141 | +- `tests/unit/github-actions-reporting.test.ts` |
| 142 | +- `tests/unit/harness-failure-reporting.test.ts` |
| 143 | +- `tests/unit/check-gha-log.test.ts` |
| 144 | + |
| 145 | +`tests/tools/check-gha-log.ts` validates captured logs for balanced, non-nested |
| 146 | +groups, column-zero markers, and failure sections outside groups. Run it after |
| 147 | +changing the grouping logic or upgrading Deno: |
| 148 | + |
| 149 | +```bash |
| 150 | +GITHUB_ACTIONS=true ./run-tests.sh <subset> | tee log.txt |
| 151 | +deno run --allow-read tests/tools/check-gha-log.ts log.txt |
| 152 | +``` |
| 153 | + |
| 154 | +Direct `Deno.test` files that bypass the Quarto harness (e.g. |
| 155 | +`playwright-tests.test.ts`) receive none of the harness's own grouping, |
| 156 | +annotation, or summary logic. They can still use file-specific reporting or be |
| 157 | +wrapped by workflow-level reporting. On GitHub Actions, |
| 158 | +`tests/integration/playwright-tests.test.ts` emits its own annotations; when a |
| 159 | +bucket loop owns the step, it calls `gha.error` directly instead of using the |
| 160 | +step-wide annotation budget. Bucket loops in `test-smokes.yml` also wrap each |
| 161 | +bucket in their own `::group::`/`::endgroup::` pair and emit a bucket-level |
| 162 | +failure annotation regardless of which files the bucket runs. |
0 commit comments