Skip to content

fix: restore real cwd in release-gates tests (backport of #3340) - #3343

Merged
mergify[bot] merged 1 commit into
developfrom
hotfix/jest-cwd-hygiene-develop
Sep 15, 2026
Merged

mergify[bot] merged 1 commit into
developfrom
hotfix/jest-cwd-hygiene-develop

Conversation

@eleshar

@eleshar eleshar commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Linked issues

Refs #3340 (backport)

Summary

Backport of the release-gates.test.js cwd-hygiene fix from PR #3341 (main).

The moduleNameMapper half of #3340 does not apply here — develop already disables the mapper entirely and resolves .cjs/.mjs via moduleFileExtensions instead, so that part of the bug doesn't exist on this branch. The git tag signing/$EDITOR hang also doesn't apply — develop's tag test already uses -m and --no-sign.

What does still apply: several describe blocks in release-gates.test.js reset cwd via process.chdir("/") after each test instead of the real starting directory. Jest reuses one worker process across multiple test files, so this leaves the cwd at filesystem root for whatever test file runs next in that worker, breaking any relative-path resolution downstream (surfaces as e.g. EACCES on a relative mkdir). Fixed by capturing and restoring the real original cwd. Also added the afterEach reset that GATE 5: Authorization and GATE 7: Approval Enforcement were missing entirely (every other gate block had one).

Verification

  • Isolated suite: 41 passed, 41 total (was previously observed hanging/leaving cwd corrupted in the equivalent state on main before the parallel fix there).
  • A full npm run test on this branch still does not complete cleanly, but for reasons unrelated to this change: this repo has a broader pre-existing pattern of scripts calling process.exit() at module-import time (163 files reference process.exit( under scripts/), several of which are require()d directly by their own test files and kill the whole Jest process when their unguarded top-level logic runs in this offline environment (e.g. metrics-collection-orchestrator.cjs, validate-branch-name.js, validate-agent-specs.test.js). That's a separate, much larger audit — out of scope here. Issue #3342 tracks the first instance found; worth broadening to a repo-wide sweep rather than fixing one at a time.

Changelog

Added to CHANGELOG.md under [Unreleased] > Fixed.

Backport of the cwd-hygiene half of #3340 (the moduleNameMapper
regex issue does not apply to develop — this branch already
disables the mapper and relies on moduleFileExtensions instead).

Several describe blocks reset cwd via process.chdir("/") after each
test instead of the real starting directory. Jest reuses one worker
process across multiple test files, so this left cwd at filesystem
root for whatever test file ran next in that worker, breaking any
relative-path resolution downstream (e.g. EACCES on a relative
mkdir). Also adds the missing afterEach reset for GATE 5 and GATE 7,
which had none at all.

Refs #3340
@eleshar
eleshar requested a review from ashleyshaw as a code owner September 15, 2026 14:31
@coderabbitai

coderabbitai Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 49 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Advanced

Run ID: 65f5cb10-6447-4d6b-82bd-acc0fcc86258

📥 Commits

Reviewing files that changed from the base of the PR and between c02b4b6 and 8a1c53a.

📒 Files selected for processing (2)
  • CHANGELOG.md
  • agents/release/gates/__tests__/release-gates.test.js

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

📋 Changelog Quality Validation

Summary

Metric Count
✅ Passing $PASSED
⚠️ Warnings $WARNINGS
❌ Failing $FAILED

Status

Validation PASSED - All entries meet quality standards

How to Fix

Run locally:

cd agents/changelog
npm run validate:changelog

See Changelog Quality Audit for details.

@github-actions

Copy link
Copy Markdown
Contributor

PR Template Routing

Branch Type: hotfix
Scope: jest-cwd-hygiene-develop
Template: pr_hotfix.md
Labels Applied: type:bug,priority:critical

This PR was automatically routed based on the branch naming strategy.

@mergify

mergify Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Queued — the merge queue status continues in this comment ↓.

@mergify

mergify Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • Entered queue2026-09-15 14:45 UTC · Rule: dependabot-develop · triggered by @eleshar with the merge queue checkbox
  • Checks skipped · PR is already up-to-date
  • Merged2026-09-15 14:45 UTC · at dff1eb24679ff7a9b58efed9a5a709a85944ea4e · squash

This pull request spent 26 seconds in the queue, including 2 seconds running CI.

Required conditions to merge

@mergify mergify Bot added the queued label Sep 15, 2026
@mergify
mergify Bot merged commit dff1eb2 into develop Sep 15, 2026
24 checks passed
@mergify
mergify Bot deleted the hotfix/jest-cwd-hygiene-develop branch September 15, 2026 14:45
@mergify mergify Bot removed the queued label Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant