Skip to content

test(windows): restore github token env in e2e#10359

Merged
jdx merged 1 commit into
mainfrom
codex/fix-windows-token-env
Jun 12, 2026
Merged

test(windows): restore github token env in e2e#10359
jdx merged 1 commit into
mainfrom
codex/fix-windows-token-env

Conversation

@jdx

@jdx jdx commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Summary

  • snapshot GitHub-related environment variables before the Windows token e2e test clears them
  • restore those variables after the test so later Windows e2e cases keep CI GitHub authentication

Root cause

The Windows Pester suite runs in a single PowerShell process. github_token.Tests.ps1 removed GITHUB_TOKEN and MISE_GITHUB_TOKEN to test credential-command behavior, but only cleaned up the credential-command variables afterward. Later tests inherited the missing token state and fell back to unauthenticated GitHub API calls.

Validation

  • git diff --cached --check
  • Not run: Windows Pester suite locally because pwsh is not installed in this environment.

Note

Low Risk
Test-only change to Pester setup/teardown; no production code or runtime behavior.

Overview
Fixes Windows Pester isolation for the GitHub token e2e test by snapshotting a fixed list of GitHub-related process env vars in BeforeEach, clearing them for the test, and restoring the saved values in AfterEach.

Previously the suite only removed token vars and restored two credential/shell vars afterward, so later cases in the same PowerShell run could lose CI GITHUB_TOKEN / MISE_GITHUB_TOKEN and hit unauthenticated GitHub API calls.

Reviewed by Cursor Bugbot for commit f5edcfe. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • Tests
    • Improved test environment variable handling and restoration logic for GitHub token testing, enhancing test reliability and maintainability.

Note: No end-user-facing changes in this release.

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Pester test setup for GitHub token handling is refactored to centralize environment variable management. A new BeforeAll block defines a list of GitHub-related variable names; BeforeEach captures their current values and unsets them; AfterEach restores the originals. Test logic is unchanged.

Changes

GitHub Token Test Fixture Refactoring

Layer / File(s) Summary
Centralized environment variable capture and restoration
e2e-win/github_token.Tests.ps1
BeforeAll defines a centralized array of GitHub environment variable names. BeforeEach snapshots their current values into a hash and unsets them. AfterEach restores original values from the snapshot.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes


A test that whispers, now speaks loud and clear,
Env vars grouped up—no hardcode here!
Snapshot and restore, the dance so fine,
One list to rule them all, by design! 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and clearly describes the main change: restoring GitHub token environment variables in Windows e2e tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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

@greptile-apps

greptile-apps Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes test-isolation pollution in the Windows Pester suite where github_token.Tests.ps1 was clearing GITHUB_TOKEN and related env vars without restoring them, causing later tests to lose GitHub authentication.

  • The old BeforeEach deleted all six token-related env vars; the old AfterEach only removed two of them (MISE_GITHUB_CREDENTIAL_COMMAND and MISE_WINDOWS_DEFAULT_INLINE_SHELL_ARGS), leaving GITHUB_TOKEN, GITHUB_API_TOKEN, MISE_GITHUB_TOKEN, and MISE_GITHUB_ENTERPRISE_TOKEN missing for any subsequent test.
  • The new approach uses [Environment]::GetEnvironmentVariable in BeforeEach to snapshot all six values before clearing them, and [Environment]::SetEnvironmentVariable in AfterEach to restore each one (passing $null correctly removes variables that were absent before the test).

Confidence Score: 5/5

Safe to merge — the change only affects test scaffolding and correctly restores environment state after each test case.

The change is a targeted test-isolation fix in a single Pester file. The snapshot/restore logic is correct: saving $null for unset variables and passing $null back to SetEnvironmentVariable properly removes them, while set values are faithfully restored. No production code is touched.

No files require special attention.

Important Files Changed

Filename Overview
e2e-win/github_token.Tests.ps1 Adds snapshot/restore of all six GitHub-related env vars in BeforeEach/AfterEach, fixing test pollution that left GITHUB_TOKEN unset for subsequent Windows e2e tests.

Reviews (1): Last reviewed commit: "test(windows): restore github token env ..." | Re-trigger Greptile

@jdx jdx enabled auto-merge (squash) June 12, 2026 18:09
@jdx jdx merged commit 7371177 into main Jun 12, 2026
34 checks passed
@jdx jdx deleted the codex/fix-windows-token-env branch June 12, 2026 18:19
@github-actions

Copy link
Copy Markdown

Hyperfine Performance

mise x -- echo

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.6.4 x -- echo 19.6 ± 0.9 18.0 24.9 1.00
mise x -- echo 20.9 ± 1.5 18.5 37.1 1.07 ± 0.09

mise env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.6.4 env 19.5 ± 1.0 17.7 25.8 1.00
mise env 19.9 ± 1.0 18.3 23.3 1.02 ± 0.07

mise hook-env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.6.4 hook-env 21.1 ± 1.8 18.4 29.1 1.00
mise hook-env 21.6 ± 1.5 19.4 28.5 1.03 ± 0.11

mise ls

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.6.4 ls 17.3 ± 1.2 15.5 25.3 1.00
mise ls 18.1 ± 1.2 15.8 23.0 1.05 ± 0.10

xtasks/test/perf

Command mise-2026.6.4 mise Variance
install (cached) 143ms 141ms +1%
ls (cached) 62ms 64ms -3%
bin-paths (cached) 77ms 78ms -1%
task-ls (cached) 153ms 151ms +1%

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.

1 participant