Skip to content

Commit e6b3d16

Browse files
jviauliliankasem
andauthored
Refactor CI artifacts for release improvements (#10704)
* Consolidate artifacts * Disable sdl spotBugs * Remove PrivateSiteExtension * stage release_notes.md as artifact * Add script to generate private site extension * Copy release_notes.md in site extension * Flatten SiteExtension artifacts, custom hash task * Generate release.json during build * modifyOutputPath: false * Use SHA256 for the hash * Default private siteext to 64bit * Default private siteext to zipping * Remove binlog artifact to save space * Update SiteExtension readme * Update src/WebJobs.Script.SiteExtension/New-PrivateSiteExtension.ps1 Co-authored-by: Lilian Kasem <[email protected]> --------- Co-authored-by: Lilian Kasem <[email protected]>
1 parent ef63b6b commit e6b3d16

File tree

10 files changed

+299
-89
lines changed

10 files changed

+299
-89
lines changed

eng/ci/official-build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ extends:
7070
codeql:
7171
# Move codeql for source languages to source analysis stage
7272
runSourceLanguagesInSourceAnalysis: true
73+
spotBugs:
74+
enabled: false # Explicitly disabling as our JavaWorker package causes this to light up and subsequently fail.
7375

7476
stages:
7577
- stage: Build

eng/ci/templates/official/jobs/build-artifacts-linux.yml

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,19 @@ jobs:
66
project: src/WebJobs.Script.WebHost/WebJobs.Script.WebHost.csproj
77
configuration: release
88
runtime: linux-x64
9-
artifacts_path: $(Build.ArtifactStagingDirectory)
10-
log_dir: $(artifacts_path)/log
11-
zip_artifacts_path: $(artifacts_path)/Linux
9+
drop_path: $(Build.ArtifactStagingDirectory)
10+
linux_drop_path: $(drop_path)/linux
1211
build_args: '-v m -c $(configuration) -r $(runtime) --self-contained true'
1312

1413
templateContext:
15-
outputParentDirectory: $(artifacts_path)
14+
outputParentDirectory: $(drop_path)
1615
outputs:
1716
# TODO: onboard to Azure Artifacts Drops to allow accessing this from docker linux pipeline in msazure
1817
# https://eng.ms/docs/cloud-ai-platform/devdiv/one-engineering-system-1es/1es-docs/azure-artifacts/artifact-services-onboarding
1918
- output: pipelineArtifact
2019
displayName: Publish linux artifacts
21-
path: $(zip_artifacts_path)
22-
artifact: Linux
23-
- output: pipelineArtifact
24-
displayName: Publish logs
25-
path: $(log_dir)
26-
artifact: Linux_Log
27-
sbomEnabled: false
28-
condition: always()
20+
path: $(linux_drop_path)
21+
artifact: drop_linux
2922

3023
pool:
3124
name: 1es-pool-azfunc
@@ -41,15 +34,15 @@ jobs:
4134
command: custom
4235
custom: restore
4336
projects: $(project)
44-
arguments: '-v m -r $(runtime) -p:PublishReadyToRun=true -bl:$(log_dir)/restore.binlog' # add PublishReadyToRun=true for https://github.com/dotnet/sdk/issues/20701
37+
arguments: '-v m -r $(runtime) -p:PublishReadyToRun=true' # add PublishReadyToRun=true for https://github.com/dotnet/sdk/issues/20701
4538

4639
- task: DotNetCoreCLI@2
4740
displayName: Build
4841
inputs:
4942
command: custom
5043
custom: build
5144
projects: $(project)
52-
arguments: '$(build_args) --no-restore -bl:$(log_dir)/build.binlog'
45+
arguments: '$(build_args) --no-restore'
5346

5447
- task: DotNetCoreCLI@2
5548
displayName: Publish
@@ -58,5 +51,6 @@ jobs:
5851
custom: publish
5952
publishWebProjects: false # we use our own publish logic
6053
zipAfterPublish: false # we use our own zip logic
54+
modifyOutputPath: false
6155
projects: $(project)
62-
arguments: '$(build_args) --no-build -p:ZipArtifactsPath=$(zip_artifacts_path) -bl:$(log_dir)/publish.binlog'
56+
arguments: '$(build_args) --no-build -o $(linux_drop_path)/host'

eng/ci/templates/official/jobs/build-artifacts-windows.yml

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,45 +8,34 @@ jobs:
88
os: windows
99

1010
variables:
11-
nuget_package_path: $(Build.ArtifactStagingDirectory)/NugetPackages
12-
log_dir: $(Build.ArtifactStagingDirectory)/log
11+
drop_path: $(Build.ArtifactStagingDirectory)
12+
nuget_drop_path: $(drop_path)/nuget
13+
windows_drop_path: $(drop_path)/windows
1314

1415
templateContext:
15-
outputParentDirectory: $(Build.ArtifactStagingDirectory)
16+
outputParentDirectory: $(drop_path)
1617
outputs:
1718
- output: pipelineArtifact
1819
displayName: Publish site extension
19-
path: $(Build.ArtifactStagingDirectory)/SiteExtension
20-
artifact: SiteExtension
21-
- output: pipelineArtifact
22-
displayName: Publish private site extension
23-
path: $(Build.ArtifactStagingDirectory)/PrivateSiteExtension
24-
artifact: PrivateSiteExtension
25-
- output: pipelineArtifact
26-
displayName: Publish site extension symbols
27-
path: $(Build.ArtifactStagingDirectory)/SiteExtensionSymbols
28-
artifact: Symbols
20+
path: $(windows_drop_path)
21+
artifact: drop_windows
2922
- output: pipelineArtifact
3023
displayName: Publish nuget packages
31-
path: $(Build.ArtifactStagingDirectory)/NugetPackages
32-
artifact: NugetPackages
33-
- output: pipelineArtifact
34-
displayName: Publish logs
35-
path: $(log_dir)
36-
artifact: Windows_Log
37-
sbomEnabled: false
38-
condition: always()
24+
path: $(nuget_drop_path)
25+
artifact: drop_nuget
3926

4027
steps:
4128
- template: /eng/ci/templates/install-dotnet.yml@self
4229
- template: /eng/ci/templates/steps/build-site-ext.yml@self
30+
parameters:
31+
publishDir: $(windows_drop_path)
4332

4433
- task: DotNetCoreCLI@2
4534
displayName: Build host packages
4635
inputs:
4736
command: custom
4837
custom: pack
49-
arguments: -c release -o $(nuget_package_path)
38+
arguments: -c release -o $(nuget_drop_path)
5039
projects: |
5140
**/WebJobs.Script.csproj
5241
**/WebJobs.Script.WebHost.csproj
@@ -74,7 +63,7 @@ jobs:
7463
inputs:
7564
command: custom
7665
custom: pack
77-
arguments: '--no-build -c release -o $(nuget_package_path)'
66+
arguments: '--no-build -c release -o $(nuget_drop_path)'
7867
projects: |
7968
**/WebJobs.Script.Abstractions.csproj
8069
@@ -91,7 +80,7 @@ jobs:
9180
inputs:
9281
command: custom
9382
custom: pack
94-
arguments: '--no-build -c release -o $(nuget_package_path)'
83+
arguments: '--no-build -c release -o $(nuget_drop_path)'
9584
projects: |
9685
**/ExtensionsMetadataGenerator.csproj
9786

eng/ci/templates/steps/build-site-ext.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ parameters:
22
- name: project
33
type: string
44
default: src/WebJobs.Script.SiteExtension/WebJobs.Script.SiteExtension.csproj
5+
- name: publishDir
6+
type: string
7+
default: ''
58

69
steps:
710
# Restore must be a separate step so we can pass in 'PublishReadyToRun=true'
@@ -11,15 +14,15 @@ steps:
1114
command: custom
1215
custom: restore
1316
projects: ${{ parameters.project }}
14-
arguments: '-v m -p:PublishReadyToRun=true -bl:$(log_dir)/site_ext.restore.binlog'
17+
arguments: '-v m -p:PublishReadyToRun=true'
1518

1619
- task: DotNetCoreCLI@2
1720
displayName: Build site extension
1821
inputs:
1922
command: custom
2023
custom: build
2124
projects: ${{ parameters.project }}
22-
arguments: '--no-restore -v m -c release -bl:$(log_dir)/site_ext.build.binlog'
25+
arguments: '--no-restore -v m -c release'
2326

2427
- task: DotNetCoreCLI@2
2528
displayName: Publish site extension
@@ -28,5 +31,9 @@ steps:
2831
custom: publish
2932
publishWebProjects: false # we use our own publish logic
3033
zipAfterPublish: false # we use our own zip logic
34+
modifyOutputPath: false
3135
projects: ${{ parameters.project }}
32-
arguments: '--no-build -v m -c release -p:ZipArtifactsPath=$(Build.ArtifactStagingDirectory) -bl:$(log_dir)/site_ext.publish.binlog'
36+
${{ if eq(parameters.publishDir, '') }}:
37+
arguments: '--no-build -v m -c release'
38+
${{ else }}:
39+
arguments: '--no-build -v m -c release -o ${{ parameters.publishDir }}'
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
<#
2+
.SYNOPSIS
3+
Produces a private site extension.
4+
5+
.DESCRIPTION
6+
Takes in a published site extension and produces a private site extension.
7+
8+
.PARAMETER InputPath
9+
The path of the published 'SiteExtension'. Leave null to scan for root in a child from here.
10+
11+
.PARAMETER OutputPath
12+
The path to produce the private site extension to (either the zip file or folder). Leave null to compute this name.
13+
14+
.PARAMETER Bitness
15+
The bitness to produce the private site extension with. Default is '64bit'.
16+
17+
.PARAMETER NoZip
18+
[Switch] Include to produce site extension as a folder and not a zip.
19+
20+
.PARAMETER Force
21+
[Switch] Include to overwrite existing files.
22+
23+
.INPUTS
24+
None. You can't pipe objects to Update-Month.ps1.
25+
26+
.OUTPUTS
27+
None. Update-Month.ps1 doesn't generate any output.
28+
#>
29+
30+
param (
31+
[string] $InputPath = $null,
32+
[string] $OutputPath = $null,
33+
[ValidateSet('x64', '64bit', 'x86', '32bit')][string] $Bitness = '64bit',
34+
[switch] $NoZip,
35+
[switch] $Force
36+
)
37+
38+
$normalizeBitness = @{
39+
'x64' = '64bit'
40+
'64bit' = '64bit'
41+
'x86' = '64bit'
42+
'32bit' = '32bit'
43+
}
44+
45+
$Bitness = $normalizeBitness[$Bitness]
46+
47+
if (-not $InputPath)
48+
{
49+
$InputPath = (Get-ChildItem -Path . -Filter "extension.xml" -Recurse).Directory.FullName
50+
}
51+
52+
if (Test-Path (Join-Path $InputPath "WebJobs.Script.SiteExtension.csproj"))
53+
{
54+
Write-Error "This script should not be ran in the WebJobs.Script.SiteExtension project folder. Run this script in the root of the published site extension folder."
55+
exit 1
56+
}
57+
58+
if (-not (Join-Path $InputPath "extension.xml" | Test-Path))
59+
{
60+
Write-Error "Unable to find published site extension."
61+
exit 1
62+
}
63+
64+
if (-not $OutputPath)
65+
{
66+
$runtime = $Bitness -eq '32bit' ? 'win-x86' : 'win-x64'
67+
$leaf = (Split-Path $InputPath -Leaf)
68+
$split = $leaf.IndexOf('.')
69+
$OutputPath = "$($leaf.Substring(0, $split)).Private.$($leaf.Substring($split + 1)).$runtime"
70+
}
71+
72+
function New-TemporaryDirectory {
73+
$tmp = [System.IO.Path]::GetTempPath()
74+
$name = (New-Guid).ToString("N")
75+
return New-Item -ItemType Directory -Path (Join-Path $tmp $name)
76+
}
77+
78+
function Write-Zip ($outputPath)
79+
{
80+
if (Test-Path $outputPath) {
81+
if ($Force) {
82+
Remove-Item -Path $outputPath -Recurse -Force
83+
} else {
84+
Write-Error "OutputPath already exists. Use -Force to overwrite."
85+
exit 1
86+
}
87+
}
88+
89+
$tempDir = New-TemporaryDirectory
90+
Write-Folder $tempDir
91+
92+
Compress-Archive -Path "$tempDir/*" -DestinationPath $outputPath
93+
Remove-Item -Path $tempDir -Recurse -Force
94+
}
95+
96+
function Write-Folder ($outputPath)
97+
{
98+
if (Test-Path "$outputPath/*") {
99+
if ($Force) {
100+
Remove-Item -Path $outputPath -Recurse -Force
101+
} else {
102+
Write-Error "OutputPath already exists. Use -Force to overwrite."
103+
exit 1
104+
}
105+
}
106+
107+
$inputPath = Get-ChildItem -Path $InputPath -Attributes Directory
108+
$outputPath = Join-Path $outputPath "SiteExtensions" "Functions"
109+
New-Item -ItemType Directory -Path $outputPath | Out-Null
110+
111+
Copy-Item "$inputPath/applicationHost.xdt" -Destination $outputPath | Out-Null
112+
113+
$filesDest = (Join-Path $outputPath "$Bitness")
114+
Copy-Item "$inputPath/$Bitness/" -Destination "$filesDest/" -Container -Recurse | Out-Null
115+
116+
$workerDest = (Join-Path $filesDest "workers")
117+
Copy-Item "$inputPath/workers/" -Destination "$workerDest/" -Container -Recurse | Out-Null
118+
}
119+
120+
if ($NoZip) {
121+
Write-Folder $OutputPath
122+
} else {
123+
if (-not $OutputPath.EndsWith(".zip")) {
124+
$OutputPath = "$OutputPath.zip"
125+
}
126+
127+
Write-Zip $OutputPath
128+
}
129+
130+
Write-Host "Published private site extension to $OutputPath"
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
param(
2+
[string] $Version = $null,
3+
[string[]] $Artifacts = $null,
4+
[string] $CommitId = $null,
5+
[string] $OutputPath
6+
)
7+
8+
if (-not $Version) {
9+
$Version = dotnet build $PSScriptRoot --getProperty:Version
10+
}
11+
12+
if (-Not $Artifacts) {
13+
$Artifacts = @(
14+
"Functions.$Version"
15+
"Functions.Symbols.$Version.win-x64"
16+
"Functions.Symbols.$Version.win-x86"
17+
)
18+
}
19+
20+
if (-not $CommitId) {
21+
$CommitId = $env:BUILD_SOURCEVERSION
22+
}
23+
24+
if (-not $CommitId) {
25+
$CommitId = (git rev-parse HEAD).Trim()
26+
}
27+
28+
$obj = @{
29+
name = $Version
30+
artifacts = $Artifacts
31+
tag = "v$Version"
32+
commitId = $CommitId
33+
releaseNotesFile = "release_notes.md"
34+
}
35+
36+
if ($OutputPath) {
37+
Write-Host "Writing $obj to $OutputPath"
38+
$obj | ConvertTo-Json | Out-File $OutputPath
39+
}
40+
41+
return $obj

0 commit comments

Comments
 (0)