test: fix env-dependent and parallel-process test failures#39467
Conversation
Two orthogonal local test failures, unrelated to product behavior: 1. /tmp/gh-aw transport-file race. create_pull_request.test.cjs and push_to_pull_request_branch.test.cjs (and generate_git_bundle.test.cjs) share the process-global /tmp/gh-aw directory. Each test's beforeEach globbed and deleted every aw-*.patch/aw-*.bundle file in that directory, so when vitest ran the files in parallel processes they deleted each other's in-flight transport files mid-test. Track only the paths each test file creates and delete just those. 2. handle_noop_message.test.cjs depended on an ambient RUNNER_TEMP. getPromptPath() throws unless GH_AW_PROMPTS_DIR or RUNNER_TEMP is set; RUNNER_TEMP is present on CI but not in local dev, so 16 tests threw before reaching their assertions. Set GH_AW_PROMPTS_DIR explicitly in beforeEach (fs.readFileSync is already mocked, so the path is irrelevant).
|
✅ smoke-ci: safeoutputs CLI comment + comment-memory run (27583855533)
|
Comment MemoryNote This comment is managed by comment memory.It stores persistent context for this thread in the code block at the top of this comment.
|
There was a problem hiding this comment.
Pull request overview
This PR updates the JavaScript Vitest suites under actions/setup/js/ to eliminate two sources of non-product-related test failures on main: (1) cross-process races caused by shared cleanup of /tmp/gh-aw transport files, and (2) reliance on CI-only ambient environment variables (RUNNER_TEMP) in handle_noop_message tests.
Changes:
- Replaces “glob/delete everything in
/tmp/gh-aw” cleanup with per-test-file tracking of canonical patch/bundle paths and deletes only those paths. - Makes
handle_noop_message.test.cjsenvironment-independent by explicitly settingGH_AW_PROMPTS_DIRinbeforeEach.
Show a summary per file
| File | Description |
|---|---|
| actions/setup/js/push_to_pull_request_branch.test.cjs | Switches transport cleanup to only remove paths created/used by this test file to avoid parallel-worker races. |
| actions/setup/js/create_pull_request.test.cjs | Applies the same per-file transport-path tracking cleanup to avoid deleting other workers’ in-flight files. |
| actions/setup/js/handle_noop_message.test.cjs | Sets GH_AW_PROMPTS_DIR in setup so tests don’t depend on ambient RUNNER_TEMP. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 2
test: fix env-dependent and parallel-process test failures
What
Fixes two independent, local-only test reliability problems in the JavaScript action test suite. Neither change touches production code.
1 — Transport-file race between parallel Vitest workers
create_pull_request.test.cjsandpush_to_pull_request_branch.test.cjsshare the process-global/tmp/gh-awdirectory. TheirbeforeEachcleanup previously globbed and deleted everyaw-*.patch/aw-*.bundlefile in that directory. When Vitest runs test files as parallel worker processes, one file's cleanup could delete transport files that a sibling file had just written, causing mid-test failures.Fix: introduce a module-level
createdTransportPathsSetin each affected test file. Helper functions (canonicalPatchPath,canonicalBundlePath) register each path they create into that set;cleanupCanonicalTransportsdeletes only those paths. No other file's in-flight files are touched.2 —
handle_noop_message.test.cjsdepended on an ambientRUNNER_TEMPgetPromptPath()throws unlessGH_AW_PROMPTS_DIRorRUNNER_TEMPis set.RUNNER_TEMPis always present on GitHub-hosted runners but absent in most local dev environments, causing all tests in the file to throw before reaching any assertion.Fix: add
process.env.GH_AW_PROMPTS_DIR = tempDirto thebeforeEachsetup. Becausefs.readFileSyncis already mocked, the path value itself is irrelevant.Why
Both failures are test-infrastructure bugs:
handle_noop_messagetests completely unusable outside CI, reducing local developer confidence in the test suite.Files changed
actions/setup/js/create_pull_request.test.cjs/tmp/gh-awscan cleanup withcreatedTransportPathsSetactions/setup/js/push_to_pull_request_branch.test.cjsactions/setup/js/handle_noop_message.test.cjsGH_AW_PROMPTS_DIRinbeforeEachto removeRUNNER_TEMPdependencyRisk
Low. All changes are confined to test files. No production logic, exported interfaces, or CI configuration is modified. The fixes make tests more isolated, not less.