Skip to content

Commit b4d4cb6

Browse files
ci: consolidate Windows bootstrap into composite action
Move the duplicated Bootstrap Windows prerequisites step (git, pwsh via Chocolatey) from test.yml and release.yml into the setup-tauri-build composite action as its first Windows-only step. actions/checkout@v6 falls back to REST API when git is not in PATH, so checkout can safely precede the composite action. The bootstrap uses shell: powershell for bare-image compatibility. Ref: TASK-319
1 parent 3ac0ecf commit b4d4cb6

5 files changed

Lines changed: 83 additions & 31 deletions

File tree

.github/actions/setup-tauri-build/action.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,22 @@ inputs:
1212
runs:
1313
using: 'composite'
1414
steps:
15+
- name: Bootstrap Windows prerequisites (git, pwsh)
16+
if: runner.os == 'Windows'
17+
shell: powershell
18+
run: |
19+
$ProgressPreference = 'SilentlyContinue'
20+
$toInstall = @()
21+
if (-not (Get-Command git -ErrorAction SilentlyContinue)) { $toInstall += 'git' }
22+
if (-not (Get-Command pwsh -ErrorAction SilentlyContinue)) { $toInstall += 'pwsh' }
23+
if ($toInstall.Count -gt 0) {
24+
choco install @toInstall -y
25+
}
26+
$gitPath = (Get-ItemProperty 'HKLM:\SOFTWARE\GitForWindows' -ErrorAction SilentlyContinue).InstallPath
27+
if ($gitPath) {
28+
echo "$gitPath\cmd" >> $env:GITHUB_PATH
29+
}
30+
1531
- name: Read pinned Rust toolchain from .tool-versions (Unix)
1632
if: runner.os != 'Windows'
1733
id: rust-version-unix

.github/workflows/release.yml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -167,21 +167,6 @@ jobs:
167167
timeout-minutes: 45
168168

169169
steps:
170-
- name: Bootstrap Windows prerequisites
171-
shell: powershell
172-
run: |
173-
$ProgressPreference = 'SilentlyContinue'
174-
$toInstall = @()
175-
if (-not (Get-Command git -ErrorAction SilentlyContinue)) { $toInstall += 'git' }
176-
if (-not (Get-Command pwsh -ErrorAction SilentlyContinue)) { $toInstall += 'pwsh' }
177-
if ($toInstall.Count -gt 0) {
178-
choco install @toInstall -y
179-
}
180-
$gitPath = (Get-ItemProperty 'HKLM:\SOFTWARE\GitForWindows' -ErrorAction SilentlyContinue).InstallPath
181-
if ($gitPath) {
182-
echo "$gitPath\cmd" >> $env:GITHUB_PATH
183-
}
184-
185170
- uses: actions/checkout@v6
186171

187172
- name: Setup Tauri build environment

.github/workflows/test.yml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -121,22 +121,6 @@ jobs:
121121
timeout-minutes: 30
122122

123123
steps:
124-
- name: Bootstrap Windows prerequisites
125-
if: runner.os == 'Windows'
126-
shell: powershell
127-
run: |
128-
$ProgressPreference = 'SilentlyContinue'
129-
$toInstall = @()
130-
if (-not (Get-Command git -ErrorAction SilentlyContinue)) { $toInstall += 'git' }
131-
if (-not (Get-Command pwsh -ErrorAction SilentlyContinue)) { $toInstall += 'pwsh' }
132-
if ($toInstall.Count -gt 0) {
133-
choco install @toInstall -y
134-
}
135-
$gitPath = (Get-ItemProperty 'HKLM:\SOFTWARE\GitForWindows' -ErrorAction SilentlyContinue).InstallPath
136-
if ($gitPath) {
137-
echo "$gitPath\cmd" >> $env:GITHUB_PATH
138-
}
139-
140124
- uses: actions/checkout@v6
141125

