Skip to content

Commit f4d60c0

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 f4d60c0

File tree

2 files changed

+100
-8
lines changed

2 files changed

+100
-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: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,3 +209,80 @@ 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+
# Find the dd_insaller* file.
236+
$LogFile = ""
237+
Find-Item -Path "${{ github.workspace }}/windows-sdk-installer-log" -File -ErrorAction SilentlyContinue | ForEach-Object {
238+
if ($_.Name -like "dd_insaller*") {
239+
$LogFile = $_.FullName
240+
}
241+
}
242+
243+
if (-Not (Test-Path -Path $LogFile)) {
244+
Write-Output "::error::Log file not found."
245+
exit 1
246+
} else {
247+
Write-Output "✅ Log file found. File contents:"
248+
Get-Content -Path "$LogFile"
249+
}
250+
251+
test-incorrect-msvc-version:
252+
name: Incorrect MSVC Version
253+
runs-on: ${{ inputs.windows-runner || 'windows-latest' }}
254+
steps:
255+
- name: Checkout
256+
uses: actions/[email protected]
257+
258+
- name: Set up build with incorrect MSVC version
259+
id: setup-build
260+
uses: ./.github/actions/setup-build
261+
with:
262+
windows-sdk-version: ${{ env.TEST_WIN_SDK_VERSION }}
263+
msvc-version: "14.99" # Intentionally incorrect version
264+
continue-on-error: true
265+
266+
- name: Download log file
267+
uses: actions/download-artifact@v4
268+
with:
269+
name: msvc-installer-log-${{ github.job }}
270+
path: ${{ github.workspace }}/msvc-installer-log
271+
272+
- name: Check the log file existence
273+
run: |
274+
# Find the dd_insaller* file.
275+
$LogFile = ""
276+
Find-Item -Path "${{ github.workspace }}/msvc-installer-log" -File -ErrorAction SilentlyContinue | ForEach-Object {
277+
if ($_.Name -like "dd_insaller*") {
278+
$LogFile = $_.FullName
279+
}
280+
}
281+
282+
if (-Not (Test-Path -Path $LogFile)) {
283+
Write-Output "::error::Log file not found."
284+
exit 1
285+
} else {
286+
Write-Output "✅ Log file found. File contents:"
287+
Get-Content -Path "$LogFile"
288+
}

0 commit comments

Comments
 (0)