ci: reduce needless file copying; zip GPOs; reliability (#42446)

This pull request makes four main changes to the build.

1. GPOs are now emitted as a ZIP file, rather than a folder to be zipped
later.
2. PDB files are linked into the output folder by hard link, rather than
copy, to save disk space.
3. We no longer copy the entire build output folder into artifacts;
instead, we *move* it, to save disk space.
4. **Failed builds** will no longer produce `build-arch-release`
artifacts; instead, they will produce numbered failure artifacts. This
means that we can finally re-run a single leg of the build, and it will
not fail due to the artifact already existing!

I included a smaller change to the DSC build step to make sure it
doesn't accidentally run when everything else failed. Heh.

Altogether, this takes a couple minutes off the build and reduces the
demand on the agent's disk by 10-15GB.
This commit is contained in:
Dustin L. Howett
2025-10-17 04:52:14 -05:00
committed by Gleb Khmyznikov
parent b2a2d85c74
commit a66c0151f2

View File

@@ -274,7 +274,7 @@ jobs:
# Build PowerToys.DSC.exe for ARM64 (x64 uses existing binary from previous build) # Build PowerToys.DSC.exe for ARM64 (x64 uses existing binary from previous build)
- task: VSBuild@1 - task: VSBuild@1
displayName: Build PowerToys.DSC.exe (x64 for generating manifests) displayName: Build PowerToys.DSC.exe (x64 for generating manifests)
condition: ne(variables['BuildPlatform'], 'x64') condition: and(succeeded(), ne(variables['BuildPlatform'], 'x64'))
inputs: inputs:
solution: src/dsc/v3/PowerToys.DSC/PowerToys.DSC.csproj solution: src/dsc/v3/PowerToys.DSC/PowerToys.DSC.csproj
msbuildArgs: /t:Build /m /restore msbuildArgs: /t:Build /m /restore
@@ -564,15 +564,16 @@ jobs:
flattenFolders: True flattenFolders: True
targetFolder: $(JobOutputDirectory) targetFolder: $(JobOutputDirectory)
- task: CopyFiles@2 - pwsh: |-
displayName: Stage Symbols $Symbols = Get-ChildItem "$(BuildPlatform)" -Recurse -Filter *.pdb -Exclude "vc143.pdb","*test*.pdb" |
inputs: Group-Object Name | ForEach-Object { $_.Group[0] }
contents: |- $OutDir = "$(JobOutputDirectory)/symbols-$(BuildPlatform)"
**\*.pdb New-Item -Type Directory $OutDir -EA:Ignore
!**\vc143.pdb Write-Host "Linking $($Symbols.Length) symbols into place at $OutDir"
!**\*test*.pdb ForEach($s in $Symbols) {
flattenFolders: True New-Item -Type HardLink -Target $s.FullName (Join-Path $OutDir $s.Name)
targetFolder: $(JobOutputDirectory)/symbols-$(BuildPlatform)/ }
displayName: Stage Unique Symbols (as hard links)
- pwsh: |- - pwsh: |-
$p = "$(JobOutputDirectory)\" $p = "$(JobOutputDirectory)\"
@@ -621,21 +622,30 @@ jobs:
# Publishing the GPO files # Publishing the GPO files
- pwsh: |- - pwsh: |-
New-Item "$(JobOutputDirectory)/gpo" -Type Directory $GpoArchive = "$(JobOutputDirectory)\GroupPolicyObjectFiles-${{ parameters.versionNumber }}.zip"
Copy-Item src\gpo\assets\* "$(JobOutputDirectory)/gpo" -Recurse tar -c -v --format=zip -C .\src\gpo\assets -f $GpoArchive *
displayName: Stage GPO files displayName: Stage GPO files
# Running the tests may result in future jobs consuming artifacts out of this build
- ${{ if or(eq(parameters.runTests, true), eq(parameters.buildTests, true)) }}: - ${{ if or(eq(parameters.runTests, true), eq(parameters.buildTests, true)) }}:
- task: CopyFiles@2 # Running the tests may result in future jobs consuming artifacts out of this build
displayName: Stage entire build output # Instead of running an expensive file copy step, move everything over since the build is totally done.
inputs: - pwsh: |-
sourceFolder: '$(Build.SourcesDirectory)' # It seems weird, but this is for compatibility. Our artifacts historically contained the folder x64/Release/x64/Release (for example).
contents: '$(BuildPlatform)/$(BuildConfiguration)/**/*' $FinalOutputRoot = "$(JobOutputDirectory)\$(BuildPlatform)\$(BuildConfiguration)\$(BuildPlatform)"
targetFolder: '$(JobOutputDirectory)\$(BuildPlatform)\$(BuildConfiguration)' $ProjectBuildRoot = "$(Build.SourcesDirectory)\$(BuildPlatform)"
$ProjectBuildDirectory = "$ProjectBuildRoot\$(BuildConfiguration)"
New-Item -Type Directory $FinalOutputRoot -EA:Ignore
Move-Item $ProjectBuildDirectory $FinalOutputRoot
displayName: Move entire output directory into artifacts
- ${{ if eq(parameters.publishArtifacts, true) }}: - ${{ if eq(parameters.publishArtifacts, true) }}:
- publish: $(JobOutputDirectory) - publish: $(JobOutputDirectory)
artifact: $(JobOutputArtifactName) artifact: $(JobOutputArtifactName)
displayName: Publish all outputs displayName: Publish all outputs
condition: always() condition: succeeded()
- publish: $(JobOutputDirectory)
artifact: $(JobOutputArtifactName)-failure-$(System.JobAttempt)
displayName: Publish failure logs
condition: or(failed(), canceled())