From a7466cfd27399e8ee14571fc99c0cb136e82a652 Mon Sep 17 00:00:00 2001 From: JamBalaya56562 Date: Sun, 9 Aug 2026 15:55:52 +0900 Subject: [PATCH] =?UTF-8?q?ci:=20EXPERIMENT=20=E2=80=94=20run=20the=20test?= =?UTF-8?q?=20suite=20on=20windows-latest?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Not for upstream as-is. Measuring what a Windows job actually needs. Round 1 found two things, both now compensated for here: `bash` on windows-latest is the WSL launcher. The image carries System32's bash.exe with no distribution installed, and the executable search order puts it ahead of Git Bash, so `usage bash` exits 1 with "Windows Subsystem for Linux has no installed distributions". My assumption that a stock runner would resolve to a real bash was wrong. `USAGE_SHELL_BASH` names the one meant, which is what #767 added it for. git defaults to core.autocrlf=true on Windows and the repo has no .gitattributes, so fixtures and expected outputs arrived with CRLF and seven help tests plus two markdown tests failed on an ending nobody can see — the diff printed identical text. Set before checkout, or it is too late. `skip_if_shell_missing` now only refuses to skip under CI on Unix, because the workflow installs zsh and fish for the Linux job alone; on Windows their absence is expected rather than a configuration bug. mise draws the same line. Round 1 confirmed this works: shell_completions_integration passed 19/19 with zsh and fish skipping and pwsh running. `skip_if_posix_shell_missing` in complete_word.rs stays strict on purpose, so an unusable bash is reported rather than skipped quietly. In round 1 it fired, correctly. The job runs `cargo test --no-fail-fast` directly rather than `mise r test`, so one failing binary does not hide the rest, and skips render and lint: render asserts a clean git diff, which line endings make unreliable here, and lint is a property of the source rather than the platform. --- .github/workflows/test.yml | 49 ++++++++++++++++++++++ cli/tests/shell_completions_integration.rs | 9 ++-- 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6eabf9e7..244870ac 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -50,3 +50,52 @@ jobs: exit 1 fi - run: mise r lint + + # Build and test only. No render, no lint: `render` asserts a clean git diff, which line + # endings and the checked-in symlinks make unreliable here, and `lint` is a property of the + # source rather than of the platform — the Linux job already covers it. + # + # No shells are installed. GitHub's Windows image has Git Bash and PowerShell but no zsh or + # fish, and the completion tests skip a shell they cannot run rather than failing. mise makes + # the same call: its Windows jobs install no POSIX shells at all. + test-windows: + runs-on: windows-latest + permissions: + contents: read + steps: + # Before checkout, or it is too late. git on Windows defaults to core.autocrlf=true, and + # the repo has no .gitattributes, so fixtures and expected outputs arrive with CRLF and + # every comparison against a checked-in string fails on an ending nobody can see. + - run: git config --global core.autocrlf false + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + submodules: recursive + persist-credentials: false + - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2 + with: + shared-key: test-windows + - uses: jdx/mise-action@dad1bfd3df957f44999b559dd69dc1671cb4e9ea # v4.2.1 + # EXPERIMENT: which shells the runner actually resolves, before anything is added. + - name: where do the shells come from + shell: cmd + run: | + where bash || echo "bash: not found" + where sh || echo "sh: not found" + where pwsh || echo "pwsh: not found" + continue-on-error: true + # `mount run=` starts fixtures with `sh`, and the Git bin directory that holds it is not + # on the runner's PATH by default — only Git's `cmd` directory is, which has git.exe and + # nothing else. Unlike `bash`, `sh` has no System32 impostor, so putting the directory on + # PATH is enough to resolve it. + - run: echo "C:\Program Files\Git\bin" >> $env:GITHUB_PATH + shell: pwsh + - run: mise r build + # Directly rather than through `mise r test`, so one failing binary does not hide the + # rest. EXPERIMENT: revert to `mise r test` before proposing this upstream. + - run: cargo test --all --all-features --no-fail-fast + env: + # The runner has System32's bash.exe — the WSL launcher, with no distribution + # installed — and the executable search order puts it ahead of Git Bash. Measured: + # without this, `usage bash` exits 1 with "Windows Subsystem for Linux has no + # installed distributions". Naming the shell is what #767 added the variable for. + USAGE_SHELL_BASH: C:\Program Files\Git\bin\bash.exe diff --git a/cli/tests/shell_completions_integration.rs b/cli/tests/shell_completions_integration.rs index cfa42251..d7db3c5c 100644 --- a/cli/tests/shell_completions_integration.rs +++ b/cli/tests/shell_completions_integration.rs @@ -83,13 +83,16 @@ fn run_with_timeout(shell: &str, secs: u32, script: &Path) -> std::io::Result bool { if shell_can_run_a_script(shell) { return false; } - if env::var("CI").is_ok_and(|v| !v.is_empty()) { + if cfg!(unix) && env::var("CI").is_ok_and(|v| !v.is_empty()) { panic!("shell `{shell}` cannot run a script but CI is set — refusing to skip"); } eprintln!(