Skip to content

test: fix env-dependent and parallel-process test failures#39467

Merged
dsyme merged 1 commit into
mainfrom
dsyme/fix-test-isolation
Jun 15, 2026
Merged

test: fix env-dependent and parallel-process test failures#39467
dsyme merged 1 commit into
mainfrom
dsyme/fix-test-isolation

Conversation

@dsyme

@dsyme dsyme commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

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.cjs and push_to_pull_request_branch.test.cjs share the process-global /tmp/gh-aw directory. Their beforeEach cleanup previously globbed and deleted every aw-*.patch / aw-*.bundle file 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 createdTransportPaths Set in each affected test file. Helper functions (canonicalPatchPath, canonicalBundlePath) register each path they create into that set; cleanupCanonicalTransports deletes only those paths. No other file's in-flight files are touched.

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 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 = tempDir to the beforeEach setup. Because fs.readFileSync is already mocked, the path value itself is irrelevant.

Why

Both failures are test-infrastructure bugs:

  • The race made parallel local runs non-deterministic and silently broken for developers.
  • The missing env var made handle_noop_message tests completely unusable outside CI, reducing local developer confidence in the test suite.

Files changed

File Change
actions/setup/js/create_pull_request.test.cjs Replace global /tmp/gh-aw scan cleanup with createdTransportPaths Set
actions/setup/js/push_to_pull_request_branch.test.cjs Same transport-path tracking fix
actions/setup/js/handle_noop_message.test.cjs Set GH_AW_PROMPTS_DIR in beforeEach to remove RUNNER_TEMP dependency

Risk

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.

Generated by PR Description Updater for issue #39467 · 98.1 AIC · ⌖ 12.7 AIC · ⊞ 19.9K ·

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).
Copilot AI review requested due to automatic review settings June 15, 2026 23:44
@github-actions

Copy link
Copy Markdown
Contributor

✅ smoke-ci: safeoutputs CLI comment + comment-memory run (27583855533)

Generated by 🧪 Smoke CI for issue #39467 ·

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

CI lights the path
Green checks bloom at dawn
Quiet bots still sing

Note

This comment is managed by comment memory.

It stores persistent context for this thread in the code block at the top of this comment.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

Generated by 🧪 Smoke CI for issue #39467 ·

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.cjs environment-independent by explicitly setting GH_AW_PROMPTS_DIR in beforeEach.
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

Comment thread actions/setup/js/create_pull_request.test.cjs
Comment thread actions/setup/js/push_to_pull_request_branch.test.cjs
@dsyme dsyme merged commit 003762a into main Jun 15, 2026
29 checks passed
@dsyme dsyme deleted the dsyme/fix-test-isolation branch June 15, 2026 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants