Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
ci(e2e): nightly full corpus gets its own concurrency group; cancelled shards report as cancelled (#6040)
garrytan88cff580b1b5
diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.ymlindex a8bc321604..90dfe0ed3f 100644--- a/.github/workflows/e2e.yml+++ b/.github/workflows/e2e.yml@@ -23,9 +23,11 @@ permissions:# Cancel a superseded run when a newer commit lands on the same PR/branch.# PR number for pull_request events (fork-safe), github.ref fallback for-# push/scheduled runs.+# push runs. Scheduled runs get their own `-nightly` group (as in test.yml):+# sharing refs/heads/master with push runs let the next merge cancel the+# nightly full corpus mid-shard (#6040).concurrency:- group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}${{ github.event_name == 'workflow_dispatch' && inputs.full_corpus && '-full-corpus' || '' }}+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}${{ github.event_name == 'workflow_dispatch' && inputs.full_corpus && '-full-corpus' || '' }}${{ github.event_name == 'schedule' && '-nightly' || '' }}cancel-in-progress: truejobs:@@ -875,14 +877,39 @@ jobs:with:pattern: coverage-full-*path: ${{ runner.temp }}/coverage-artifacts+ # A run cancelled by a newer run in its concurrency group or by a user+ # reports its cancelled shards as cancelled (no coverage, not a test+ # failure). A shard that failed or hit timeout-minutes in a run nobody+ # cancelled stays a failure. docs/TESTING.md#full-corpus-report-states+ - name: Classify full E2E shards+ id: shards+ env:+ FULL_E2E_RESULT: ${{ needs.coverage-full-e2e.result }}+ RUN_CANCELLED: ${{ cancelled() }}+ RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}+ RUN_ID: ${{ github.run_id }}+ DOCS: docs/TESTING.md#full-corpus-report-states+ run: |+ if [ "$FULL_E2E_RESULT" = success ]; then+ echo "state=complete" >> "$GITHUB_OUTPUT"+ exit 0+ fi+ if [ "$FULL_E2E_RESULT" = cancelled ] && [ "$RUN_CANCELLED" = true ]; then+ msg="Full E2E shards cancelled: this run ($RUN_URL) was cancelled by a newer run in its concurrency group or by a user before the four shards finished, so no full-corpus coverage report exists for it. This is not a test failure. Next: gh workflow run e2e.yml --ref master -f full_corpus=true (or wait for the next schedule). Docs: $DOCS"+ echo "::warning title=Full E2E shards cancelled::$msg"+ { echo "### Full-corpus coverage: cancelled"; echo; echo "$msg"; } >> "$GITHUB_STEP_SUMMARY"+ echo "state=cancelled" >> "$GITHUB_OUTPUT"+ exit 0+ fi+ msg="Full E2E did not succeed (result: ${FULL_E2E_RESULT:-none}) and nobody cancelled this run, so a shard failed or hit its timeout-minutes; refusing a complete report from prior-attempt artifacts. Next: gh run view $RUN_ID --log-failed, fix the failing shard, then gh run rerun $RUN_ID --failed. Docs: $DOCS"+ echo "::error title=Full E2E shards failed::$msg"+ { echo "### Full-corpus coverage: failed"; echo; echo "$msg"; } >> "$GITHUB_STEP_SUMMARY"+ exit 1- name: Merge full corpus+ if: steps.shards.outputs.state == 'complete'env:COVERAGE_CORPUS: fullCorpusrun: |- if [ "${{ needs.coverage-full-e2e.result }}" != "success" ]; then- echo "Full E2E did not succeed; refusing a complete report from prior-attempt artifacts"- exit 1- fibun scripts/verify-nightly-e2e.ts "$RUNNER_TEMP/coverage-artifacts" 4 "$GITHUB_SHA"bun scripts/merge-lcov.ts \--out-lcov "$RUNNER_TEMP/coverage-full-merged/lcov.info" \@@ -890,8 +917,10 @@ jobs:--manifest-expect shard-1,shard-2,shard-3,shard-4,shard-5,shard-6,shard-7,shard-8,shard-9,shard-10,serial,slow,e2e-1,e2e-2,e2e-3,e2e-4 \"$RUNNER_TEMP/coverage-artifacts"- name: Coverage summary → step summary+ if: steps.shards.outputs.state == 'complete'run: bun scripts/render-coverage-summary.ts --summary "$RUNNER_TEMP/coverage-full-merged/summary.json" --structural scripts/structural-suites.tsv >> "$GITHUB_STEP_SUMMARY"- name: Baseline gate (fullCorpus, like-for-like)+ if: steps.shards.outputs.state == 'complete'# shell: bash → pipefail, so tee can't mask the gate's exit code.shell: bashenv:diff --git a/docs/TESTING.md b/docs/TESTING.mdindex e27e604136..4115a310f8 100644--- a/docs/TESTING.md+++ b/docs/TESTING.md@@ -1275,6 +1275,21 @@ cancellations cannot report complete execution, and the report refuses topublish without that evidence. Receipts prove file execution, not everyoptional assertion within a file.+#### Full-corpus report states++`coverage-full-report` classifies the four full E2E shards before merging+anything. All shards succeeded: it merges, renders and gates the full corpus.+The run was cancelled (by a newer run in its concurrency group or by a user)+before the shards finished: it reports `Full E2E shards cancelled` as a+warning and a step-summary section, publishes no coverage and does not fail,+because nothing was measured; re-run with+`gh workflow run e2e.yml --ref master -f full_corpus=true` or wait for the next+schedule. Any other non-success (a shard failed, or hit its `timeout-minutes`+in a run nobody cancelled) is a failure: read `gh run view <run-id> --log-failed`,+fix the shard, then `gh run rerun <run-id> --failed`. Scheduled runs use their+own `-nightly` concurrency group, so a push to master no longer cancels the+nightly full corpus (#6040).+**Merge** (`scripts/merge-lcov.ts`) sums DA hits per file and line across theinput directories, normalizes paths, and emits a merged lcov plus a summaryJSON (src-only totals, per-directory and per-file percentages, the `lineHits`diff --git a/test/scripts/nightly-e2e.test.ts b/test/scripts/nightly-e2e.test.tsindex ffdb852926..2ef6f9eaf2 100644--- a/test/scripts/nightly-e2e.test.ts+++ b/test/scripts/nightly-e2e.test.ts@@ -130,20 +130,49 @@ describe('nightly E2E scheduling', () => {const report = workflow.jobs['coverage-full-report'];expect(report.needs).toContain('coverage-full-e2e');expect(report.if).toBe(`always() && (${fullProfile})`);- const merge = report.steps.find((step: any) => step.name === 'Merge full corpus').run;+ const mergeStep = report.steps.find((step: any) => step.name === 'Merge full corpus');+ const merge = mergeStep.run;expect(merge).toContain('scripts/verify-nightly-e2e.ts "$RUNNER_TEMP/coverage-artifacts" 4 "$GITHUB_SHA"');expect(merge).toContain(',e2e-1,e2e-2,e2e-3,e2e-4');+ const classify = report.steps.find((step: any) => step.name === 'Classify full E2E shards');+ expect(report.steps.indexOf(classify)).toBeLessThan(report.steps.indexOf(mergeStep));+ expect(classify.id).toBe('shards');+ expect(classify.env.FULL_E2E_RESULT).toBe('${{ needs.coverage-full-e2e.result }}');+ expect(classify.env.RUN_CANCELLED).toBe('${{ cancelled() }}');+ for (const name of ['Merge full corpus', 'Coverage summary → step summary', 'Baseline gate (fullCorpus, like-for-like)']) {+ expect(report.steps.find((step: any) => step.name === name).if).toBe("steps.shards.outputs.state == 'complete'");+ }+ expect(readFileSync(join(repo, 'docs/TESTING.md'), 'utf8')).toMatch(/^#+ Full-corpus report states$/m);fixture(root => {- const bin = join(root, 'bin');- mkdirSync(bin);- writeFileSync(join(bin, 'bun'), '#!/bin/sh\necho COVERAGE_CALLED\n', { mode: 0o755 });- for (const result of ['success', 'failure', 'cancelled', 'skipped', '']) {- const script = merge.replace('${{ needs.coverage-full-e2e.result }}', result);- const run = spawnSync('bash', ['-e', '-c', script], {- encoding: 'utf8', env: { ...process.env, PATH: `${bin}:${process.env.PATH}`, RUNNER_TEMP: root, GITHUB_SHA: 'fixture-sha' },+ // A timed-out shard in a run nobody cancelled reports `cancelled` from+ // needs but RUN_CANCELLED=false: it must stay a failure.+ for (const [result, runCancelled, status, state] of [+ ['success', 'false', 0, 'complete'], ['success', 'true', 0, 'complete'],+ ['failure', 'false', 1, ''], ['failure', 'true', 1, ''],+ ['cancelled', 'false', 1, ''], ['cancelled', 'true', 0, 'cancelled'],+ ['skipped', 'false', 1, ''], ['', 'false', 1, ''],+ ] as const) {+ const out = join(root, `out-${result || 'none'}-${runCancelled}`);+ const summary = `${out}.summary`;+ writeFileSync(out, '');+ writeFileSync(summary, '');+ const run = spawnSync('bash', ['-e', '-c', classify.run], {+ encoding: 'utf8',+ env: { ...process.env, FULL_E2E_RESULT: result, RUN_CANCELLED: runCancelled, RUN_ID: '42', RUN_URL: 'https://example.test/runs/42', DOCS: classify.env.DOCS, GITHUB_OUTPUT: out, GITHUB_STEP_SUMMARY: summary },});- expect(run.status, run.stderr).toBe(result === 'success' ? 0 : 1);- expect(run.stdout.includes('COVERAGE_CALLED')).toBe(result === 'success');+ expect(run.status, `${result}/${runCancelled}: ${run.stdout}${run.stderr}`).toBe(status);+ expect(readFileSync(out, 'utf8')).toBe(state ? `state=${state}\n` : '');+ if (state === 'cancelled') {+ expect(run.stdout).toContain('::warning title=Full E2E shards cancelled::');+ expect(readFileSync(summary, 'utf8')).toContain('Full-corpus coverage: cancelled');+ expect(run.stdout).toContain('gh workflow run e2e.yml --ref master -f full_corpus=true');+ }+ if (status === 1) {+ expect(run.stdout).toContain('::error title=Full E2E shards failed::');+ expect(run.stdout).toContain('gh run view 42 --log-failed');+ expect(readFileSync(summary, 'utf8')).toContain('Full-corpus coverage: failed');+ }+ if (status !== 0 || state === 'cancelled') expect(run.stdout).toContain('docs/TESTING.md#full-corpus-report-states');}});const status = workflow.jobs['e2e-status'];@@ -163,7 +192,7 @@ describe('nightly E2E scheduling', () => {const select = selection.run;expect(selection.env.FULL_CORPUS).toBe('${{ ' + fullProfile + ' }}');const group = workflow.concurrency.group;- expect(group).toBe("${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}${{ github.event_name == 'workflow_dispatch' && inputs.full_corpus && '-full-corpus' || '' }}");+ expect(group).toBe("${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}${{ github.event_name == 'workflow_dispatch' && inputs.full_corpus && '-full-corpus' || '' }}${{ github.event_name == 'schedule' && '-nightly' || '' }}");for (const [event, enabled, expected] of [['pull_request', false, false], ['pull_request', true, false], ['push', true, false],['workflow_dispatch', false, false], ['workflow_dispatch', true, true], ['schedule', false, true],