Skip to content

Commit f0a96f5

Browse files
authored
Convert build pipeline to 1ES (#1061)
- Convert build pipeline to 1ES - Remove old pipeline - Changes to build.ps1 for new pipeline
1 parent af76566 commit f0a96f5

File tree

6 files changed

+166
-185
lines changed

6 files changed

+166
-185
lines changed

azure-pipelines.yml

Lines changed: 0 additions & 127 deletions
This file was deleted.

build.ps1

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,7 @@ param(
2828
$Configuration = "Debug",
2929

3030
[string]
31-
$BuildNumber = '0',
32-
33-
[switch]
34-
$AddSBOM,
35-
36-
[string]
37-
$SBOMUtilSASUrl
31+
$BuildNumber = '0'
3832
)
3933

4034
#Requires -Version 7.0
@@ -73,35 +67,6 @@ function Get-FunctionsCoreToolsDir {
7367
}
7468
}
7569

76-
function Install-SBOMUtil
77-
{
78-
if ([string]::IsNullOrEmpty($SBOMUtilSASUrl))
79-
{
80-
throw "The `$SBOMUtilSASUrl parameter cannot be null or empty when specifying the `$AddSBOM switch"
81-
}
82-
83-
$MANIFESTOOLNAME = "ManifestTool"
84-
Write-Log "Installing $MANIFESTOOLNAME..."
85-
86-
$MANIFESTOOL_DIRECTORY = Join-Path $PSScriptRoot $MANIFESTOOLNAME
87-
Remove-Item -Recurse -Force $MANIFESTOOL_DIRECTORY -ErrorAction Ignore
88-
89-
Invoke-RestMethod -Uri $SBOMUtilSASUrl -OutFile "$MANIFESTOOL_DIRECTORY.zip"
90-
Expand-Archive "$MANIFESTOOL_DIRECTORY.zip" -DestinationPath $MANIFESTOOL_DIRECTORY
91-
92-
$dllName = "Microsoft.ManifestTool.dll"
93-
$manifestToolPath = "$MANIFESTOOL_DIRECTORY/$dllName"
94-
95-
if (-not (Test-Path $manifestToolPath))
96-
{
97-
throw "$MANIFESTOOL_DIRECTORY does not contain '$dllName'"
98-
}
99-
100-
Write-Log 'Done.'
101-
102-
return $manifestToolPath
103-
}
104-
10570
function Deploy-PowerShellWorker {
10671
$ErrorActionPreference = 'Stop'
10772

@@ -179,28 +144,6 @@ if (!$NoBuild.IsPresent) {
179144

180145
dotnet publish -c $Configuration "/p:BuildNumber=$BuildNumber" $PSScriptRoot
181146

182-
if ($AddSBOM)
183-
{
184-
# Install manifest tool
185-
$manifestTool = Install-SBOMUtil
186-
Write-Log "manifestTool: $manifestTool "
187-
188-
# Generate manifest
189-
$buildPath = "$PSScriptRoot/src/bin/$Configuration/$TargetFramework/publish"
190-
$telemetryFilePath = Join-Path $PSScriptRoot ((New-Guid).Guid + ".json")
191-
$packageName = "Microsoft.Azure.Functions.PowerShellWorker.nuspec"
192-
193-
# Delete the manifest folder if it exists
194-
$manifestFolderPath = Join-Path $buildPath "_manifest"
195-
if (Test-Path $manifestFolderPath)
196-
{
197-
Remove-Item $manifestFolderPath -Recurse -Force -ErrorAction Ignore
198-
}
199-
200-
Write-Log "Running: dotnet $manifestTool generate -BuildDropPath $buildPath -BuildComponentPath $buildPath -Verbosity Information -t $telemetryFilePath"
201-
& { dotnet $manifestTool generate -BuildDropPath $buildPath -BuildComponentPath $buildPath -Verbosity Information -t $telemetryFilePath -PackageName $packageName }
202-
}
203-
204147
dotnet pack -c $Configuration "/p:BuildNumber=$BuildNumber" "$PSScriptRoot/package"
205148
}
206149

eng/ci/official.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
trigger:
2+
batch: true
3+
branches:
4+
include:
5+
- v4.x/*
6+
- v3.x/*
7+
8+
# CI only, does not trigger on PRs.
9+
pr: none
10+
11+
resources:
12+
repositories:
13+
- repository: 1es
14+
type: git
15+
name: 1ESPipelineTemplates/1ESPipelineTemplates
16+
ref: refs/tags/release
17+
18+
variables:
19+
Configuration: Release
20+
buildNumber: $[ counter('build', 4000) ] # Start higher than the versions from the previous pipeline. Every build (pr or branch) will increment.
21+
22+
extends:
23+
template: v1/1ES.Official.PipelineTemplate.yml@1es
24+
parameters:
25+
pool:
26+
name: 1es-pool-azfunc
27+
image: 1es-windows-2022
28+
os: windows
29+
30+
stages:
31+
- stage: WindowsUnitTests
32+
dependsOn: []
33+
jobs:
34+
- template: /eng/ci/templates/test.yml@self
35+
36+
- stage: LinuxUnitTests
37+
dependsOn: []
38+
jobs:
39+
- template: /eng/ci/templates/test.yml@self
40+
pool:
41+
name: 1es-pool-azfunc
42+
image: 1es-ubuntu-22.04
43+
os: linux
44+
45+
- stage: Build
46+
dependsOn: [WindowsUnitTests, LinuxUnitTests]
47+
jobs:
48+
- template: /eng/ci/templates/build.yml@self

eng/ci/public.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
trigger:
2+
batch: true
3+
branches:
4+
include:
5+
- dev
6+
- v4.x/*
7+
- v3.x/*
8+
9+
# Only run the tests on PR to official branches - do we want to run them on all PRs?
10+
pr:
11+
branches:
12+
include:
13+
- '*'
14+
15+
resources:
16+
repositories:
17+
- repository: 1es
18+
type: git
19+
name: 1ESPipelineTemplates/1ESPipelineTemplates
20+
ref: refs/tags/release
21+
22+
extends:
23+
template: v1/1ES.Unofficial.PipelineTemplate.yml
24+
parameters:
25+
pool:
26+
name: 1es-pool-azfunc-public
27+
image: 1es-windows-2022
28+
os: windows
29+
30+
stages:
31+
- stage: WindowsUnitTests
32+
dependsOn: []
33+
jobs:
34+
- template: /eng/ci/templates/test.yml@self
35+
pool:
36+
name: 1es-pool-azfunc-public
37+
38+
- stage: LinuxUnitTests
39+
dependsOn: []
40+
jobs:
41+
- template: /eng/ci/templates/test.yml@self
42+
pool:
43+
name: 1es-pool-azfunc-public
44+
image: 1es-ubuntu-22.04
45+
os: linux

eng/ci/templates/build.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
jobs:
2+
- job:
3+
templateContext:
4+
outputs:
5+
- output: nuget
6+
packagesToPush: "$(Build.ArtifactStagingDirectory)/*.nupkg"
7+
packageParentPath: "$(Build.ArtifactStagingDirectory)"
8+
nuGetFeedType: internal
9+
publishVstsFeed: "e6a70c92-4128-439f-8012-382fe78d6396/c0493cce-bc63-4e11-9fc9-e7c45291f151"
10+
sbomPackageName: "Azure Functions PowerShell Worker"
11+
sbomBuildComponentPath: "$(Build.SourcesDirectory)"
12+
allowPackageConflicts: true
13+
# - output: nuget
14+
# condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/dev'), eq(variables['UPLOADPACKAGETOPRERELEASEFEED'], true))
15+
# packagesToPush: '$(Build.ArtifactStagingDirectory)/*.nupkg'
16+
# packageParentPath: '$(Build.ArtifactStagingDirectory)'
17+
# nuGetFeedType: 'internal'
18+
# publishVstsFeed: 'e6a70c92-4128-439f-8012-382fe78d6396/f37f760c-aebd-443e-9714-ce725cd427df' # AzureFunctionsPreRelease feed
19+
# allowPackageConflicts: true
20+
steps:
21+
- pwsh: ./build.ps1 -NoBuild -Bootstrap
22+
displayName: "Running ./build.ps1 -NoBuild -Bootstrap"
23+
24+
- pwsh: |
25+
$ErrorActionPreference = "Stop"
26+
27+
./build.ps1 -Clean -Configuration Release -BuildNumber "$(buildNumber)"
28+
displayName: "Build worker code"
29+
30+
- task: CopyFiles@2
31+
inputs:
32+
SourceFolder: "$(System.DefaultWorkingDirectory)/package"
33+
Contents: |
34+
**/*.nuspec
35+
**/*.nupkg
36+
TargetFolder: "$(Build.ArtifactStagingDirectory)"
37+
flattenFolders: true
38+
displayName: "Copy package to artifacts directory"

eng/ci/templates/test.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
jobs:
2+
- job: UnitTests
3+
steps:
4+
- pwsh: ./build.ps1 -NoBuild -Bootstrap
5+
displayName: "Running ./build.ps1 -NoBuild -Bootstrap"
6+
7+
- pwsh: ./Check-CsprojVulnerabilities.ps1
8+
displayName: "Check for security vulnerabilities"
9+
10+
- pwsh: |
11+
$ErrorActionPreference = "Stop"
12+
13+
./build.ps1 -Clean -Configuration Release -BuildNumber "$(buildNumber)"
14+
displayName: "Build worker code"
15+
16+
- pwsh: ./build.ps1 -NoBuild -Test
17+
displayName: "Running UnitTest"
18+
19+
# - pwsh: ./test/E2E/Start-E2ETest.ps1
20+
# env:
21+
# AzureWebJobsStorage: $(AzureWebJobsStorage)
22+
# AzureWebJobsCosmosDBConnectionString: $(AzureWebJobsCosmosDBConnectionString)
23+
# AzureWebJobsServiceBus: $(AzureWebJobsServiceBus)
24+
# AzureWebJobsEventHubSender: $(AzureWebJobsEventHubSender)
25+
# FUNCTIONS_WORKER_RUNTIME: "powershell"
26+
# displayName: "Running E2ETest"
27+
28+
- task: PublishTestResults@2
29+
inputs:
30+
testResultsFormat: "VSTest"
31+
testResultsFiles: "**/*.trx"
32+
failTaskOnFailedTests: true
33+
condition: succeededOrFailed()
34+
displayName: "Publish tests results"

0 commit comments

Comments
 (0)