mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
ci: add Git usr/bin to PATH on Windows (#25939)
## Summary Fixes all 9 Windows CI test failures caused by the mise CI refactor (`fe257666d7`, PR #25727). ### Root cause `jdx/mise-action` exports `Path` (Windows convention) via `GITHUB_ENV`. Bash on Windows maintains its own `PATH`. When Go's `os.Environ()` returns both, `cmd.exe` subprocesses non-deterministically pick the MSYS-translated `PATH` (forward slashes), causing Windows executables (`printf`, `powershell.exe`, `cmd.exe`) to be unresolvable. These failures only appeared on `main` (where `-count=1` forces real test execution) and were masked on PRs by Go test cache. ### Fixes applied **CI (`setup-mise` action)**: - Write both `Path` and `PATH` to `GITHUB_ENV` with Git usr/bin prepended **Code (`cli/root.go`)**: - Add `appendAndDedupEnv` helper that deduplicates case-insensitive env vars on Windows, preferring native Windows paths (backslashes) over MSYS paths **Code (`cli/configssh_windows.go`)**: - Use absolute paths for `powershell.exe` and `cmd.exe` in the SSH config `Match exec` escape function, avoiding PATH resolution entirely **Tests**: - Switch `--header-command` tests from `printf` to `echo` (cmd.exe builtin) for reliable cross-platform execution - Add env dedup in `Test_sshConfigMatchExecEscape` for subprocess PATH consistency Fixes coder/internal#1556, coder/internal#1558, coder/internal#1559 > 🤖 Generated by Coder agent, will be reviewed by @mafredri. 🏂🏻
This commit is contained in:
@@ -166,3 +166,23 @@ runs:
|
||||
mise_dir: ${{ steps.mise-data-dir.outputs.path }}
|
||||
install_args: ${{ steps.cache-key.outputs.install-args }}
|
||||
cache: "false"
|
||||
|
||||
- name: Ensure Git usr/bin is in PATH (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
shell: pwsh
|
||||
# jdx/mise-action exports "Path" via GITHUB_ENV which may
|
||||
# collide with bash's "PATH". Ensure Git usr/bin is present
|
||||
# and remove any duplicate Path/PATH entries from GITHUB_ENV
|
||||
# by writing both forms.
|
||||
run: | # zizmor: ignore[github-env]
|
||||
$gitdir = "C:\Program Files\Git\usr\bin"
|
||||
$current = $env:Path
|
||||
if ($current -notlike "*$gitdir*") {
|
||||
$current = "$gitdir;$current"
|
||||
}
|
||||
# Write both Path and PATH to GITHUB_ENV so that both
|
||||
# cmd.exe (uses Path) and bash/Go (uses PATH) see the
|
||||
# same value including Git usr/bin.
|
||||
"Path=$current" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8
|
||||
"PATH=$current" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8
|
||||
|
||||
|
||||
Reference in New Issue
Block a user