272 строки
9.4 KiB
YAML
272 строки
9.4 KiB
YAML
trigger:
|
|
batch: true
|
|
branches:
|
|
include:
|
|
- main
|
|
- production
|
|
|
|
pr:
|
|
branches:
|
|
include:
|
|
- main
|
|
|
|
variables:
|
|
# https://dev.azure.com/dnceng/internal/_library?itemType=VariableGroups&view=VariableGroupView&variableGroupId=189
|
|
# Required for MaestroAppClientId, MaestroStagingAppClientId
|
|
- group: Publish-Build-Assets
|
|
- name: resourceGroupName
|
|
value: product-construction-service
|
|
- name: containerName
|
|
value: product-construction-service.api
|
|
- name: diffFolder
|
|
value: $(Build.ArtifactStagingDirectory)/diff
|
|
- name: _TeamName
|
|
value: DotNetCore
|
|
- name: _PublishUsingPipelines
|
|
value: true
|
|
- name: _DotNetArtifactsCategory
|
|
value: .NETCore
|
|
- name: _SignType
|
|
value: test
|
|
- ${{ if not(or(startsWith(variables['Build.SourceBranch'], 'refs/heads/production'), startsWith(variables['Build.SourceBranch'], 'refs/heads/production-'), eq(variables['Build.SourceBranch'], 'refs/heads/production'))) }}:
|
|
- name: subscriptionId
|
|
value: e6b5f9f5-0ca4-4351-879b-014d78400ec2
|
|
- name: containerappName
|
|
value: product-construction-int
|
|
- name: containerjobNames
|
|
value: sub-triggerer-twicedaily-int,sub-triggerer-daily-int,sub-triggerer-weekly-int,longest-path-updater-job-int,feed-cleaner-int
|
|
- name: containerRegistryName
|
|
value: productconstructionint
|
|
- name: containerappEnvironmentName
|
|
value: product-construction-service-env-int
|
|
- name: containerappWorkspaceName
|
|
value: product-construction-service-workspace-int
|
|
- name: dockerRegistryUrl
|
|
value: productconstructionint.azurecr.io
|
|
- name: serviceConnectionName
|
|
value: ProductConstructionServiceDeploymentInt
|
|
- name: authServiceConnection
|
|
value: "Darc: Maestro Staging"
|
|
- name: MaestroAppId
|
|
value: $(MaestroStagingAppClientId)
|
|
- name: redisConnectionString
|
|
value: "product-construction-service-redis-int.redis.cache.windows.net:6380,ssl=true"
|
|
- ${{ else }}:
|
|
- name: subscriptionId
|
|
value: fbd6122a-9ad3-42e4-976e-bccb82486856
|
|
- name: containerappName
|
|
value: product-construction-prod
|
|
- name: containerjobNames
|
|
value: sub-triggerer-twicedaily-prod,sub-triggerer-daily-prod,sub-triggerer-weekly-prod,longest-path-updater-job-prod,feed-cleaner-prod
|
|
- name: containerRegistryName
|
|
value: productconstructionprod
|
|
- name: containerappEnvironmentName
|
|
value: product-construction-service-env-prod
|
|
- name: containerappWorkspaceName
|
|
value: product-construction-service-workspace-prod
|
|
- name: dockerRegistryUrl
|
|
value: productconstructionprod.azurecr.io
|
|
- name: serviceConnectionName
|
|
value: ProductConstructionServiceDeploymentProd
|
|
- name: authServiceConnection
|
|
value: "Darc: Maestro Production"
|
|
- name: MaestroAppId
|
|
value: $(MaestroAppClientId)
|
|
- name: redisConnectionString
|
|
value: "product-construction-service-redis-prod.redis.cache.windows.net,ssl=true"
|
|
- ${{ if eq(variables['Build.SourceBranch'], 'refs/heads/main') }}:
|
|
- name: devBranchSuffix
|
|
value:
|
|
- ${{ else }}:
|
|
- name: devBranchSuffix
|
|
value: -dev
|
|
|
|
stages:
|
|
- stage: Build
|
|
displayName: Build
|
|
dependsOn: []
|
|
jobs:
|
|
- job: BuildAndPublish
|
|
displayName: Build and Publish Repo
|
|
pool:
|
|
name: NetCore1ESPool-Internal
|
|
demands: ImageOverride -equals 1es-windows-2019
|
|
|
|
variables:
|
|
- name: BuildConfig
|
|
value: Release
|
|
|
|
steps:
|
|
- checkout: self
|
|
|
|
- powershell: |
|
|
. .\eng\common\tools.ps1
|
|
InitializeDotNetCli -install:$true
|
|
.\.dotnet\dotnet workload update --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json
|
|
.\.dotnet\dotnet workload install aspire --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json
|
|
displayName: Install .NET and Aspire Workload
|
|
|
|
- powershell: >
|
|
.\eng\common\build.ps1
|
|
-restore
|
|
-pack
|
|
-configuration $(BuildConfig)
|
|
-projects .\src\Microsoft.DotNet.Darc\Darc\Microsoft.DotNet.Darc.csproj
|
|
displayName: Build Darc
|
|
|
|
- powershell: >
|
|
.\eng\common\build.ps1
|
|
-restore
|
|
-build
|
|
-configuration $(BuildConfig)
|
|
-projects .\test\ProductConstructionService.ScenarioTests\ProductConstructionService.ScenarioTests.csproj
|
|
displayName: Build ScenarioTests
|
|
|
|
- powershell: >
|
|
.\eng\common\build.ps1
|
|
-restore
|
|
-build
|
|
-configuration $(BuildConfig)
|
|
-projects .\src\ProductConstructionService\ProductConstructionService.Cli\ProductConstructionService.Cli.csproj
|
|
displayName: Build ProductConstructionService.Cli
|
|
|
|
- publish: $(Build.SourcesDirectory)\artifacts\bin\ProductConstructionService.ScenarioTests\$(BuildConfig)\net8.0\publish
|
|
artifact: ProductConstructionService.ScenarioTests
|
|
|
|
- publish: $(Build.SourcesDirectory)\artifacts\packages\$(BuildConfig)\NonShipping
|
|
artifact: PackageArtifacts
|
|
|
|
- publish: $(Build.SourcesDirectory)\artifacts\bin\ProductConstructionService.Cli\$(BuildConfig)\net8.0
|
|
artifact: ProductConstructionService.Cli
|
|
|
|
|
|
- job: BuildAndPublishDocker
|
|
displayName: Build And Publish new Docker Image
|
|
pool:
|
|
name: NetCore1ESPool-Internal
|
|
demands: ImageOverride -equals 1es-ubuntu-2004
|
|
|
|
steps:
|
|
- checkout: self
|
|
|
|
- template: eng/templates/steps/docker-build.yml
|
|
parameters:
|
|
devBranchSuffix: $(devBranchSuffix)
|
|
dockerImageName: $(dockerRegistryUrl)/$(containerName)
|
|
|
|
- ${{ if notin(variables['Build.Reason'], 'PullRequest') }}:
|
|
- stage: DeployPCS
|
|
dependsOn:
|
|
- Build
|
|
displayName: Deploy Product Construction Service
|
|
|
|
jobs:
|
|
- job: Deploy
|
|
displayName: Deploy container app
|
|
pool:
|
|
name: NetCore1ESPool-Internal
|
|
demands: ImageOverride -equals 1es-windows-2019
|
|
variables:
|
|
newDockerImageTag: $[stageDependencies.Build.BuildAndPublishDocker.outputs['DockerTag.newDockerImageTag']]
|
|
|
|
steps:
|
|
- powershell: |
|
|
Write-Host $(containerjobNames)
|
|
$az = Get-Command az.cmd
|
|
"##vso[task.setvariable variable=azCliPath]$($az.Source)"
|
|
|
|
- powershell: Write-Host $(azCliPath)
|
|
|
|
- task: AzureCLI@2
|
|
inputs:
|
|
azureSubscription: $(serviceConnectionName)
|
|
scriptType: pscore
|
|
scriptLocation: inlineScript
|
|
inlineScript: |
|
|
New-Item -ItemType Directory -Path $(diffFolder)
|
|
$before = az containerapp show --name $(containerappName) -g $(resourceGroupName) --output json
|
|
Set-Content -Path $(diffFolder)/before.json -Value $before
|
|
displayName: Snapshot configuration (before)
|
|
|
|
- download: current
|
|
displayName: Download ProductConstructionService.Cli
|
|
artifact: ProductConstructionService.Cli
|
|
|
|
- task: NuGetToolInstaller@1
|
|
displayName: Use NuGet
|
|
inputs:
|
|
versionSpec: 5.3.x
|
|
|
|
- powershell: |
|
|
. .\eng\common\tools.ps1
|
|
InitializeDotNetCli -install:$true
|
|
.\.dotnet\dotnet workload install aspire
|
|
displayName: Install .NET and Aspire Workload
|
|
|
|
# We'll need to give this service connection permission to get an auth token for PCS
|
|
- task: AzureCLI@2
|
|
inputs:
|
|
azureSubscription: $(serviceConnectionName)
|
|
scriptType: pscore
|
|
scriptLocation: inlineScript
|
|
inlineScript: >
|
|
$(Pipeline.Workspace)/ProductConstructionService.Cli/ProductConstructionService.Cli.exe
|
|
deploy
|
|
--subscriptionId $(subscriptionId)
|
|
--resourceGroupName $(resourceGroupName)
|
|
--containerRegistryName $(containerRegistryName)
|
|
--containerAppName $(containerappName)
|
|
--workspaceName $(containerappWorkspaceName)
|
|
--containerJobNames $(containerjobNames)
|
|
--newImageTag $(newDockerImageTag)
|
|
--imageName $(containerName)
|
|
--azCliPath "$(azCliPath)"
|
|
--redisConnectionString $(redisConnectionString)
|
|
displayName: Deploy container app
|
|
|
|
- task: AzureCLI@2
|
|
inputs:
|
|
azureSubscription: $(serviceConnectionName)
|
|
scriptType: pscore
|
|
scriptLocation: inlineScript
|
|
inlineScript: |
|
|
$after = az containerapp show --name $(containerappName) -g $(resourceGroupName) --output json
|
|
Set-Content -Path $(diffFolder)/after.json -Value $after
|
|
displayName: Snapshot configuration (after)
|
|
|
|
# git diff will set the exit code to 1, since the files are different, we have to manually set it back to 0
|
|
- powershell: |
|
|
$diff = git diff before.json after.json
|
|
$LASTEXITCODE = 0
|
|
Set-Content -Path diff -Value $diff
|
|
displayName: Diff configuration snapshots
|
|
workingDirectory: $(diffFolder)
|
|
|
|
- publish: $(diffFolder)
|
|
displayName: Upload snapshot diff
|
|
artifact: DeploymentDiff
|
|
|
|
- stage: TestPCS
|
|
displayName: Run E2E Product Construction Service Tests
|
|
dependsOn:
|
|
- DeployPCS
|
|
|
|
jobs:
|
|
- template: /eng/templates/jobs/e2e-pcs-tests.yml
|
|
parameters:
|
|
name: scenarioTests_GitHub
|
|
displayName: GitHub tests
|
|
testFilter: 'TestCategory=GitHub'
|
|
|
|
- template: /eng/templates/jobs/e2e-pcs-tests.yml
|
|
parameters:
|
|
name: scenarioTests_AzDO
|
|
displayName: AzDO tests
|
|
testFilter: 'TestCategory=AzDO'
|
|
|
|
- template: /eng/templates/jobs/e2e-pcs-tests.yml
|
|
parameters:
|
|
name: scenarioTests_Other
|
|
displayName: Other tests
|
|
testFilter: 'TestCategory!=GitHub&TestCategory!=AzDO'
|