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