From 2ccdd37d4b923b41907b73d97a9d768a0b452d04 Mon Sep 17 00:00:00 2001 From: tamirdresher_microsoft Date: Thu, 13 Aug 2026 15:45:01 +0300 Subject: [PATCH] fix(test): make gh-aw compile test mirror real .github/workflows layout test/gh-aw-quality.test.ts's compiled-workflow-contract test copied workflows/ into a bare workflows/ dir inside the ephemeral test git repo, then ran gh aw compile workflows/squad.md --strict. Since #1682 added safe-outputs.dispatch-workflow (workflows: [squad-implement-worker]) to workflows/squad.md, gh aw v0.85.4's dispatch-workflow validation now resolves its expected .github/workflows/ location relative to the compiled file, assuming the standard /.github/workflows/.md depth. Because this repo's source lives one level shallower, at /workflows/.md, gh aw's resolution lands one directory too high (confirmed empirically against both the test workspace and the real repo root), so it can never find squad-implement-worker and fails --strict compilation. This is the sole cause of dev's vitest red status since 2026-08-12T23:39. Fix: mirror the real downstream deployment layout inside the test workspace instead - copy workflows/ into /.github/workflows/ and compile .github/workflows/squad.md, matching exactly how docs/src/content/docs/guide/gh-aw.md documents real installs via gh aw add owner/squad/workflows/squad-implement-worker.md@dev owner/squad/workflows/squad.md@dev (both files land side-by-side in the consumer's .github/workflows/). Verified this placement in an isolated compile outside any repo/worktree - dispatch-workflow resolves and compile succeeds with exit 0. This also changes the compiled runtime-import placeholder paths from bare shared/planning-ontology.md to .github/workflows/shared/planning-ontology.md, which is gh-aw's genuine, repo-root-relative behavior for that layout (reproduced in the same isolated compile) - updated the two literal assertions to match. Added a 20s test timeout since gh aw compile can exceed vitest's 5s default under full-suite parallel load. workflows/squad.md, workflows/squad-implement-worker.md, and #1682's dispatch-workflow feature are completely untouched. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- test/gh-aw-quality.test.ts | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/test/gh-aw-quality.test.ts b/test/gh-aw-quality.test.ts index 300a45af8..71fa03018 100644 --- a/test/gh-aw-quality.test.ts +++ b/test/gh-aw-quality.test.ts @@ -613,29 +613,49 @@ describe('gh-aw: prompt budget & planning import regression', () => { describe('gh-aw: compiled workflow contract', () => { const ghAwAvailable = spawnSync('gh', ['aw', '--version'], { encoding: 'utf8' }).status === 0; + // Explicit timeout: this test shells out to the real `gh aw compile` binary, + // which reliably finishes in ~2-3s in isolation but can exceed the 5s vitest + // default under full-suite parallel load/contention. Bumping this avoids + // spurious CI flakiness unrelated to the assertions themselves. it.skipIf(!ghAwAvailable)('strict-compiles and preserves prompt/config behavior', () => { const workspace = createTestWorkspace('gh-aw-compile-'); try { execFileSync('git', ['init', '--quiet'], { cwd: workspace }); - cpSync(WORKFLOWS_DIR, join(workspace, 'workflows'), { recursive: true }); - execFileSync('gh', ['aw', 'compile', 'workflows/squad.md', '--strict'], { + // gh-aw's dispatch-workflow validation (added alongside #1682's + // safe-outputs.dispatch-workflow config) resolves its dispatch target against + // a `.github/workflows/` directory that it locates relative to the compiled + // file's path, assuming the standard `/.github/workflows/.md` + // layout. This repo distributes the gh-aw *source* one level shallower, from a + // top-level `workflows/` directory (see docs/src/content/docs/guide/gh-aw.md), + // which downstream consumers install into their own `.github/workflows/` via + // `gh aw add owner/squad/workflows/squad-implement-worker.md@dev + // owner/squad/workflows/squad.md@dev` — landing both files side-by-side there. + // Mirror that real deployment layout in the ephemeral test workspace (instead + // of a bare `workflows/` copy) so the dispatch target `squad-implement-worker` + // resolves the same way it will for every real downstream install. + cpSync(WORKFLOWS_DIR, join(workspace, '.github', 'workflows'), { recursive: true }); + execFileSync('gh', ['aw', 'compile', '.github/workflows/squad.md', '--strict'], { cwd: workspace, encoding: 'utf8', stdio: 'pipe', }); - const compiled = readFileSync(join(workspace, 'workflows', 'squad.lock.yml'), 'utf8'); + const compiled = readFileSync(join(workspace, '.github', 'workflows', 'squad.lock.yml'), 'utf8'); expect(compiled).toContain('"auto_close_issue":false'); expect(compiled).toContain('"data_enabled":true'); expect(compiled).toContain('"required":["origin_issue","phases","schema_version","squad_artifact"]'); expect(compiled).toContain('"enum":["research","plan","plan-accepted"'); - expect(compiled).toContain('{{#runtime-import shared/planning-ontology.md}}'); - expect(compiled).toContain('{{#runtime-import squad.md}}'); + // gh-aw records runtime-import paths relative to the repo root (not the + // compiled file's own directory), so with the real `.github/workflows/` + // deployment layout these are prefixed accordingly — verified against an + // isolated compile outside this repo/worktree entirely. + expect(compiled).toContain('{{#runtime-import .github/workflows/shared/planning-ontology.md}}'); + expect(compiled).toContain('{{#runtime-import .github/workflows/squad.md}}'); expect(compiled).not.toMatch(//); } finally { rmSync(workspace, { recursive: true, force: true }); } - }); + }, 20000); }); // ---------------------------------------------------------------------------