Skip to content

Commit

Permalink
Upload logs on cmake generate/build failure (#5293)
Browse files Browse the repository at this point in the history
* Upload logs on cmake generate/build failure

* Copy relevant files to staging location, clean up after publishing

* Update cspell words

* Test: break cmake generate in a way that'll produce SOME log files.

* Revert "Test: break cmake generate in a way that'll produce SOME log files."

This reverts commit d5a3005.

* Show failure logs instead of uploading artifacts. Only show log files for vcpkg at this time

* Reapply "Test: break cmake generate in a way that'll produce SOME log files."

This reverts commit 582629a.

* Revert "Reapply "Test: break cmake generate in a way that'll produce SOME log files.""

This reverts commit 7a35250.

* Another type of test

* Revert inadvertent whitespace changes

* Revert "Another type of test"

This reverts commit e38013f.

* More logging
  • Loading branch information
danieljurek authored Feb 7, 2024
1 parent 5a70fca commit ce4f25d
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@
"rtti",
"rwxrw",
"sasia",
"sbom",
"Schonberger",
"scus",
"SDDL",
Expand Down Expand Up @@ -251,6 +252,7 @@
"Wunused",
"xbox",
"Xclang",
"xcode",
"XSMB",
"zulu"
],
Expand Down
2 changes: 2 additions & 0 deletions eng/pipelines/templates/jobs/ci.tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ jobs:
VcpkgArgs: "$(VcpkgArgs)"
Env: "$(CmakeEnvArg)"

- template: /eng/pipelines/templates/steps/show-failure-logs.yml

- template: /eng/common/testproxy/test-proxy-tool.yml
parameters:
runProxy: true
Expand Down
2 changes: 2 additions & 0 deletions eng/pipelines/templates/jobs/cmake-generate.tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,5 @@ jobs:
GenerateArgs: ${{ cmakeOption.Value }}
Env: "$(CmakeEnvArg)"
PackageName: ${{ artifact.Name }}

- template: /eng/pipelines/templates/steps/show-failure-logs.yml
2 changes: 2 additions & 0 deletions eng/pipelines/templates/jobs/live.tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ jobs:
BuildArgs: "$(BuildArgs)"
Env: "$(CmakeEnvArg)"

- template: /eng/pipelines/templates/steps/show-failure-logs.yml

- template: /eng/common/TestResources/build-test-resource-config.yml
parameters:
SubscriptionConfiguration: ${{ parameters.CloudConfig.SubscriptionConfiguration }}
Expand Down
2 changes: 2 additions & 0 deletions eng/pipelines/templates/steps/cmake-generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ steps:
env:
VCPKG_BINARY_SOURCES: $(VCPKG_BINARY_SOURCES_SECRET)
# The calling job will attempt to upload logs on failure. To that end this
# step should ONLY run on success.
- script: rm -rf build
workingDirectory: ${{ parameters.CmakeGeneratePath }}
displayName: clean build folder for ${{ parameters.PackageName }}
6 changes: 6 additions & 0 deletions eng/pipelines/templates/steps/show-failure-logs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
steps:
- task: PowerShell@2
condition: failed()
displayName: Show build failure logs
inputs:
filePath: eng/scripts/Show-FailureLogs.ps1
25 changes: 25 additions & 0 deletions eng/scripts/Show-FailureLogs.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Only show contents of particular vcpkg log files whose potentially sensitive
# information will be redacted by DevOps (if it's included).

# Before adding other expressions to output ensure that those logs will not
# contain sensitive information or that DevOps is properly configured to remove
# sensitive information.

$logFiles = Get-ChildItem -Recurse -Filter *.log
$filteredLogs = $logFiles.Where({ $_.Name -in ('vcpkg-bootstrap.log', 'vcpkg-manifest-install.log') })

if (!$filteredLogs) {
Write-Host "No logs found"
exit 0
}

foreach ($logFile in $filteredLogs)
{
Write-Host "//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////"
Write-Host "=============================================================================================================================="
Write-Host "Log file: $logFile"
Write-Host "=============================================================================================================================="
Get-Content $logFile | Write-Host
}

exit 0

0 comments on commit ce4f25d

Please sign in to comment.