Skip to content

Commit 4a90611

Browse files
committed
Improve PowerShell WSL prechecks and CI coverage
1 parent 4e9eee9 commit 4a90611

3 files changed

Lines changed: 46 additions & 11 deletions

File tree

.github/workflows/cpp-build.yml

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
name: C++ Build Matrix
1+
name: Repository CI
22

33
on:
44
push:
55
pull_request:
66

77
jobs:
8-
build-linux:
8+
linux-bash:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Checkout
@@ -22,7 +22,10 @@ jobs:
2222
- name: Compile all C++ files
2323
run: bash ./scripts/build-all.sh
2424

25-
build-windows:
25+
- name: Verify repository
26+
run: bash ./scripts/verify-repo.sh
27+
28+
windows-powershell:
2629
runs-on: windows-latest
2730
steps:
2831
- name: Checkout
@@ -31,18 +34,29 @@ jobs:
3134
- name: Setup MSYS2
3235
uses: msys2/setup-msys2@v2
3336
with:
34-
msystem: MINGW64
37+
msystem: UCRT64
3538
path-type: inherit
3639
update: true
3740
install: >-
38-
mingw-w64-x86_64-gcc
41+
mingw-w64-ucrt-x86_64-gcc
3942
40-
- name: Check markdown links
41-
shell: msys2 {0}
43+
- name: Add MinGW to PATH
44+
shell: pwsh
4245
run: |
43-
./scripts/check-links.sh
46+
"C:\msys64\ucrt64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
47+
48+
- name: Confirm g++ toolchain
49+
shell: pwsh
50+
run: g++ --version
51+
52+
- name: Check markdown links
53+
shell: pwsh
54+
run: powershell -ExecutionPolicy Bypass -File scripts\check-links.ps1
4455

4556
- name: Compile all C++ files
46-
shell: msys2 {0}
47-
run: |
48-
./scripts/build-all.sh
57+
shell: pwsh
58+
run: powershell -ExecutionPolicy Bypass -File scripts\build-all.ps1
59+
60+
- name: Verify repository
61+
shell: pwsh
62+
run: powershell -ExecutionPolicy Bypass -File scripts\verify-repo.ps1

scripts/build-all.ps1

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ function Assert-LastExitCode([string]$action) {
1818
}
1919
}
2020

21+
function Assert-WslToolchainReady() {
22+
wsl bash -lc "command -v g++ >/dev/null 2>&1"
23+
if ($LASTEXITCODE -ne 0) {
24+
Write-Host "WSL fallback is not ready: unable to run g++ inside WSL."
25+
Write-Host "Install g++ in WSL, fix WSL access, or install native g++ on Windows."
26+
exit 1
27+
}
28+
}
29+
2130
$cppFiles = Get-ChildItem -Recurse -Path "languages/cpp" -Filter "*.cpp"
2231
if ($cppFiles.Count -eq 0) {
2332
Write-Host "No C++ files found under languages/cpp"
@@ -35,6 +44,7 @@ if (-not $nativeGpp) {
3544
if ($runningOnWindows -and $wslCommand) {
3645
$useWsl = $true
3746
Write-Host "Native g++ not found. Using WSL g++ fallback."
47+
Assert-WslToolchainReady
3848
} else {
3949
Write-Host "g++ was not found in PATH."
4050
Write-Host "Install g++ (or use WSL on Windows) and try again."

scripts/run-module.ps1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ function Assert-LastExitCode([string]$action) {
2222
}
2323
}
2424

25+
function Assert-WslToolchainReady() {
26+
wsl bash -lc "command -v g++ >/dev/null 2>&1"
27+
if ($LASTEXITCODE -ne 0) {
28+
Write-Host "WSL fallback is not ready: unable to run g++ inside WSL."
29+
Write-Host "Install g++ in WSL, fix WSL access, or install native g++ on Windows."
30+
exit 1
31+
}
32+
}
33+
2534
$normalized = $ModulePath -replace "\\", "/"
2635
$fullModulePath = Join-Path $root $normalized
2736
$runningOnWindows = $env:OS -eq "Windows_NT"
@@ -46,6 +55,8 @@ $useWsl = $false
4655
if (-not $nativeGpp) {
4756
if ($runningOnWindows -and $wslCommand) {
4857
$useWsl = $true
58+
Write-Host "Native g++ not found. Using WSL g++ fallback."
59+
Assert-WslToolchainReady
4960
} else {
5061
Write-Host "g++ was not found in PATH."
5162
Write-Host "Install g++ (or use WSL on Windows) and try again."

0 commit comments

Comments
 (0)