Skip to content

[ENG-4046] Pin the guide tests to a local project so Publish passes on main - #311

Merged
mariojgt merged 1 commit into
mainfrom
mariot/eng-4046-pin-guide-test-env
Sep 28, 2026
Merged

mariojgt merged 1 commit into
mainfrom
mariot/eng-4046-pin-guide-test-env

Conversation

@mariojgt

Copy link
Copy Markdown
Contributor

Ref ENG-4046

What changed

Every test in tests/guide.test.ts now runs as a project on a developer's machine (PATCHSTACK_ENVIRONMENT=local), set once in each beforeEach. It replaces the two single-test pins added in #299.

Why it broke

The Publish workflow failed on three guide tests (run), after the same tests passed on the pull request.

Since #299, the checklist names the environment the scan reports from. The CLI works that out from the machine's variables, and GitHub Actions sets them:

  • a pull-request run reads as sandbox;
  • the publish job, a workflow_dispatch on main, reads as production.

The tests expect a local project, so they saw "Sync and monitor in production environment" and the production next step. #299 pinned only the two tests that the pull-request run caught. Three more only differ between local and production, so they only failed on main.

The CLI's behaviour is right. The tests were reading the runner's environment instead of stating their own.

Fix

  • Set PATCHSTACK_ENVIRONMENT=local in both beforeEach blocks of tests/guide.test.ts. afterEach already restores the original environment, so nothing leaks into other files.
  • Remove the two single-test pins, which are now redundant.

Verified

npx vitest run, all 207 files, in the three places it runs:

Context Result
Laptop (no CI variables) 3,454 passed, 7 skipped
Pull request (GITHUB_EVENT_NAME=pull_request) 3,454 passed, 7 skipped
Publish on main (GITHUB_EVENT_NAME=workflow_dispatch, GITHUB_REF=refs/heads/main) 3,454 passed, 7 skipped

Before the fix, the third row reproduced the three Publish failures exactly.

Docs: not needed. Test-only change.

🤖 Generated with Claude Code

The publish job runs on main, where the CLI reads GitHub's own variables
as a production build. Three guide tests that expect a local project
failed there after passing on the pull request, which reads as sandbox.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@mariojgt

Copy link
Copy Markdown
Contributor Author

/review

@coderbuds

coderbuds Bot commented Sep 28, 2026

Copy link
Copy Markdown

Tests now pin PATCHSTACK_ENVIRONMENT to ensure consistent CI behavior.

🎯 Quality: 92% Elite · 📦 Size: Small

📈 This month: Your 141st PR — above team average · Averaging Excellent

See how your team is trending →

@mariojgt
mariojgt merged commit 1e8cf05 into main Sep 28, 2026
18 checks passed
@mariojgt
mariojgt deleted the mariot/eng-4046-pin-guide-test-env branch September 28, 2026 14: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