Skip to content

Fix Windows CI's Powershell not propagate error by default - #5070

Merged
rami3l merged 3 commits into
rust-lang:mainfrom
Cloud0310:fix/windows-ci-check
Sep 12, 2026
Merged

rami3l merged 3 commits into
rust-lang:mainfrom
Cloud0310:fix/windows-ci-check

Conversation

@Cloud0310

@Cloud0310 Cloud0310 commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Previous Windows GNU and MSVC target on CI/CD has different report. This is what I found when dealing with CI/CD errors on #5056.
This is due to the default shell for running GNU target on Windows is pwsh, and its not exiting upon first error, causing checking failures being ignored.

Note: bug finding assisted by codex GPT-6.

@Cloud0310

Cloud0310 commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

Nah, another OpenSSL build problem.....

@rami3l

rami3l commented Sep 11, 2026

Copy link
Copy Markdown
Member

@Cloud0310 The CI is failing because now with Git Bash, Perl is running under Git Perl instead of Strawberry under Windows. I am afraid we have to do early returns by hand in pwsh now.

@Cloud0310

Cloud0310 commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

@rami3l Fixed and added note for this. Thanks for further bug diagnosis.

@rami3l
rami3l added this pull request to the merge queue Sep 11, 2026
@ChrisDenton

ChrisDenton commented Sep 11, 2026

Copy link
Copy Markdown
Member

Hm, have you considered using $PSNativeCommandUseErrorActionPreference = $true?

@Cloud0310

Cloud0310 commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

Hm, have you considered using "$PSNativeCommandUseErrorActionPreference = $true?

Good idea, would love to try.

@rami3l
rami3l removed this pull request from the merge queue due to a manual request Sep 11, 2026
@Cloud0310 Cloud0310 changed the title Fix Windows CI false report on exitcode Fix Windows CI not propagate error by default. Sep 11, 2026
@Cloud0310 Cloud0310 changed the title Fix Windows CI not propagate error by default. Fix Windows CI's Powershell not propagate error by default Sep 11, 2026
@Cloud0310

Cloud0310 commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

I've pinned to PowerShell on Windows actions, and added comments about this choice in case of future confusion.

@ChrisDenton

Copy link
Copy Markdown
Member

Feel free to ignore this if you don't want to do any bigger refactoring but seeing the repeated use of pwsh and powershell makes me wonder if we could set the default shell to a custom pwsh and then override it only when we really need to run bash. E.g. make the default something like:

shell: pwsh -Command $ErrorActionPreference='stop'; $PSNativeCommandUseErrorActionPreference=$true; & '{0}'

@Cloud0310

Copy link
Copy Markdown
Contributor Author

Feel free to ignore this if you don't want to do any bigger refactoring but seeing the repeated use of pwsh and powershell makes me wonder if we could set the default shell to a custom pwsh and then override it only when we really need to run bash. E.g. make the default something like:

shell: pwsh -Command $ErrorActionPreference='stop'; $PSNativeCommandUseErrorActionPreference=$true; & '{0}'

If so, I guess we can also use:

        run: |
          cargo check --all --all-targets --features test
          git -c core.quotePath=false ls-files -- '*.rs' | ForEach-Object {
            (Get-Item -LiteralPath $_).LastWriteTime = Get-Date
          }

for less dependency upon xargs on PowerShell. Also a small refactor.

@Cloud0310

Cloud0310 commented Sep 12, 2026

Copy link
Copy Markdown
Contributor Author

Just in case, I also added another commit for making Powershell with $ErrorActionPreference='stop' and $ErrorActionPreference='stop' as the default shell on Windows, just in case of future problems. Is this ok? @rami3l @ChrisDenton

@rami3l

rami3l commented Sep 12, 2026

Copy link
Copy Markdown
Member

@Cloud0310 I'd love to see how this experiment goes, and unification looks cool.

One concern I have is that pwsh and powershell are not the same environment and may cause regression afterwards. But we won't know about that until we test it online.

@Cloud0310
Cloud0310 force-pushed the fix/windows-ci-check branch 3 times, most recently from e87fbb0 to 112ea65 Compare September 12, 2026 05:54
Update tracked Rust source timestamps with ForEach-Object and Get-Item, removing the dependency on xargs and touch in Windows jobs.
Use a shared pwsh shell with native command failure propagation for Windows jobs, retaining Bash overrides where required.
@rami3l
rami3l enabled auto-merge September 12, 2026 06:06
@rami3l
rami3l added this pull request to the merge queue Sep 12, 2026
Merged via the queue into rust-lang:main with commit 5fc78f7 Sep 12, 2026
32 checks passed
@rami3l
rami3l deleted the fix/windows-ci-check branch September 12, 2026 06:44
@rami3l

rami3l commented Sep 12, 2026

Copy link
Copy Markdown
Member

@Cloud0310 I'd love to see how this experiment goes, and unification looks cool.

One concern I have is that pwsh and powershell are not the same environment and may cause regression afterwards. But we won't know about that until we test it online.

Okay, so the CI passes but the CD failed for this very reason. I'll try to see what I can do about this.

Comment thread ci/actions-templates/windows-builds-template.yaml
@ChrisDenton

Copy link
Copy Markdown
Member

This is great, thanks for the refactoring @Cloud0310!

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.

4 participants