From 8f9361ee0d26eb82b6fb6e10716f853536cb7308 Mon Sep 17 00:00:00 2001 From: Fabrice de Gans Date: Thu, 29 May 2025 10:04:12 -0700 Subject: [PATCH 1/2] Upload the VS Installer log Rather than dumping the log to the bot output, the log file is now uploaded as an artifact named after the job name. --- .github/actions/setup-build/action.yml | 37 +++++++++++---- .github/workflows/test-setup-build.yml | 66 ++++++++++++++++++++++++++ 2 files changed, 95 insertions(+), 8 deletions(-) diff --git a/.github/actions/setup-build/action.yml b/.github/actions/setup-build/action.yml index 49cc4c05..24ac9d28 100644 --- a/.github/actions/setup-build/action.yml +++ b/.github/actions/setup-build/action.yml @@ -2,6 +2,12 @@ name: Setup build description: Sets up the build environment for the current job inputs: + upload-prefix: + description: | + The prefix to use for the uploaded artifacts. This is used to distinguish + between different matrix jobs in the same workflow. + required: true + type: string windows-sdk-version: description: The Windows SDK version to use, e.g. "10.0.22621.0" required: false @@ -108,6 +114,7 @@ runs: - name: Install Windows SDK version ${{ inputs.windows-sdk-version }} if: steps.sanitize-input.outputs.build-os == 'windows' && inputs.windows-sdk-version != '' + id: setup-windows-sdk shell: pwsh run: | $WinSdkVersionString = "${{ inputs.windows-sdk-version }}" @@ -140,13 +147,13 @@ runs: "--add", "Microsoft.VisualStudio.Component.Windows11SDK.${WinSdkVersionBuild}" $process.WaitForExit() + $LogFile = Get-ChildItem "${env:TEMP}" -Filter "dd_installer_*.log" | Sort-Object LastWriteTime -Descending | Select-Object -First 1 + "log-file=$($LogFile.FullName)" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append + if (Test-Path -Path $Win10SdkIncludeVersion -PathType Container) { Write-Output "ℹ️ Windows SDK ${WinSdkVersionString} installed successfully." } else { - Write-Output "::error::Failed to install Windows SDK ${WinSdkVersionString}." - Write-Output "Installer log:" - $log = Get-ChildItem "${env:TEMP}" -Filter "dd_installer_*.log" | Sort-Object LastWriteTime -Descending | Select-Object -First 1 - Get-Content $log.FullName + Write-Output "::error::Failed to install Windows SDK ${WinSdkVersionString}. Check the installer log for details." exit 1 } } @@ -170,6 +177,13 @@ runs: } } + - name: Upload installer log + if: always() && steps.setup-windows-sdk.outputs.log-file != '' + uses: actions/upload-artifact@v4 + with: + name: ${{ inputs.upload-prefix }}-windows-sdk-installer-log + path: ${{ steps.setup-windows-sdk.outputs.log-file }} + - name: Install Windows MSVC version ${{ inputs.msvc-version }} if: steps.sanitize-input.outputs.build-os == 'windows' && inputs.msvc-version != '' id: setup-msvc @@ -212,6 +226,9 @@ runs: "--add", "Microsoft.VisualStudio.Component.VC.${MSVCPackageVersion}.ATL.ARM64" $process.WaitForExit() + $LogFile = Get-ChildItem "${env:TEMP}" -Filter "dd_installer_*.log" | Sort-Object LastWriteTime -Descending | Select-Object -First 1 + "log-file=$($LogFile.FullName)" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append + # Check if the MSVC version was installed successfully. $MSVCBuildToolsVersion = "" foreach ($dir in Get-ChildItem -Path $MSVCDir -Directory) { @@ -224,16 +241,20 @@ runs: } if ($MSVCBuildToolsVersion -eq "") { - Write-Output "::error::Failed to install MSVC ${MSVCVersionString}." - Write-Output "Installer log:" - $log = Get-ChildItem "${env:TEMP}" -Filter "dd_installer_*.log" | Sort-Object LastWriteTime -Descending | Select-Object -First 1 - Get-Content $log.FullName + Write-Output "::error::Failed to install MSVC ${MSVCVersionString}. Check the installer log for details." exit 1 } else { Write-Output "ℹ️ MSVC ${MSVCBuildToolsVersion} installed successfully." "windows-build-tools-version=${MSVCBuildToolsVersion}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append } + - name: Upload installer log + if: always() && steps.setup-msvc.outputs.log-file != '' + uses: actions/upload-artifact@v4 + with: + name: ${{ inputs.upload-prefix }}-msvc-installer-log + path: ${{ steps.setup-msvc.outputs.log-file }} + - name: Setup Visual Studio Developer Environment if: steps.sanitize-input.outputs.build-os == 'windows' && inputs.setup-vs-dev-env == 'true' uses: compnerd/gha-setup-vsdevenv@5eb3eae1490d4f7875d574c4973539f69109700d # main diff --git a/.github/workflows/test-setup-build.yml b/.github/workflows/test-setup-build.yml index d100592a..4877d02f 100644 --- a/.github/workflows/test-setup-build.yml +++ b/.github/workflows/test-setup-build.yml @@ -36,6 +36,7 @@ jobs: id: setup-build uses: ./.github/actions/setup-build with: + upload-prefix: "test-build-windows-vs-dev-env" windows-sdk-version: ${{ env.TEST_WIN_SDK_VERSION }} msvc-version: ${{ env.TEST_MSVC_VERSION }} setup-vs-dev-env: true @@ -141,6 +142,7 @@ jobs: id: setup-build uses: ./.github/actions/setup-build with: + upload-prefix: "test-build-windows-no-vs-dev-env" windows-sdk-version: ${{ env.TEST_WIN_SDK_VERSION }} msvc-version: ${{ env.TEST_MSVC_VERSION }} setup-vs-dev-env: false @@ -227,3 +229,67 @@ jobs: } else { Write-Output "🎉 All environment checks passed successfully." } + + test-incorrect-windows-sdk-version: + name: Incorrect Windows SDK Version + runs-on: ${{ inputs.windows-runner || 'windows-latest' }} + steps: + - name: Checkout + uses: actions/checkout@v4.2.2 + + - name: Set up build with incorrect Windows SDK version + id: setup-build + uses: ./.github/actions/setup-build + with: + upload-prefix: "test-incorrect-windows-sdk-version" + windows-sdk-version: "99.99.9999.0" # Intentionally incorrect version + continue-on-error: true + + - name: Download log file + uses: actions/download-artifact@v4 + with: + name: test-incorrect-windows-sdk-version-windows-sdk-installer-log + path: ${{ github.workspace }}/windows-sdk-installer-log + + - name: Check the log file existence + run: | + $LogFile = Get-ChildItem -Path "${{ github.workspace }}/windows-sdk-installer-log" + if (-Not (Test-Path -Path $LogFile)) { + Write-Output "::error::Log file not found." + exit 1 + } else { + Write-Output "✅ Log file found. File contents:" + Get-Content -Path "$LogFile" + } + + test-incorrect-msvc-version: + name: Incorrect MSVC Version + runs-on: ${{ inputs.windows-runner || 'windows-latest' }} + steps: + - name: Checkout + uses: actions/checkout@v4.2.2 + + - name: Set up build with incorrect MSVC version + id: setup-build + uses: ./.github/actions/setup-build + with: + upload-prefix: "test-incorrect-msvc-version" + msvc-version: "14.99" # Intentionally incorrect version + continue-on-error: true + + - name: Download log file + uses: actions/download-artifact@v4 + with: + name: test-incorrect-msvc-version-msvc-installer-log + path: ${{ github.workspace }}/msvc-installer-log + + - name: Check the log file existence + run: | + $LogFile = Get-ChildItem -Path "${{ github.workspace }}/msvc-installer-log" + if (-Not (Test-Path -Path $LogFile)) { + Write-Output "::error::Log file not found." + exit 1 + } else { + Write-Output "✅ Log file found. File contents:" + Get-Content -Path "$LogFile" + } From cc504839d01c93dda12d24a1e8c085e7561f1eda Mon Sep 17 00:00:00 2001 From: Fabrice de Gans Date: Fri, 30 May 2025 10:52:26 -0700 Subject: [PATCH 2/2] Only upload the log on failure --- .github/actions/setup-build/action.yml | 20 ++++++-------------- .github/workflows/test-setup-build.yml | 8 ++------ 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/.github/actions/setup-build/action.yml b/.github/actions/setup-build/action.yml index 24ac9d28..b632d94d 100644 --- a/.github/actions/setup-build/action.yml +++ b/.github/actions/setup-build/action.yml @@ -2,12 +2,6 @@ name: Setup build description: Sets up the build environment for the current job inputs: - upload-prefix: - description: | - The prefix to use for the uploaded artifacts. This is used to distinguish - between different matrix jobs in the same workflow. - required: true - type: string windows-sdk-version: description: The Windows SDK version to use, e.g. "10.0.22621.0" required: false @@ -147,13 +141,12 @@ runs: "--add", "Microsoft.VisualStudio.Component.Windows11SDK.${WinSdkVersionBuild}" $process.WaitForExit() - $LogFile = Get-ChildItem "${env:TEMP}" -Filter "dd_installer_*.log" | Sort-Object LastWriteTime -Descending | Select-Object -First 1 - "log-file=$($LogFile.FullName)" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append - if (Test-Path -Path $Win10SdkIncludeVersion -PathType Container) { Write-Output "ℹ️ Windows SDK ${WinSdkVersionString} installed successfully." } else { Write-Output "::error::Failed to install Windows SDK ${WinSdkVersionString}. Check the installer log for details." + $LogFile = Get-ChildItem "${env:TEMP}" -Filter "dd_installer_*.log" | Sort-Object LastWriteTime -Descending | Select-Object -First 1 + "log-file=$($LogFile.FullName)" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append exit 1 } } @@ -181,7 +174,7 @@ runs: if: always() && steps.setup-windows-sdk.outputs.log-file != '' uses: actions/upload-artifact@v4 with: - name: ${{ inputs.upload-prefix }}-windows-sdk-installer-log + name: ${{ github.job }}-windows-sdk-installer-log path: ${{ steps.setup-windows-sdk.outputs.log-file }} - name: Install Windows MSVC version ${{ inputs.msvc-version }} @@ -226,9 +219,6 @@ runs: "--add", "Microsoft.VisualStudio.Component.VC.${MSVCPackageVersion}.ATL.ARM64" $process.WaitForExit() - $LogFile = Get-ChildItem "${env:TEMP}" -Filter "dd_installer_*.log" | Sort-Object LastWriteTime -Descending | Select-Object -First 1 - "log-file=$($LogFile.FullName)" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append - # Check if the MSVC version was installed successfully. $MSVCBuildToolsVersion = "" foreach ($dir in Get-ChildItem -Path $MSVCDir -Directory) { @@ -242,6 +232,8 @@ runs: if ($MSVCBuildToolsVersion -eq "") { Write-Output "::error::Failed to install MSVC ${MSVCVersionString}. Check the installer log for details." + $LogFile = Get-ChildItem "${env:TEMP}" -Filter "dd_installer_*.log" | Sort-Object LastWriteTime -Descending | Select-Object -First 1 + "log-file=$($LogFile.FullName)" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append exit 1 } else { Write-Output "ℹ️ MSVC ${MSVCBuildToolsVersion} installed successfully." @@ -252,7 +244,7 @@ runs: if: always() && steps.setup-msvc.outputs.log-file != '' uses: actions/upload-artifact@v4 with: - name: ${{ inputs.upload-prefix }}-msvc-installer-log + name: ${{ github.job }}-msvc-installer-log path: ${{ steps.setup-msvc.outputs.log-file }} - name: Setup Visual Studio Developer Environment diff --git a/.github/workflows/test-setup-build.yml b/.github/workflows/test-setup-build.yml index 4877d02f..8699b30e 100644 --- a/.github/workflows/test-setup-build.yml +++ b/.github/workflows/test-setup-build.yml @@ -36,7 +36,6 @@ jobs: id: setup-build uses: ./.github/actions/setup-build with: - upload-prefix: "test-build-windows-vs-dev-env" windows-sdk-version: ${{ env.TEST_WIN_SDK_VERSION }} msvc-version: ${{ env.TEST_MSVC_VERSION }} setup-vs-dev-env: true @@ -142,7 +141,6 @@ jobs: id: setup-build uses: ./.github/actions/setup-build with: - upload-prefix: "test-build-windows-no-vs-dev-env" windows-sdk-version: ${{ env.TEST_WIN_SDK_VERSION }} msvc-version: ${{ env.TEST_MSVC_VERSION }} setup-vs-dev-env: false @@ -241,14 +239,13 @@ jobs: id: setup-build uses: ./.github/actions/setup-build with: - upload-prefix: "test-incorrect-windows-sdk-version" windows-sdk-version: "99.99.9999.0" # Intentionally incorrect version continue-on-error: true - name: Download log file uses: actions/download-artifact@v4 with: - name: test-incorrect-windows-sdk-version-windows-sdk-installer-log + name: ${{ github.job }}-windows-sdk-installer-log path: ${{ github.workspace }}/windows-sdk-installer-log - name: Check the log file existence @@ -273,14 +270,13 @@ jobs: id: setup-build uses: ./.github/actions/setup-build with: - upload-prefix: "test-incorrect-msvc-version" msvc-version: "14.99" # Intentionally incorrect version continue-on-error: true - name: Download log file uses: actions/download-artifact@v4 with: - name: test-incorrect-msvc-version-msvc-installer-log + name: ${{ github.job }}-msvc-installer-log path: ${{ github.workspace }}/msvc-installer-log - name: Check the log file existence