The "Install rustup" step was duplicated across two jobs: `test-fast` and `test-fixtures-windows`, both conditioned on `windows-11-arm`. There is furthermore the possibility that it may be added in the future to other jobs (such as if it ends up being useful to run the MSRV check on `windows-11-arm`). The duplication was such that it would be easy to wrongly change one but not the other occurrence. If that were to happen, and tests passed/failed or otherwise behaved differently due to differences in their CI environments, then it would create the wrong impression of being related to whether `GIX_TEST_IGNORE_ARCHIVES` is set. To decrease unnecessary duplication, and more specifically to avoid that specific confusion and the wild goose chase that might ensue from it, this extracts the logic of the "Install rustup" steps, other than the `if` key checking that we are running on `windows-11-arm`, to a newly created composite action `setup-windows-arm-rustup`. The reason for keeping the operating system check in the calling jobs is so that it is always immediately clear in the job output whether the step is meant to have an effect. Although composite actions often make sense to publish separately and use across repositories, that is probably not the case here. This logic does only what we need right now, and does not include functionality such as respecting a preexisitng `CARGO_HOME` environment variable or making sure to download `rustup-init.exe` to a location that would be reasonable for all callers. (This does *not* also extract the "Upgrade Git for Windows" step to a composite action. It's not necessary to do so, because the step only currently appears in one job: the `test-fixtures-windows` job, conditioned on `windows-11-arm`. It would, in principle, be useful to extract it nonetheless, because it is cumbersome and also something we've removed and reintroduced before; so making it a composite action could make it more reasonable to keep around for next time it is needed. The problem is that there is a benefit to upgrading Git for Windows before, rather than after, performing any nontrivial Git operations, to decrease the likelihood of dangling subprocesses or otherwise open files preventing the Inno Setup installer from performing the upgrade. There is also a separate specific benefit to upgrading it before `actions/checkout` runs, so that step uses it, thereby effectively validating that it really works. But extracting the "Upgrade Git for Windows" step to a composite action that runs before the `actions/checkout` step is complicated, because the otherwise ideal way to refer to the action locally with a `./` path couldn't be used, because its code would not yet have been checked out. There are ways around this, but their complexity suggests they may not be worthwhile until a composite action is needed in order to actually decrease logic duplication. See the experiments in EliahKagan#68 for details.)
Unified · Split
| @@ -0,0 +1,21 @@ | |||
| 1 | name: setup-windows-arm-rustup | ||
| 2 | |||
| 3 | description: Set up Rustup for AMD64 Windows | ||
| 4 | |||
| 5 | runs: | ||
| 6 | using: composite | ||
| 7 | |||
| 8 | steps: | ||
| 9 | - name: Install Rustup | ||
| 10 | run: | | ||
| 11 | if (Get-Command rustup -ErrorAction SilentlyContinue) { | ||
| 12 | Write-Output '::warning:: The runner has rustup. Consider removing this step.' | ||
| 13 | } else { | ||
| 14 | $file = 'rustup-init.exe' | ||
| 15 | $url = "https://static.rust-lang.org/rustup/dist/aarch64-pc-windows-msvc/$file" | ||
| 16 | curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused -fsSL --output $file $url | ||
| 17 | & ".\$file" --default-toolchain none -y | ||
| 18 | Remove-Item $file | ||
| 19 | Add-Content -Value "$Env:USERPROFILE\.cargo\bin" -Path $Env:GITHUB_PATH | ||
| 20 | } | ||
| 21 | shell: pwsh | ||
| @@ -223,17 +223,7 @@ jobs: · 222 unmodified lines | |||
| 223 | - uses: actions/checkout@v4 | 223 | - uses: actions/checkout@v4 |
| 224 | - name: Install rustup | 224 | - name: Install rustup |
| 225 | if: matrix.os == 'windows-11-arm' | 225 | if: matrix.os == 'windows-11-arm' |
| 226 | run: | | 226 | uses: ./.github/actions/setup-windows-arm-rustup |
| 227 | if (Get-Command rustup -ErrorAction SilentlyContinue) { | ||
| 228 | Write-Output '::warning:: The runner has rustup. Consider removing this step.' | ||
| 229 | } else { | ||
| 230 | $file = 'rustup-init.exe' | ||
| 231 | $url = "https://static.rust-lang.org/rustup/dist/aarch64-pc-windows-msvc/$file" | ||
| 232 | curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused -fsSL --output $file $url | ||
| 233 | & ".\$file" --default-toolchain none -y | ||
| 234 | Remove-Item $file | ||
| 235 | Add-Content -Value "$Env:USERPROFILE\.cargo\bin" -Path $Env:GITHUB_PATH | ||
| 236 | } | ||
| 237 | - uses: dtolnay/rust-toolchain@stable | 227 | - uses: dtolnay/rust-toolchain@stable |
| 238 | - uses: Swatinem/rust-cache@v2 | 228 | - uses: Swatinem/rust-cache@v2 |
| 239 | - name: cargo check default features | 229 | - name: cargo check default features |
| @@ -300,17 +290,7 @@ jobs: · 60 unmodified lines | |||
| 300 | - uses: actions/checkout@v4 | 290 | - uses: actions/checkout@v4 |
| 301 | - name: Install rustup | 291 | - name: Install rustup |
| 302 | if: matrix.os == 'windows-11-arm' | 292 | if: matrix.os == 'windows-11-arm' |
| 303 | run: | | 293 | uses: ./.github/actions/setup-windows-arm-rustup |
| 304 | if (Get-Command rustup -ErrorAction SilentlyContinue) { | ||
| 305 | Write-Output '::warning:: The runner has rustup. Consider removing this step.' | ||
| 306 | } else { | ||
| 307 | $file = 'rustup-init.exe' | ||
| 308 | $url = "https://static.rust-lang.org/rustup/dist/aarch64-pc-windows-msvc/$file" | ||
| 309 | curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused -fsSL --output $file $url | ||
| 310 | & ".\$file" --default-toolchain none -y | ||
| 311 | Remove-Item $file | ||
| 312 | Add-Content -Value "$Env:USERPROFILE\.cargo\bin" -Path $Env:GITHUB_PATH | ||
| 313 | } | ||
| 314 | - uses: dtolnay/rust-toolchain@stable | 294 | - uses: dtolnay/rust-toolchain@stable |
| 315 | - uses: Swatinem/rust-cache@v2 | 295 | - uses: Swatinem/rust-cache@v2 |
| 316 | - uses: taiki-e/install-action@v2 | 296 | - uses: taiki-e/install-action@v2 |