ReviewOS

also looking at this

stacks/buddy

test(pr-body): set the APP_ENV this file needs instead of inheriting it from another

#1455
Merged glennmichael123 wants to merge fix/pr-body-major-updates-app-env into main
1 file +25 -1
8 days ago

main is currently red. The most recent CI run on main (34383875126, sha bc95959) is 2398 pass / 1 fail, and the failure is not a flake.

What fails

PR Body Generation for Major Updates > should match Renovate-style format for major updates asserts the package cell links to github.com:

expect(body).toMatch(/\[stripe\]\([^)]*github\.com[^)]*\)/)

In CI it receives [stripe](https://www.npmjs.com/package/stripe), the no-repository-metadata fallback in pr-generator.ts.

Why

That github link needs info.repository?.url, which comes from ReleaseNotesFetcher.fetchPackageInfo. That method returns fixed metadata, including https://github.com/stripe/stripe-node, only when APP_ENV is test. Otherwise it goes to the registry, which test/preload.ts blocks by design.

This file never set APP_ENV. Five other test files do assign process.env.APP_ENV, and none of them restores it, so in Bun's shared test process the value leaked forward and this file passed whenever one of those ran before it. The outcome was decided by file order.

That is why it looks like a flake: a local full run happens to order it after a file that sets the variable, and CI does not.

Repro

$ bun test test/pr-body-major-updates.test.ts
 2 pass
 1 fail      # ~2s, spent on blocked network retries

$ APP_ENV=test bun test test/pr-body-major-updates.test.ts
 3 pass
 0 fail      # 99ms

The change

The file sets the precondition it depends on, matching what its five siblings already do, and restores the previous value in afterAll so it does not become another source of the same leak.

After: the file passes on its own with no ambient APP_ENV, in 81ms rather than ~2s. Full suite 2405 pass, 0 fail.

Found while investigating CI on #1454, which is unrelated and blocked by this.

🤖 Generated with Claude Code

1 changed file on the files tab, with 0 review threads.

Sign in to comment on this pull request.