Skip to content

Commit a1cdad3

Browse files
committed
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.
1 parent 85e7154 commit a1cdad3

File tree

2 files changed

+85
-8
lines changed

2 files changed

+85
-8
lines changed

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

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ runs:
108108
109109
- name: Install Windows SDK version ${{ inputs.windows-sdk-version }}
110110
if: steps.sanitize-input.outputs.build-os == 'windows' && inputs.windows-sdk-version != ''
111+
id: setup-windows-sdk
111112
shell: pwsh
112113
run: |
113114
$WinSdkVersionString = "${{ inputs.windows-sdk-version }}"
@@ -140,13 +141,13 @@ runs:
140141
"--add", "Microsoft.VisualStudio.Component.Windows11SDK.${WinSdkVersionBuild}"
141142
$process.WaitForExit()
142143
144+
$LogFile = Get-ChildItem "${env:TEMP}" -Filter "dd_installer_*.log" | Sort-Object LastWriteTime -Descending | Select-Object -First 1
145+
"log-file=$($LogFile.FullName)" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
146+
143147
if (Test-Path -Path $Win10SdkIncludeVersion -PathType Container) {
144148
Write-Output "ℹ️ Windows SDK ${WinSdkVersionString} installed successfully."
145149
} else {
146-
Write-Output "::error::Failed to install Windows SDK ${WinSdkVersionString}."
147-
Write-Output "Installer log:"
148-
$log = Get-ChildItem "${env:TEMP}" -Filter "dd_installer_*.log" | Sort-Object LastWriteTime -Descending | Select-Object -First 1
149-
Get-Content $log.FullName
150+
Write-Output "::error::Failed to install Windows SDK ${WinSdkVersionString}. Check the installer log for details."
150151
exit 1
151152
}
152153
}
@@ -170,6 +171,13 @@ runs:
170171
}
171172
}
172173
174+
- name: Upload installer log
175+
if: always() && steps.setup-windows-sdk.outputs.log-file != ''
176+
uses: actions/upload-artifact@v4
177+
with:
178+
name: windows-sdk-installer-log-${{ github.job }}
179+
path: ${{ steps.setup-windows-sdk.outputs.log-file }}
180+
173181
- name: Install Windows MSVC version ${{ inputs.msvc-version }}
174182
if: steps.sanitize-input.outputs.build-os == 'windows' && inputs.msvc-version != ''
175183
id: setup-msvc
@@ -212,6 +220,9 @@ runs:
212220
"--add", "Microsoft.VisualStudio.Component.VC.${MSVCPackageVersion}.ATL.ARM64"
213221
$process.WaitForExit()
214222
223+
$LogFile = Get-ChildItem "${env:TEMP}" -Filter "dd_installer_*.log" | Sort-Object LastWriteTime -Descending | Select-Object -First 1
224+
"log-file=$($LogFile.FullName)" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
225+
215226
# Check if the MSVC version was installed successfully.
216227
$MSVCBuildToolsVersion = ""
217228
foreach ($dir in Get-ChildItem -Path $MSVCDir -Directory) {
@@ -224,16 +235,20 @@ runs:
224235
}
225236
226237
if ($MSVCBuildToolsVersion -eq "") {
227-
Write-Output "::error::Failed to install MSVC ${MSVCVersionString}."
228-
Write-Output "Installer log:"
229-
$log = Get-ChildItem "${env:TEMP}" -Filter "dd_installer_*.log" | Sort-Object LastWriteTime -Descending | Select-Object -First 1
230-
Get-Content $log.FullName
238+
Write-Output "::error::Failed to install MSVC ${MSVCVersionString}. Check the installer log for details."
231239
exit 1
232240
} else {
233241
Write-Output "ℹ️ MSVC ${MSVCBuildToolsVersion} installed successfully."
234242
"windows-build-tools-version=${MSVCBuildToolsVersion}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
235243
}
236244
245+
- name: Upload installer log
246+
if: always() && steps.setup-msvc.outputs.log-file != ''
247+
uses: actions/upload-artifact@v4
248+
with:
249+
name: msvc-installer-log-${{ github.job }}
250+
path: ${{ steps.setup-msvc.outputs.log-file }}
251+
237252
- name: Setup Visual Studio Developer Environment
238253
if: steps.sanitize-input.outputs.build-os == 'windows' && inputs.setup-vs-dev-env == 'true'
239254
uses: compnerd/gha-setup-vsdevenv@5eb3eae1490d4f7875d574c4973539f69109700d # main

.github/workflows/test-setup-build.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,3 +209,65 @@ jobs:
209209
} else {
210210
Write-Output "🎉 All environment checks passed successfully."
211211
}
212+
213+
test-incorrect-windows-sdk-version:
214+
name: Incorrect Windows SDK Version
215+
runs-on: ${{ inputs.windows-runner || 'windows-latest' }}
216+
steps:
217+
- name: Checkout
218+
uses: actions/[email protected]
219+
220+
- name: Set up build with incorrect Windows SDK version
221+
id: setup-build
222+
uses: ./.github/actions/setup-build
223+
with:
224+
windows-sdk-version: "99.99.9999.0" # Intentionally incorrect version
225+
continue-on-error: true
226+
227+
- name: Download log file
228+
uses: actions/download-artifact@v4
229+
with:
230+
name: windows-sdk-installer-log-${{ github.job }}
231+
path: ${{ github.workspace }}/windows-sdk-installer-log
232+
233+
- name: Check the log file existence
234+
run: |
235+
$LogFile = Get-ChildItem -Path "${{ github.workspace }}/windows-sdk-installer-log"
236+
if (-Not (Test-Path -Path $LogFile)) {
237+
Write-Output "::error::Log file not found."
238+
exit 1
239+
} else {
240+
Write-Output "✅ Log file found. File contents:"
241+
Get-Content -Path "$LogFile"
242+
}
243+
244+
test-incorrect-msvc-version:
245+
name: Incorrect MSVC Version
246+
runs-on: ${{ inputs.windows-runner || 'windows-latest' }}
247+
steps:
248+
- name: Checkout
249+
uses: actions/[email protected]
250+
251+
- name: Set up build with incorrect MSVC version
252+
id: setup-build
253+
uses: ./.github/actions/setup-build
254+
with:
255+
msvc-version: "14.99" # Intentionally incorrect version
256+
continue-on-error: true
257+
258+
- name: Download log file
259+
uses: actions/download-artifact@v4
260+
with:
261+
name: msvc-installer-log-${{ github.job }}
262+
path: ${{ github.workspace }}/msvc-installer-log
263+
264+
- name: Check the log file existence
265+
run: |
266+
$LogFile = Get-ChildItem -Path "${{ github.workspace }}/msvc-installer-log"
267+
if (-Not (Test-Path -Path $LogFile)) {
268+
Write-Output "::error::Log file not found."
269+
exit 1
270+
} else {
271+
Write-Output "✅ Log file found. File contents:"
272+
Get-Content -Path "$LogFile"
273+
}

0 commit comments

Comments
 (0)