Skip to content

Commit 71d6fd7

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 44bfd45 commit 71d6fd7

File tree

2 files changed

+95
-8
lines changed

2 files changed

+95
-8
lines changed

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

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ name: Setup build
22
description: Sets up the build environment for the current job
33

44
inputs:
5+
upload-prefix:
6+
description: |
7+
The prefix to use for the uploaded artifacts. This is used to distinguish
8+
between different matrix jobs in the same workflow.
9+
required: true
10+
type: string
511
windows-sdk-version:
612
description: The Windows SDK version to use, e.g. "10.0.22621.0"
713
required: false
@@ -108,6 +114,7 @@ runs:
108114
109115
- name: Install Windows SDK version ${{ inputs.windows-sdk-version }}
110116
if: steps.sanitize-input.outputs.build-os == 'windows' && inputs.windows-sdk-version != ''
117+
id: setup-windows-sdk
111118
shell: pwsh
112119
run: |
113120
$WinSdkVersionString = "${{ inputs.windows-sdk-version }}"
@@ -140,13 +147,13 @@ runs:
140147
"--add", "Microsoft.VisualStudio.Component.Windows11SDK.${WinSdkVersionBuild}"
141148
$process.WaitForExit()
142149
150+
$LogFile = Get-ChildItem "${env:TEMP}" -Filter "dd_installer_*.log" | Sort-Object LastWriteTime -Descending | Select-Object -First 1
151+
"log-file=$($LogFile.FullName)" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
152+
143153
if (Test-Path -Path $Win10SdkIncludeVersion -PathType Container) {
144154
Write-Output "ℹ️ Windows SDK ${WinSdkVersionString} installed successfully."
145155
} 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
156+
Write-Output "::error::Failed to install Windows SDK ${WinSdkVersionString}. Check the installer log for details."
150157
exit 1
151158
}
152159
}
@@ -170,6 +177,13 @@ runs:
170177
}
171178
}
172179
180+
- name: Upload installer log
181+
if: always() && steps.setup-windows-sdk.outputs.log-file != ''
182+
uses: actions/upload-artifact@v4
183+
with:
184+
name: ${{ inputs.upload-prefix }}-windows-sdk-installer-log
185+
path: ${{ steps.setup-windows-sdk.outputs.log-file }}
186+
173187
- name: Install Windows MSVC version ${{ inputs.msvc-version }}
174188
if: steps.sanitize-input.outputs.build-os == 'windows' && inputs.msvc-version != ''
175189
id: setup-msvc
@@ -212,6 +226,9 @@ runs:
212226
"--add", "Microsoft.VisualStudio.Component.VC.${MSVCPackageVersion}.ATL.ARM64"
213227
$process.WaitForExit()
214228
229+
$LogFile = Get-ChildItem "${env:TEMP}" -Filter "dd_installer_*.log" | Sort-Object LastWriteTime -Descending | Select-Object -First 1
230+
"log-file=$($LogFile.FullName)" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
231+
215232
# Check if the MSVC version was installed successfully.
216233
$MSVCBuildToolsVersion = ""
217234
foreach ($dir in Get-ChildItem -Path $MSVCDir -Directory) {
@@ -224,16 +241,20 @@ runs:
224241
}
225242
226243
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
244+
Write-Output "::error::Failed to install MSVC ${MSVCVersionString}. Check the installer log for details."
231245
exit 1
232246
} else {
233247
Write-Output "ℹ️ MSVC ${MSVCBuildToolsVersion} installed successfully."
234248
"windows-build-tools-version=${MSVCBuildToolsVersion}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
235249
}
236250
251+
- name: Upload installer log
252+
if: always() && steps.setup-msvc.outputs.log-file != ''
253+
uses: actions/upload-artifact@v4
254+
with:
255+
name: ${{ inputs.upload-prefix }}-msvc-installer-log
256+
path: ${{ steps.setup-msvc.outputs.log-file }}
257+
237258
- name: Setup Visual Studio Developer Environment
238259
if: steps.sanitize-input.outputs.build-os == 'windows' && inputs.setup-vs-dev-env == 'true'
239260
uses: compnerd/gha-setup-vsdevenv@5eb3eae1490d4f7875d574c4973539f69109700d # main

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

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636
id: setup-build
3737
uses: ./.github/actions/setup-build
3838
with:
39+
upload-prefix: "test-build-windows-vs-dev-env"
3940
windows-sdk-version: ${{ env.TEST_WIN_SDK_VERSION }}
4041
msvc-version: ${{ env.TEST_MSVC_VERSION }}
4142
setup-vs-dev-env: true
@@ -141,6 +142,7 @@ jobs:
141142
id: setup-build
142143
uses: ./.github/actions/setup-build
143144
with:
145+
upload-prefix: "test-build-windows-no-vs-dev-env"
144146
windows-sdk-version: ${{ env.TEST_WIN_SDK_VERSION }}
145147
msvc-version: ${{ env.TEST_MSVC_VERSION }}
146148
setup-vs-dev-env: false
@@ -227,3 +229,67 @@ jobs:
227229
} else {
228230
Write-Output "🎉 All environment checks passed successfully."
229231
}
232+
233+
test-incorrect-windows-sdk-version:
234+
name: Incorrect Windows SDK Version
235+
runs-on: ${{ inputs.windows-runner || 'windows-latest' }}
236+
steps:
237+
- name: Checkout
238+
uses: actions/[email protected]
239+
240+
- name: Set up build with incorrect Windows SDK version
241+
id: setup-build
242+
uses: ./.github/actions/setup-build
243+
with:
244+
upload-prefix: "test-incorrect-windows-sdk-version"
245+
windows-sdk-version: "99.99.9999.0" # Intentionally incorrect version
246+
continue-on-error: true
247+
248+
- name: Download log file
249+
uses: actions/download-artifact@v4
250+
with:
251+
name: test-incorrect-windows-sdk-version-windows-sdk-installer-log
252+
path: ${{ github.workspace }}/windows-sdk-installer-log
253+
254+
- name: Check the log file existence
255+
run: |
256+
$LogFile = Get-ChildItem -Path "${{ github.workspace }}/windows-sdk-installer-log"
257+
if (-Not (Test-Path -Path $LogFile)) {
258+
Write-Output "::error::Log file not found."
259+
exit 1
260+
} else {
261+
Write-Output "✅ Log file found. File contents:"
262+
Get-Content -Path "$LogFile"
263+
}
264+
265+
test-incorrect-msvc-version:
266+
name: Incorrect MSVC Version
267+
runs-on: ${{ inputs.windows-runner || 'windows-latest' }}
268+
steps:
269+
- name: Checkout
270+
uses: actions/[email protected]
271+
272+
- name: Set up build with incorrect MSVC version
273+
id: setup-build
274+
uses: ./.github/actions/setup-build
275+
with:
276+
upload-prefix: "test-incorrect-msvc-version"
277+
msvc-version: "14.99" # Intentionally incorrect version
278+
continue-on-error: true
279+
280+
- name: Download log file
281+
uses: actions/download-artifact@v4
282+
with:
283+
name: test-incorrect-msvc-version-msvc-installer-log
284+
path: ${{ github.workspace }}/msvc-installer-log
285+
286+
- name: Check the log file existence
287+
run: |
288+
$LogFile = Get-ChildItem -Path "${{ github.workspace }}/msvc-installer-log"
289+
if (-Not (Test-Path -Path $LogFile)) {
290+
Write-Output "::error::Log file not found."
291+
exit 1
292+
} else {
293+
Write-Output "✅ Log file found. File contents:"
294+
Get-Content -Path "$LogFile"
295+
}

0 commit comments

Comments
 (0)