Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

ci(e2e): pass run cancellation to the shard classifier through an if: step

garrytandd619ad4554a
diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml
index 90dfe0ed3f..70908b5728 100644
--- a/.github/workflows/e2e.yml
+++ b/.github/workflows/e2e.yml
@@ -881,11 +881,16 @@ jobs:
# 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
+ # Status functions are only valid in `if:`, so cancellation reaches the
+ # classifier through GITHUB_ENV.
+ - name: Note run cancellation
+ if: cancelled()
+ run: echo "RUN_CANCELLED=true" >> "$GITHUB_ENV"
- name: Classify full E2E shards
id: shards
+ if: always()
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
diff --git a/test/scripts/nightly-e2e.test.ts b/test/scripts/nightly-e2e.test.ts
index 2ef6f9eaf2..0624d106c0 100644
--- a/test/scripts/nightly-e2e.test.ts
+++ b/test/scripts/nightly-e2e.test.ts
@@ -138,7 +138,15 @@ describe('nightly E2E scheduling', () => {
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() }}');
+ expect(classify.if).toBe('always()');
+ expect(classify.env.RUN_CANCELLED).toBeUndefined();
+ const note = report.steps.find((step: any) => step.name === 'Note run cancellation');
+ expect(report.steps.indexOf(note)).toBe(report.steps.indexOf(classify) - 1);
+ expect(note.if).toBe('cancelled()');
+ expect(note.run).toBe('echo "RUN_CANCELLED=true" >> "$GITHUB_ENV"');
+ // Status functions such as cancelled() are refused outside `if:` (HTTP 422
+ // at dispatch), so no step may carry one in env or run.
+ for (const step of report.steps) expect(JSON.stringify({ env: step.env, run: step.run })).not.toMatch(/\b(cancelled|always|success|failure)\(\)/);
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'");
}