142126
# Linux: containerized cargo check with Blacksmith Docker layer caching
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
id: TASK-319
3+
title: Reduce repeated Windows CI bootstrap overhead
4+
status: Done
5+
assignee: []
6+
created_date: '2026-04-12 06:59'
7+
updated_date: '2026-04-12 07:17'
8+
labels:
9+
- ci
10+
- github-actions
11+
- windows
12+
- performance
13+
milestone: m-1
14+
dependencies:
15+
- TASK-317
16+
references:
17+
- 'https://github.com/pythoninthegrasses/mt/actions/runs/24300669188'
18+
documentation:
19+
- .github/workflows/test.yml
20+
- .github/workflows/release.yml
21+
- .github/actions/setup-tauri-build/action.yml
22+
- docs/builds.md
23+
priority: medium
24+
ordinal: 750
25+
---
26+
27+
## Description
28+
29+
<!-- SECTION:DESCRIPTION:BEGIN -->
30+
Lower fixed cost in Windows CI jobs by removing or centralizing repeated bootstrap work that happens before the real verification or build steps begin. Keep the workflow reliable on the current runner image while reducing duplicated setup across test and release workflows.
31+
<!-- SECTION:DESCRIPTION:END -->
32+
33+
## Acceptance Criteria
34+
<!-- AC:BEGIN -->
35+
- [x] #1 Repeated Windows bootstrap steps used across workflows are consolidated, removed, or shifted to a more appropriate reusable layer.
36+
- [x] #2 The test and release workflows still succeed on the current Windows runner image without requiring interactive setup.
37+
- [x] #3 Any remaining pre-checkout bootstrap is justified in workflow comments or task notes.
38+
- [x] #4 The resulting workflow change is validated in CI or an equivalent local/static workflow validation step.
39+
<!-- AC:END -->
40+
41+
## Implementation Notes
42+
43+
<!-- SECTION:NOTES:BEGIN -->
44+
## Implementation
45+
46+
### Problem
47+
The "Bootstrap Windows prerequisites" step (installs git + pwsh via Chocolatey, adds git to PATH) was copy-pasted identically in both `test.yml` (build job) and `release.yml` (build-windows job). This ran before `actions/checkout` because it installs git.
48+
49+
### Solution
50+
Moved the bootstrap into the composite action `.github/actions/setup-tauri-build/action.yml` as the first step (conditional on `runner.os == 'Windows'`). Uses `shell: powershell` (not `pwsh`) so it works on bare images where PowerShell 7 isn't yet installed.
51+
52+
Since `actions/checkout@v6` falls back to REST API download when Git 2.18+ isn't in PATH, checkout can safely run before the composite action. The bootstrap then installs git/pwsh for use by subsequent steps.
53+
54+
### Changes
55+
- `.github/actions/setup-tauri-build/action.yml`: Added "Bootstrap Windows prerequisites (git, pwsh)" as the first step, gated on `runner.os == 'Windows'`
56+
- `.github/workflows/test.yml`: Removed standalone bootstrap step from build job
57+
- `.github/workflows/release.yml`: Removed standalone bootstrap step from build-windows job
58+
- `docs/builds.md`: Added note about Windows bootstrap centralization in "CI Setup Modes" section
59+
60+
### Validation
61+
- `actionlint` reports only pre-existing Blacksmith runner label warnings — no new issues
62+
- `actions/checkout` REST API fallback confirmed in upstream docs
63+
- Bootstrap is idempotent (skips install when tools present)
64+
- Release workflow unaffected (still uses `mode: full` default)
65+
<!-- SECTION:NOTES:END -->

docs/builds.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,8 @@ The `check` mode skips Node.js, frontend dependencies, and cargo tools (cargo-bi
608608

609609
Jobs using `mode: check` in `test.yml`: `rust` (lint/test) and `build` matrix (cross-platform `cargo check`).
610610

611+
On Windows, the composite action also bootstraps `git` and `pwsh` via Chocolatey if they are missing from the runner image. This runs before all other steps (using `shell: powershell` for compatibility with bare images) so that `actions/checkout` can use system git and subsequent `pwsh`-shell steps work. The bootstrap is idempotent — it skips installation when the tools are already present.
612+
611613
#### Windows Toolchain Pinning
612614

613615
The self-hosted Windows runner can accumulate stale rustup state across runs. In particular, a system-level settings file (`C:\Windows\system32\config\systemprofile\.rustup\settings.toml`) may set `default_host_triple` to `x86_64-pc-windows-gnu`. When `RUSTUP_TOOLCHAIN` is set to a bare channel name like `nightly-2026-02-09`, rustup resolves it using the default host triple — producing the GNU-hosted toolchain, which requires `dlltool.exe` (not present on MSVC-only runners) and fails with:

0 commit comments

Comments
 (0)