azure-functions-host/azure-pipelines.yml

657 строки
22 KiB
YAML

variables:
buildNumber: $[ counter('constant', 13000) ]
isReleaseBranch: $[contains(variables['Build.SourceBranch'], 'release/')]
DOTNET_NOLOGO: 1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_CLI_TELEMETRY_OPTOUT: 1
pr:
branches:
include:
- dev
- in-proc
- release/4.*
- release/in-proc
trigger:
branches:
include:
- dev
- in-proc
- release/4.*
- release/in-proc
jobs:
- job: InitializePipeline
pool:
name: '1ES-Hosted-AzFunc'
demands:
- ImageOverride -equals MMS2019TLS
steps:
- task: UseDotNet@2 # The pinned SDK we use to build
displayName: 'Install .NET SDK from global.json'
inputs:
packageType: sdk
useGlobalJson: true
- task: PowerShell@2
displayName: 'Initialize'
name: Initialize
inputs:
filePath: '$(Build.Repository.LocalPath)\build\initialize-pipeline.ps1'
showWarnings: true
pwsh: true
- job: BuildArtifacts
strategy:
matrix:
# net6-legacy is a temporary artifact that will eventually be removed
net6-legacy:
minorVersionPrefix: ""
net6:
minorVersionPrefix: "6"
net8:
minorVersionPrefix: "8"
dependsOn: InitializePipeline
condition: and(succeeded(), or(ne(variables['Build.Reason'], 'PullRequest'), eq(dependencies.InitializePipeline.outputs['Initialize.BuildArtifacts'], true)))
variables:
${{ if or( eq( variables['Build.Reason'], 'PullRequest' ), and( not( contains( variables['Build.SourceBranch'], 'release/in-proc' ) ), not( contains( variables['Build.SourceBranch'], 'release/ExtensionsMetadataGenerator/' ) ) ) ) }}:
suffixTemp: $(buildNumber)
packSuffixSwitchTemp: --version-suffix $(buildNumber)
emgSuffixSwitchTemp: --version-suffix ci$(buildNumber)
suffix: $[variables.suffixTemp] # this resolves to an empty string if it is missing
packSuffixSwitch: $[variables.packSuffixSwitchTemp]
emgSuffixSwitch: $[variables.emgSuffixSwitchTemp]
pool:
name: '1ES-Hosted-AzFunc'
demands:
- ImageOverride -equals MMS2019TLS
steps:
- template: build/install-dotnet.yml
- template: eng/ci/templates/steps/build-site-ext.yml
- task: PowerShell@2
displayName: "Check for security vulnerabilities"
inputs:
filePath: '$(Build.Repository.LocalPath)\build\check-vulnerabilities.ps1'
- task: DotNetCoreCLI@2
displayName: 'Build host packages'
inputs:
command: 'custom'
custom: 'pack'
arguments: '-p:BuildNumber=$(buildNumber) -c Release $(packSuffixSwitch) -p:MinorVersionPrefix="$(minorVersionPrefix)"'
projects: |
**\WebJobs.Script.csproj
**\WebJobs.Script.WebHost.csproj
**\WebJobs.Script.Grpc.csproj
- task: DotNetCoreCLI@2
displayName: 'Build Abstractions and ExtensionsMetadataGenerator'
inputs:
command: 'build'
arguments: '-c Release'
projects: |
**\ExtensionsMetadataGenerator.csproj
**\WebJobs.Script.Abstractions.csproj
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@2
displayName: 'ESRP CodeSigning: Strong Name and Authenticode'
inputs:
ConnectedServiceName: 'ESRP Service'
FolderPath: 'out/bin/WebJobs.Script.Abstractions'
Pattern: Microsoft.Azure.WebJobs.Script.Abstractions*.dll
signConfigType: inlineSignParams
inlineOperation: |
[
{
"KeyCode": "CP-230012",
"OperationCode": "SigntoolSign",
"Parameters": {
"OpusName": "Microsoft",
"OpusInfo": "http://www.microsoft.com",
"FileDigest": "/fd \"SHA256\"",
"PageHash": "/NPH",
"TimeStamp": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256"
},
"ToolName": "sign",
"ToolVersion": "1.0"
},
{
"KeyCode": "CP-230012",
"OperationCode": "SigntoolVerify",
"Parameters": {},
"ToolName": "sign",
"ToolVersion": "1.0"
}
]
- task: DeleteFiles@1
displayName: 'Delete CodeSignSummary files'
inputs:
contents: '**\CodeSignSummary-*.md'
- task: DotNetCoreCLI@2
displayName: 'Pack WebJobs.Script.Abstractions package'
inputs:
command: 'custom'
custom: 'pack'
arguments: '--no-build -c Release'
projects: |
**\WebJobs.Script.Abstractions.csproj
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@2
displayName: 'ESRP CodeSigning: Nupkg'
inputs:
ConnectedServiceName: 'ESRP Service'
FolderPath: 'out/pkg/release'
Pattern: 'Microsoft.Azure.WebJobs.Script.Abstractions*.nupkg'
signConfigType: inlineSignParams
inlineOperation: |
[
{
"KeyCode": "CP-401405",
"OperationCode": "NuGetSign",
"Parameters": {},
"ToolName": "sign",
"ToolVersion": "1.0"
},
{
"KeyCode": "CP-401405",
"OperationCode": "NuGetVerify",
"Parameters": {},
"ToolName": "sign",
"ToolVersion": "1.0"
}
]
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@2
displayName: 'ESRP CodeSigning: Strong Name and Authenticode'
inputs:
ConnectedServiceName: 'ESRP Service'
FolderPath: 'out/bin/ExtensionsMetadataGenerator'
Pattern: 'Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator*.dll'
signConfigType: inlineSignParams
inlineOperation: |
[
{
"KeyCode" : "CP-233863-SN",
"OperationCode" : "StrongNameSign",
"Parameters" : {},
"ToolName" : "sign",
"ToolVersion" : "1.0"
},
{
"KeyCode" : "CP-233863-SN",
"OperationCode" : "StrongNameVerify",
"Parameters" : {},
"ToolName" : "sign",
"ToolVersion" : "1.0"
},
{
"KeyCode": "CP-230012",
"OperationCode": "SigntoolSign",
"Parameters": {
"OpusName": "Microsoft",
"OpusInfo": "http://www.microsoft.com",
"FileDigest": "/fd \"SHA256\"",
"PageHash": "/NPH",
"TimeStamp": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256"
},
"ToolName": "sign",
"ToolVersion": "1.0"
},
{
"KeyCode": "CP-230012",
"OperationCode": "SigntoolVerify",
"Parameters": {},
"ToolName": "sign",
"ToolVersion": "1.0"
}
]
condition: and(succeeded(), startsWith(variables['SignArtifacts'], 'true'))
- task: DeleteFiles@1
displayName: 'Delete CodeSignSummary files'
inputs:
contents: '**\CodeSignSummary-*.md'
- task: DotNetCoreCLI@2
displayName: 'Pack ExtensionsMetadataGenerator package'
inputs:
command: 'custom'
custom: 'pack'
arguments: '--no-build -c Release $(emgSuffixSwitch)'
projects: |
**\ExtensionsMetadataGenerator.csproj
steps:
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@2
displayName: 'ESRP CodeSigning: Nupkg'
inputs:
ConnectedServiceName: 'ESRP Service'
FolderPath: 'out/pkg/release'
Pattern: 'Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator*.nupkg'
signConfigType: inlineSignParams
inlineOperation: |
[
{
"KeyCode": "CP-401405",
"OperationCode": "NuGetSign",
"Parameters": {},
"ToolName": "sign",
"ToolVersion": "1.0"
},
{
"KeyCode": "CP-401405",
"OperationCode": "NuGetVerify",
"Parameters": {},
"ToolName": "sign",
"ToolVersion": "1.0"
}
]
condition: and(succeeded(), startsWith(variables['SignArtifacts'], 'true'))
- task: DeleteFiles@1
displayName: 'Delete CodeSignSummary files'
inputs:
contents: '**\CodeSignSummary-*.md'
- task: ManifestGeneratorTask@0
displayName: 'SBOM Generation Task - SiteExtension'
inputs:
BuildDropPath: '$(Build.ArtifactStagingDirectory)\SiteExtension'
Verbosity: 'Information'
- publish: $(Build.ArtifactStagingDirectory)\SiteExtension
artifact: _SiteExtension.net$(minorVersionPrefix)
- task: ManifestGeneratorTask@0
displayName: 'SBOM Generation Task - PrivateSiteExtension'
inputs:
BuildDropPath: '$(Build.ArtifactStagingDirectory)\PrivateSiteExtension'
Verbosity: 'Information'
- publish: $(Build.ArtifactStagingDirectory)\PrivateSiteExtension
artifact: _PrivateSiteExtension.net$(minorVersionPrefix)
- task: ManifestGeneratorTask@0
displayName: 'SBOM Generation Task - Symbols'
inputs:
BuildDropPath: '$(Build.ArtifactStagingDirectory)\SiteExtensionSymbols'
Verbosity: 'Information'
- publish: $(Build.ArtifactStagingDirectory)\SiteExtensionSymbols
artifact: Symbols
- task: ManifestGeneratorTask@0
displayName: 'SBOM Generation Task - NugetPackages'
inputs:
BuildDropPath: 'out/pkg/release'
Verbosity: 'Information'
- publish: out/pkg/release
artifact: _NugetPackages.net$(minorVersionPrefix)
- job: RunUnitTests
strategy:
matrix:
net6:
targetFramework: "net6.0"
net8:
targetFramework: "net8.0"
pool:
name: '1ES-Hosted-AzFunc'
demands:
- ImageOverride -equals MMS2019TLS
steps:
- template: build/install-dotnet.yml
- task: DotNetCoreCLI@2
displayName: 'Unit Tests'
inputs:
command: 'test'
testRunTitle: 'Unit Tests'
arguments: '-v n -f $(targetFramework)'
projects: |
**\WebJobs.Script.Scaling.Tests.csproj
**\WebJobs.Script.Tests.csproj
- task: DotNetCoreCLI@2
displayName: 'ExtensionsMetadataGenerator Unit Tests'
inputs:
command: 'test'
testRunTitle: 'EGM Unit Tests'
arguments: '-v n'
projects: |
**\ExtensionsMetadataGeneratorTests.csproj
- job: RunNonE2EIntegrationTests
strategy:
matrix:
net6:
targetFramework: "net6.0"
net8:
targetFramework: "net8.0"
pool:
name: '1ES-Hosted-AzFunc'
demands:
- ImageOverride -equals MMS2019TLS
steps:
- template: build/install-dotnet.yml
- task: UseNode@1
inputs:
version: '14.x'
- task: PowerShell@2
displayName: 'Install Az.Storage Powershell module'
inputs:
targetType: 'inline'
script: 'Install-Module -Name Az.Storage -RequiredVersion 1.11.0 -Scope CurrentUser -Force -AllowClobber'
- task: AzurePowerShell@5
displayName: 'Checkout secrets'
inputs:
azureSubscription: Azure-Functions-Host-CI
ScriptPath: '$(Build.Repository.LocalPath)\build\checkout-secrets.ps1'
azurePowerShellVersion: 'LatestVersion'
- task: AzureKeyVault@1
inputs:
# Note: This is actually a Service Connection in DevOps, not an Azure subscription name
azureSubscription: 'Azure-Functions-Host-CI'
keyVaultName: azure-functions-host-$(LeaseBlob)
secretsFilter: '*'
- task: DotNetCoreCLI@2
displayName: 'Non-E2E integration tests'
inputs:
command: 'test'
testRunTitle: 'Non-E2E integration tests'
arguments: '--filter "Category!=E2E" -f $(targetFramework)'
projects: |
**\WebJobs.Script.Tests.Integration.csproj
env:
AzureWebJobsStorage: $(Storage)
AzureWebJobsSecondaryStorage: $(SecondaryStorage)
ConnectionStrings__CosmosDB: $(CosmosDB)
AzureWebJobsEventHubSender: $(EventHub)
AzureWebJobsEventHubReceiver: $(EventHub)
AzureWebJobsSecretStorageKeyVaultUri: $(KeyVaultUri)
AzureWebJobsSecretStorageKeyVaultTenantId: $(AzureTenantId)
AzureWebJobsSecretStorageKeyVaultClientId: $(AzureClientId)
AzureWebJobsSecretStorageKeyVaultClientSecret: $(AzureClientSecret)
- task: AzurePowerShell@5
condition: always()
displayName: 'Checkin secrets'
inputs:
azureSubscription: Azure-Functions-Host-CI
ScriptPath: '$(Build.Repository.LocalPath)\build\checkin-secrets.ps1'
ScriptArguments: '-leaseBlob $(LeaseBlob) -leaseToken $(LeaseToken)'
azurePowerShellVersion: 'LatestVersion'
- job: RunIntegrationTests
strategy:
matrix:
net6:
targetFramework: "net6.0"
net8:
targetFramework: "net8.0"
pool:
name: '1ES-Hosted-AzFunc'
demands:
- ImageOverride -equals MMS2019TLS
steps:
- template: build/install-dotnet.yml
- task: UseNode@1
inputs:
version: '14.x'
- task: UsePythonVersion@0
inputs:
versionSpec: '3.7.x'
addToPath: true
- task: PowerShell@2
displayName: 'Install Az.Storage Powershell module'
inputs:
targetType: 'inline'
script: 'Install-Module -Name Az.Storage -RequiredVersion 1.11.0 -Scope CurrentUser -Force -AllowClobber'
- task: Npm@1
displayName: 'npm ci'
inputs:
command: ci
workingDir: sample/CustomHandlerRetry
- task: AzureKeyVault@1
inputs:
# Note: This is actually a Service Connection in DevOps, not an Azure subscription name
azureSubscription: 'Azure-Functions-Host-CI'
keyVaultName: 'azure-functions-host-ci'
secretsFilter: '*'
- task: AzurePowerShell@5
displayName: 'Checkout secrets'
inputs:
azureSubscription: Azure-Functions-Host-CI
ScriptPath: '$(Build.Repository.LocalPath)\build\checkout-secrets.ps1'
azurePowerShellVersion: 'LatestVersion'
- task: AzureKeyVault@1
inputs:
# Note: This is actually a Service Connection in DevOps, not an Azure subscription name
azureSubscription: 'Azure-Functions-Host-CI'
keyVaultName: azure-functions-host-$(LeaseBlob)
secretsFilter: '*'
- task: PowerShell@2
displayName: 'Set environment variables'
inputs:
targetType: 'inline'
script: |
Write-Host "##vso[task.setvariable variable=AzureWebJobsStorage]$env:AzureWebJobsStorageSecretMap"
Write-Host "##vso[task.setvariable variable=AzureWebJobsSeconaryStorage]$env:AzureWebJobsSecondaryStorageSecretMap"
Write-Host "##vso[task.setvariable variable=ConnectionStrings__CosmosDB]$env:CosmosDbSecretMap"
Write-Host "##vso[task.setvariable variable=AzureWebJobsEventHubSender]$env:AzureWebJobsEventHubSenderSecretMap"
Write-Host "##vso[task.setvariable variable=AzureWebJobsEventHubReceiver]$env:AzureWebJobsEventHubReceiverSecretMap"
env:
AzureWebJobsStorageSecretMap: $(Storage)
AzureWebJobsSecondaryStorageSecretMap: $(SecondaryStorage)
CosmosDbSecretMap: $(CosmosDb)
AzureWebJobsEventHubSenderSecretMap: $(EventHub)
AzureWebJobsEventHubReceiverSecretMap: $(EventHub)
- task: JavaToolInstaller@0
inputs:
versionSpec: '11'
jdkArchitectureOption: 'x64'
jdkSourceOption: 'PreInstalled'
- task: DotNetCoreCLI@2
displayName: "C# end to end tests"
condition: succeededOrFailed()
inputs:
command: 'test'
testRunTitle: "C# end to end tests"
arguments: '--filter "Group=CSharpEndToEndTests" -f $(targetFramework)'
projects: |
**\WebJobs.Script.Tests.Integration.csproj
- task: DotNetCoreCLI@2
displayName: "Node end to end tests"
condition: succeededOrFailed()
inputs:
command: 'test'
testRunTitle: "Node end to end tests"
arguments: '--filter "Group=NodeEndToEndTests" --no-build -f $(targetFramework)'
projects: |
**\WebJobs.Script.Tests.Integration.csproj
- task: DotNetCoreCLI@2
displayName: "Direct load end to end tests"
condition: succeededOrFailed()
inputs:
command: 'test'
testRunTitle: "Direct load end to end tests"
arguments: '--filter "Group=DirectLoadEndToEndTests" --no-build -f $(targetFramework)'
projects: |
**\WebJobs.Script.Tests.Integration.csproj
- task: DotNetCoreCLI@2
displayName: "F# end to end tests"
condition: succeededOrFailed()
inputs:
command: 'test'
testRunTitle: "F# end to end tests"
arguments: '--filter "Group=FSharpEndToEndTests" --no-build -f $(targetFramework)'
projects: |
**\WebJobs.Script.Tests.Integration.csproj
- task: DotNetCoreCLI@2
displayName: "Language worker end to end tests"
condition: succeededOrFailed()
inputs:
command: 'test'
testRunTitle: "Language worker end to end tests"
arguments: '--filter "Group=LanguageWorkerSelectionEndToEndTests" --no-build -f $(targetFramework)'
projects: |
**\WebJobs.Script.Tests.Integration.csproj
- task: DotNetCoreCLI@2
displayName: "Node script host end to end tests"
condition: succeededOrFailed()
inputs:
command: 'test'
testRunTitle: "Node script host end to end tests"
arguments: '--filter "Group=NodeScriptHostTests" --no-build -f $(targetFramework)'
projects: |
**\WebJobs.Script.Tests.Integration.csproj
- task: DotNetCoreCLI@2
displayName: "Raw assembly end to end tests"
condition: succeededOrFailed()
inputs:
command: 'test'
testRunTitle: "Raw assembly end to end tests"
arguments: '--filter "Group=RawAssemblyEndToEndTests" --no-build -f $(targetFramework)'
projects: |
**\WebJobs.Script.Tests.Integration.csproj
- task: DotNetCoreCLI@2
displayName: "Samples end to end tests"
condition: succeededOrFailed()
inputs:
command: 'test'
testRunTitle: "Samples end to end tests"
arguments: '--filter "Group=SamplesEndToEndTests" --no-build -f $(targetFramework)'
projects: |
**\WebJobs.Script.Tests.Integration.csproj
- task: DotNetCoreCLI@2
displayName: "Drain mode end to end tests"
condition: succeededOrFailed()
inputs:
command: 'test'
testRunTitle: "Drain mode end to end tests"
arguments: '--filter "Group=DrainModeEndToEndTests" --no-build -f $(targetFramework)'
projects: |
**\WebJobs.Script.Tests.Integration.csproj
- task: DotNetCoreCLI@2
displayName: "Standby mode end to end tests Windows"
condition: succeededOrFailed()
inputs:
command: 'test'
testRunTitle: "Standby mode end to end tests Windows"
arguments: '--filter "Group=StandbyModeEndToEndTests_Windows" --no-build -f $(targetFramework)'
projects: |
**\WebJobs.Script.Tests.Integration.csproj
- task: DotNetCoreCLI@2
displayName: "Standby mode end to end tests Linux"
condition: succeededOrFailed()
inputs:
command: 'test'
testRunTitle: "Standby mode end to end tests Linux"
arguments: '--filter "Group=StandbyModeEndToEndTests_Linux" --no-build -f $(targetFramework)'
projects: |
**\WebJobs.Script.Tests.Integration.csproj
- task: DotNetCoreCLI@2
displayName: "Linux container end to end tests Windows"
condition: succeededOrFailed()
inputs:
command: 'test'
testRunTitle: "Linux container end to end tests Windows"
arguments: '--filter "Group=ContainerInstanceTests" --no-build -f $(targetFramework)'
projects: |
**\WebJobs.Script.Tests.Integration.csproj
- task: DotNetCoreCLI@2
displayName: "Release verification tests"
condition: eq(variables['isReleaseBranch'], 'True')
inputs:
command: 'test'
testRunTitle: "Release verification tests"
arguments: '--filter "Group=ReleaseTests" --no-build -f $(targetFramework)'
projects: |
**\WebJobs.Script.Tests.Integration.csproj
- task: AzurePowerShell@5
condition: always()
displayName: 'Checkin secrets'
inputs:
azureSubscription: Azure-Functions-Host-CI
ScriptPath: '$(Build.Repository.LocalPath)\build\checkin-secrets.ps1'
ScriptArguments: '-leaseBlob $(LeaseBlob) -leaseToken $(LeaseToken)'
azurePowerShellVersion: 'LatestVersion'
- job: PublishArtifacts
dependsOn:
- BuildArtifacts
- RunUnitTests
- RunNonE2EIntegrationTests
- RunIntegrationTests
condition: succeeded()
steps:
- task: DownloadPipelineArtifact@2
displayName: 'Download _SiteExtension.net6 Artifact'
inputs:
buildType: 'current'
artifact: '_SiteExtension.net6'
path: '$(Build.ArtifactStagingDirectory)/SiteExtension'
- task: DownloadPipelineArtifact@2
displayName: 'Download _SiteExtension.net8 Artifact'
inputs:
buildType: 'current'
artifact: '_SiteExtension.net8'
path: '$(Build.ArtifactStagingDirectory)/SiteExtension'
- task: DownloadPipelineArtifact@2
displayName: 'Download _PrivateSiteExtension.net6 Artifact'
inputs:
buildType: 'current'
artifact: '_PrivateSiteExtension.net6'
path: '$(Build.ArtifactStagingDirectory)/PrivateSiteExtension'
- task: DownloadPipelineArtifact@2
displayName: 'Download _PrivateSiteExtension.net8 Artifact'
inputs:
buildType: 'current'
artifact: '_PrivateSiteExtension.net8'
path: '$(Build.ArtifactStagingDirectory)/PrivateSiteExtension'
- task: DownloadPipelineArtifact@2
displayName: 'Download _NugetPackages.net8 Artifact'
inputs:
buildType: 'current'
artifact: '_NugetPackages.net8'
path: '$(Build.ArtifactStagingDirectory)/packages'
- task: DownloadPipelineArtifact@2
displayName: 'Download Symbols6 Artifact'
inputs:
buildType: 'current'
artifact: '_Symbols.net6'
path: '$(Build.ArtifactStagingDirectory)/Symbols'
- task: DownloadPipelineArtifact@2
displayName: 'Download Symbols8 Artifact'
inputs:
buildType: 'current'
artifact: '_Symbols.net8'
path: '$(Build.ArtifactStagingDirectory)/Symbols'
# Publish artifacts.
- task: PublishPipelineArtifact@1
displayName: 'Publish SiteExtension Artifact'
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)/SiteExtension'
artifact: 'SiteExtension'
publishLocation: 'pipeline'
- task: PublishPipelineArtifact@1
displayName: 'Publish PrivateSiteExtension Artifact'
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)/PrivateSiteExtension'
artifact: 'PrivateSiteExtension'
publishLocation: 'pipeline'
- task: PublishPipelineArtifact@1
displayName: 'Publish Nuget packages Artifact'
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)/packages'
artifact: 'NugetPackages'
publishLocation: 'pipeline'
- task: PublishPipelineArtifact@1
displayName: 'Publish Symbols Artifact'
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)/Symbols'
artifact: 'Symbols'
publishLocation: 'pipeline'