Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 6 additions & 3 deletions cli/tests/shell_completions_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,16 @@ fn run_with_timeout(shell: &str, secs: u32, script: &Path) -> std::io::Result<Ou
/// the thing it guards must be the same executable, or an override would be honoured by one and
/// not the other.
///
/// Panics under `CI=1` (or any non-empty `CI`) to prevent silent false-positives in CI: if a
/// shell is unusable in CI it's a configuration bug, not an excuse to skip the test.
/// Panics under `CI=1` (or any non-empty `CI`) to prevent silent false-positives: if a shell is
/// unusable on a runner that went to the trouble of installing it, that is a configuration bug,
/// not an excuse to skip. The workflow installs zsh and fish for the Linux job only, so on
/// Windows their absence is the expected state rather than a bug and the rule does not apply.
/// mise draws the same line — its Windows runners install no POSIX shells at all.
fn skip_if_shell_missing(shell: &str) -> 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!(
Expand Down
Loading