From 3fbc806e772cc0fa03a94d91c7bcac7b5f8a9004 Mon Sep 17 00:00:00 2001 From: Alan Tse Date: Sat, 21 Jun 2025 17:49:39 -0700 Subject: [PATCH 1/6] ci: cache with msvc key --- .github/workflows/build.yaml | 41 +++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index d5d91cc978..13babcb621 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -125,9 +125,18 @@ jobs: with: arch: x64 - - name: Check cl.exe version - run: cl.exe /Bv 2>&1 || exit 0 - shell: cmd + - name: Get MSVC version + id: msvc_version + shell: pwsh + run: | + $output = & cl.exe /Bv 2>&1 + if ($output -match 'Compiler Version ([0-9\\.]+)') { + $version = $Matches[1] + Write-Host "MSVC version: $version" + echo "version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append + } else { + throw "MSVC version not found" + } - name: Setup vcpkg uses: lukka/run-vcpkg@v11.5 @@ -138,9 +147,10 @@ jobs: uses: actions/cache@v4 with: path: build/ALL - key: ${{ runner.os }}-cmake-${{ github.event.inputs.cache-key-suffix || 'default' }}-${{ hashFiles('.gitmodules', 'extern/**', 'CMakePresets.json', 'vcpkg.json', 'vcpkg-configuration.json') }} + key: ${{ runner.os }}-cmake-msvc-${{ steps.msvc_version.outputs.version }}-${{ github.event.inputs.cache-key-suffix || 'default' }}-${{ hashFiles('.gitmodules', 'extern/**', 'CMakePresets.json', 'vcpkg.json', 'vcpkg-configuration.json') }} restore-keys: | - ${{ runner.os }}-cmake-${{ github.event.inputs.cache-key-suffix || 'default' }}- + ${{ runner.os }}-cmake-msvc-${{ steps.msvc_version.outputs.version }}-${{ github.event.inputs.cache-key-suffix || 'default' }}- + ${{ runner.os }}-cmake-msvc-${{ steps.msvc_version.outputs.version }}- ${{ runner.os }}-cmake- - name: Remove stale CMake cache if drive letter changed @@ -235,6 +245,20 @@ jobs: - uses: ilammy/msvc-dev-cmd@v1 if: steps.check-hlsl.outputs.skip != 'true' + - name: Get MSVC version + if: steps.check-hlsl.outputs.skip != 'true' + id: msvc_version + shell: pwsh + run: | + $output = & cl.exe /Bv 2>&1 + if ($output -match 'Compiler Version ([0-9\\.]+)') { + $version = $Matches[1] + Write-Host "MSVC version: $version" + echo "version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append + } else { + throw "MSVC version not found" + } + - name: Setup vcpkg if: steps.check-hlsl.outputs.skip != 'true' uses: lukka/run-vcpkg@v11.5 @@ -246,10 +270,11 @@ jobs: uses: actions/cache@v4 with: path: build/ALL - key: ${{ runner.os }}-cmake-${{ matrix.config.name }}-${{ github.event.inputs.cache-key-suffix || 'default' }}-${{ hashFiles('.gitmodules', 'extern/**', 'CMakePresets.json', 'vcpkg.json', 'vcpkg-configuration.json') }} + key: ${{ runner.os }}-cmake-msvc-${{ steps.msvc_version.outputs.version }}-${{ matrix.config.name }}-${{ github.event.inputs.cache-key-suffix || 'default' }}-${{ hashFiles('.gitmodules', 'extern/**', 'CMakePresets.json', 'vcpkg.json', 'vcpkg-configuration.json') }} restore-keys: | - ${{ runner.os }}-cmake-${{ matrix.config.name }}-${{ github.event.inputs.cache-key-suffix || 'default' }}- - ${{ runner.os }}-cmake-${{ matrix.config.name }}- + ${{ runner.os }}-cmake-msvc-${{ steps.msvc_version.outputs.version }}-${{ matrix.config.name }}-${{ github.event.inputs.cache-key-suffix || 'default' }}- + ${{ runner.os }}-cmake-msvc-${{ steps.msvc_version.outputs.version }}-${{ matrix.config.name }}- + ${{ runner.os }}-cmake-msvc-${{ steps.msvc_version.outputs.version }}- ${{ runner.os }}-cmake- - name: Remove stale CMake cache if drive letter changed From 7b72559aa268adbbbe386682ee84f5d0a3c79cd3 Mon Sep 17 00:00:00 2001 From: "Alan D. Tse" Date: Sat, 21 Jun 2025 18:59:24 -0700 Subject: [PATCH 2/6] ci: make version extraction robust --- .github/workflows/build.yaml | 66 ++++++++++++++++++++++++++++++------ 1 file changed, 56 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 13babcb621..cb99e10a77 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -130,12 +130,35 @@ jobs: shell: pwsh run: | $output = & cl.exe /Bv 2>&1 - if ($output -match 'Compiler Version ([0-9\\.]+)') { - $version = $Matches[1] - Write-Host "MSVC version: $version" - echo "version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append + Write-Host "Raw cl.exe output:" + Write-Host $output + + # Try multiple patterns to extract version + $version = $null + + # Pattern 1: "Compiler Version X.Y.Z" + if ($output -match 'Compiler Version ([0-9]+\.[0-9]+\.[0-9]+)') { + $version = $Matches[1] + Write-Host "Found version using pattern 1: $version" + } + # Pattern 2: "Version X.Y.Z" + elseif ($output -match 'Version ([0-9]+\.[0-9]+\.[0-9]+)') { + $version = $Matches[1] + Write-Host "Found version using pattern 2: $version" + } + # Pattern 3: "X.Y.Z" (any version-like string) + elseif ($output -match '([0-9]+\.[0-9]+\.[0-9]+)') { + $version = $Matches[1] + Write-Host "Found version using pattern 3: $version" + } + + if ($version) { + Write-Host "MSVC version: $version" + Add-Content -Path $env:GITHUB_OUTPUT -Value "version=$version" -Encoding UTF8 } else { - throw "MSVC version not found" + Write-Host "Failed to extract MSVC version from output:" + Write-Host $output + throw "MSVC version not found in output" } - name: Setup vcpkg @@ -251,12 +274,35 @@ jobs: shell: pwsh run: | $output = & cl.exe /Bv 2>&1 - if ($output -match 'Compiler Version ([0-9\\.]+)') { - $version = $Matches[1] - Write-Host "MSVC version: $version" - echo "version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append + Write-Host "Raw cl.exe output:" + Write-Host $output + + # Try multiple patterns to extract version + $version = $null + + # Pattern 1: "Compiler Version X.Y.Z" + if ($output -match 'Compiler Version ([0-9]+\.[0-9]+\.[0-9]+)') { + $version = $Matches[1] + Write-Host "Found version using pattern 1: $version" + } + # Pattern 2: "Version X.Y.Z" + elseif ($output -match 'Version ([0-9]+\.[0-9]+\.[0-9]+)') { + $version = $Matches[1] + Write-Host "Found version using pattern 2: $version" + } + # Pattern 3: "X.Y.Z" (any version-like string) + elseif ($output -match '([0-9]+\.[0-9]+\.[0-9]+)') { + $version = $Matches[1] + Write-Host "Found version using pattern 3: $version" + } + + if ($version) { + Write-Host "MSVC version: $version" + Add-Content -Path $env:GITHUB_OUTPUT -Value "version=$version" -Encoding UTF8 } else { - throw "MSVC version not found" + Write-Host "Failed to extract MSVC version from output:" + Write-Host $output + throw "MSVC version not found in output" } - name: Setup vcpkg From 23ccf34f3476d4954054353da6f7d4dd96555c68 Mon Sep 17 00:00:00 2001 From: "Alan D. Tse" Date: Sat, 21 Jun 2025 19:45:21 -0700 Subject: [PATCH 3/6] ci: address D8003 --- .github/workflows/build.yaml | 50 ++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index cb99e10a77..3d21088437 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -129,28 +129,36 @@ jobs: id: msvc_version shell: pwsh run: | - $output = & cl.exe /Bv 2>&1 + # Create a dummy source file for cl.exe /Bv + "int main() { return 0; }" | Out-File -FilePath "dummy.cpp" -Encoding ASCII + + $output = & cl.exe /Bv dummy.cpp 2>&1 Write-Host "Raw cl.exe output:" Write-Host $output # Try multiple patterns to extract version $version = $null - # Pattern 1: "Compiler Version X.Y.Z" - if ($output -match 'Compiler Version ([0-9]+\.[0-9]+\.[0-9]+)') { + # Pattern 1: "Microsoft (R) C/C++ Optimizing Compiler Version X.Y.Z" + if ($output -match 'Microsoft \(R\) C/C\+\+ Optimizing Compiler Version ([0-9]+\.[0-9]+\.[0-9]+)') { $version = $Matches[1] Write-Host "Found version using pattern 1: $version" } - # Pattern 2: "Version X.Y.Z" - elseif ($output -match 'Version ([0-9]+\.[0-9]+\.[0-9]+)') { + # Pattern 2: "Compiler Version X.Y.Z" + elseif ($output -match 'Compiler Version ([0-9]+\.[0-9]+\.[0-9]+)') { $version = $Matches[1] Write-Host "Found version using pattern 2: $version" } - # Pattern 3: "X.Y.Z" (any version-like string) - elseif ($output -match '([0-9]+\.[0-9]+\.[0-9]+)') { + # Pattern 3: "Version X.Y.Z" + elseif ($output -match 'Version ([0-9]+\.[0-9]+\.[0-9]+)') { $version = $Matches[1] Write-Host "Found version using pattern 3: $version" } + # Pattern 4: "X.Y.Z" (any version-like string) + elseif ($output -match '([0-9]+\.[0-9]+\.[0-9]+)') { + $version = $Matches[1] + Write-Host "Found version using pattern 4: $version" + } if ($version) { Write-Host "MSVC version: $version" @@ -161,6 +169,9 @@ jobs: throw "MSVC version not found in output" } + # Clean up dummy file + Remove-Item "dummy.cpp" -ErrorAction SilentlyContinue + - name: Setup vcpkg uses: lukka/run-vcpkg@v11.5 with: @@ -273,28 +284,36 @@ jobs: id: msvc_version shell: pwsh run: | - $output = & cl.exe /Bv 2>&1 + # Create a dummy source file for cl.exe /Bv + "int main() { return 0; }" | Out-File -FilePath "dummy.cpp" -Encoding ASCII + + $output = & cl.exe /Bv dummy.cpp 2>&1 Write-Host "Raw cl.exe output:" Write-Host $output # Try multiple patterns to extract version $version = $null - # Pattern 1: "Compiler Version X.Y.Z" - if ($output -match 'Compiler Version ([0-9]+\.[0-9]+\.[0-9]+)') { + # Pattern 1: "Microsoft (R) C/C++ Optimizing Compiler Version X.Y.Z" + if ($output -match 'Microsoft \(R\) C/C\+\+ Optimizing Compiler Version ([0-9]+\.[0-9]+\.[0-9]+)') { $version = $Matches[1] Write-Host "Found version using pattern 1: $version" } - # Pattern 2: "Version X.Y.Z" - elseif ($output -match 'Version ([0-9]+\.[0-9]+\.[0-9]+)') { + # Pattern 2: "Compiler Version X.Y.Z" + elseif ($output -match 'Compiler Version ([0-9]+\.[0-9]+\.[0-9]+)') { $version = $Matches[1] Write-Host "Found version using pattern 2: $version" } - # Pattern 3: "X.Y.Z" (any version-like string) - elseif ($output -match '([0-9]+\.[0-9]+\.[0-9]+)') { + # Pattern 3: "Version X.Y.Z" + elseif ($output -match 'Version ([0-9]+\.[0-9]+\.[0-9]+)') { $version = $Matches[1] Write-Host "Found version using pattern 3: $version" } + # Pattern 4: "X.Y.Z" (any version-like string) + elseif ($output -match '([0-9]+\.[0-9]+\.[0-9]+)') { + $version = $Matches[1] + Write-Host "Found version using pattern 4: $version" + } if ($version) { Write-Host "MSVC version: $version" @@ -305,6 +324,9 @@ jobs: throw "MSVC version not found in output" } + # Clean up dummy file + Remove-Item "dummy.cpp" -ErrorAction SilentlyContinue + - name: Setup vcpkg if: steps.check-hlsl.outputs.skip != 'true' uses: lukka/run-vcpkg@v11.5 From 213e51567f86a7dbc273181785808a0e5b8c0cc5 Mon Sep 17 00:00:00 2001 From: "Alan D. Tse" Date: Sat, 21 Jun 2025 20:04:46 -0700 Subject: [PATCH 4/6] ci: further regex checks --- .github/workflows/build.yaml | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 3d21088437..1b07d4b2c4 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -139,18 +139,20 @@ jobs: # Try multiple patterns to extract version $version = $null - # Pattern 1: "Microsoft (R) C/C++ Optimizing Compiler Version X.Y.Z" - if ($output -match 'Microsoft \(R\) C/C\+\+ Optimizing Compiler Version ([0-9]+\.[0-9]+\.[0-9]+)') { + Write-Host "Attempting to match patterns..." + + # Pattern 1: Simple "Version X.Y.Z" (most reliable) + if ($output -match 'Version ([0-9]+\.[0-9]+\.[0-9]+)') { $version = $Matches[1] Write-Host "Found version using pattern 1: $version" } - # Pattern 2: "Compiler Version X.Y.Z" - elseif ($output -match 'Compiler Version ([0-9]+\.[0-9]+\.[0-9]+)') { + # Pattern 2: "Microsoft (R) C/C++ Optimizing Compiler Version X.Y.Z" + elseif ($output -match 'Microsoft \(R\) C/C\+\+ Optimizing Compiler Version ([0-9]+\.[0-9]+\.[0-9]+)') { $version = $Matches[1] Write-Host "Found version using pattern 2: $version" } - # Pattern 3: "Version X.Y.Z" - elseif ($output -match 'Version ([0-9]+\.[0-9]+\.[0-9]+)') { + # Pattern 3: "Compiler Version X.Y.Z" + elseif ($output -match 'Compiler Version ([0-9]+\.[0-9]+\.[0-9]+)') { $version = $Matches[1] Write-Host "Found version using pattern 3: $version" } @@ -160,6 +162,9 @@ jobs: Write-Host "Found version using pattern 4: $version" } + Write-Host "Final version result: $version" + Write-Host "Matches array: $($Matches | ConvertTo-Json)" + if ($version) { Write-Host "MSVC version: $version" Add-Content -Path $env:GITHUB_OUTPUT -Value "version=$version" -Encoding UTF8 @@ -294,18 +299,20 @@ jobs: # Try multiple patterns to extract version $version = $null - # Pattern 1: "Microsoft (R) C/C++ Optimizing Compiler Version X.Y.Z" - if ($output -match 'Microsoft \(R\) C/C\+\+ Optimizing Compiler Version ([0-9]+\.[0-9]+\.[0-9]+)') { + Write-Host "Attempting to match patterns..." + + # Pattern 1: Simple "Version X.Y.Z" (most reliable) + if ($output -match 'Version ([0-9]+\.[0-9]+\.[0-9]+)') { $version = $Matches[1] Write-Host "Found version using pattern 1: $version" } - # Pattern 2: "Compiler Version X.Y.Z" - elseif ($output -match 'Compiler Version ([0-9]+\.[0-9]+\.[0-9]+)') { + # Pattern 2: "Microsoft (R) C/C++ Optimizing Compiler Version X.Y.Z" + elseif ($output -match 'Microsoft \(R\) C/C\+\+ Optimizing Compiler Version ([0-9]+\.[0-9]+\.[0-9]+)') { $version = $Matches[1] Write-Host "Found version using pattern 2: $version" } - # Pattern 3: "Version X.Y.Z" - elseif ($output -match 'Version ([0-9]+\.[0-9]+\.[0-9]+)') { + # Pattern 3: "Compiler Version X.Y.Z" + elseif ($output -match 'Compiler Version ([0-9]+\.[0-9]+\.[0-9]+)') { $version = $Matches[1] Write-Host "Found version using pattern 3: $version" } @@ -315,6 +322,9 @@ jobs: Write-Host "Found version using pattern 4: $version" } + Write-Host "Final version result: $version" + Write-Host "Matches array: $($Matches | ConvertTo-Json)" + if ($version) { Write-Host "MSVC version: $version" Add-Content -Path $env:GITHUB_OUTPUT -Value "version=$version" -Encoding UTF8 From 6add44a05d1f2f6efcadad45009dd93d7b012c5f Mon Sep 17 00:00:00 2001 From: "Alan D. Tse" Date: Sat, 21 Jun 2025 20:10:27 -0700 Subject: [PATCH 5/6] ci: split lines --- .github/workflows/build.yaml | 100 +++++++++++++++++++++-------------- 1 file changed, 60 insertions(+), 40 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 1b07d4b2c4..b3a272e3aa 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -136,30 +136,40 @@ jobs: Write-Host "Raw cl.exe output:" Write-Host $output - # Try multiple patterns to extract version + # More robust version extraction $version = $null - Write-Host "Attempting to match patterns..." + # Split output into lines and search for version patterns + $lines = $output -split "`n|`r" + Write-Host "Number of lines: $($lines.Count)" - # Pattern 1: Simple "Version X.Y.Z" (most reliable) - if ($output -match 'Version ([0-9]+\.[0-9]+\.[0-9]+)') { - $version = $Matches[1] - Write-Host "Found version using pattern 1: $version" - } - # Pattern 2: "Microsoft (R) C/C++ Optimizing Compiler Version X.Y.Z" - elseif ($output -match 'Microsoft \(R\) C/C\+\+ Optimizing Compiler Version ([0-9]+\.[0-9]+\.[0-9]+)') { - $version = $Matches[1] - Write-Host "Found version using pattern 2: $version" - } - # Pattern 3: "Compiler Version X.Y.Z" - elseif ($output -match 'Compiler Version ([0-9]+\.[0-9]+\.[0-9]+)') { - $version = $Matches[1] - Write-Host "Found version using pattern 3: $version" + foreach ($line in $lines) { + Write-Host "Processing line: '$line'" + + # Try different patterns on each line + if ($line -match 'Version ([0-9]+\.[0-9]+\.[0-9]+)') { + $version = $Matches[1] + Write-Host "Found version in line: $version" + break + } + elseif ($line -match '([0-9]+\.[0-9]+\.[0-9]+)') { + $version = $Matches[1] + Write-Host "Found generic version in line: $version" + break + } } - # Pattern 4: "X.Y.Z" (any version-like string) - elseif ($output -match '([0-9]+\.[0-9]+\.[0-9]+)') { - $version = $Matches[1] - Write-Host "Found version using pattern 4: $version" + + # If still no version, try the whole output as a single string + if (-not $version) { + Write-Host "Trying whole output as single string..." + if ($output -match 'Version ([0-9]+\.[0-9]+\.[0-9]+)') { + $version = $Matches[1] + Write-Host "Found version in whole output: $version" + } + elseif ($output -match '([0-9]+\.[0-9]+\.[0-9]+)') { + $version = $Matches[1] + Write-Host "Found generic version in whole output: $version" + } } Write-Host "Final version result: $version" @@ -296,30 +306,40 @@ jobs: Write-Host "Raw cl.exe output:" Write-Host $output - # Try multiple patterns to extract version + # More robust version extraction $version = $null - Write-Host "Attempting to match patterns..." + # Split output into lines and search for version patterns + $lines = $output -split "`n|`r" + Write-Host "Number of lines: $($lines.Count)" - # Pattern 1: Simple "Version X.Y.Z" (most reliable) - if ($output -match 'Version ([0-9]+\.[0-9]+\.[0-9]+)') { - $version = $Matches[1] - Write-Host "Found version using pattern 1: $version" - } - # Pattern 2: "Microsoft (R) C/C++ Optimizing Compiler Version X.Y.Z" - elseif ($output -match 'Microsoft \(R\) C/C\+\+ Optimizing Compiler Version ([0-9]+\.[0-9]+\.[0-9]+)') { - $version = $Matches[1] - Write-Host "Found version using pattern 2: $version" - } - # Pattern 3: "Compiler Version X.Y.Z" - elseif ($output -match 'Compiler Version ([0-9]+\.[0-9]+\.[0-9]+)') { - $version = $Matches[1] - Write-Host "Found version using pattern 3: $version" + foreach ($line in $lines) { + Write-Host "Processing line: '$line'" + + # Try different patterns on each line + if ($line -match 'Version ([0-9]+\.[0-9]+\.[0-9]+)') { + $version = $Matches[1] + Write-Host "Found version in line: $version" + break + } + elseif ($line -match '([0-9]+\.[0-9]+\.[0-9]+)') { + $version = $Matches[1] + Write-Host "Found generic version in line: $version" + break + } } - # Pattern 4: "X.Y.Z" (any version-like string) - elseif ($output -match '([0-9]+\.[0-9]+\.[0-9]+)') { - $version = $Matches[1] - Write-Host "Found version using pattern 4: $version" + + # If still no version, try the whole output as a single string + if (-not $version) { + Write-Host "Trying whole output as single string..." + if ($output -match 'Version ([0-9]+\.[0-9]+\.[0-9]+)') { + $version = $Matches[1] + Write-Host "Found version in whole output: $version" + } + elseif ($output -match '([0-9]+\.[0-9]+\.[0-9]+)') { + $version = $Matches[1] + Write-Host "Found generic version in whole output: $version" + } } Write-Host "Final version result: $version" From af4343386237a67d6643f24471267ec55793e1cb Mon Sep 17 00:00:00 2001 From: "Alan D. Tse" Date: Sat, 21 Jun 2025 20:16:00 -0700 Subject: [PATCH 6/6] ci: fix debug output --- .github/workflows/build.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index b3a272e3aa..64239d53cb 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -173,7 +173,6 @@ jobs: } Write-Host "Final version result: $version" - Write-Host "Matches array: $($Matches | ConvertTo-Json)" if ($version) { Write-Host "MSVC version: $version" @@ -343,7 +342,6 @@ jobs: } Write-Host "Final version result: $version" - Write-Host "Matches array: $($Matches | ConvertTo-Json)" if ($version) { Write-Host "MSVC version: $version"