Skip to content

Commit

Permalink
[Rollout] Production rollout 2024-09-25 (#4002)
Browse files Browse the repository at this point in the history
  • Loading branch information
MilenaHristova authored Sep 25, 2024
2 parents 8539a5e + 4f96b7f commit b8af96a
Show file tree
Hide file tree
Showing 11 changed files with 568 additions and 294 deletions.
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<PackageVersion Include="Azure.Identity" Version="1.12.0" />
<PackageVersion Include="Azure.Monitor.OpenTelemetry.AspNetCore" Version="1.0.0" />
<PackageVersion Include="Azure.Monitor.OpenTelemetry.Exporter" Version="1.1.0" />
<PackageVersion Include="Azure.ResourceManager.AppContainers" Version="1.3.0" />
<PackageVersion Include="Azure.Security.KeyVault.Keys" Version="4.6.0" />
<PackageVersion Include="Azure.Security.KeyVault.Secrets" Version="4.6.0" />
<PackageVersion Include="Azure.Storage.Queues" Version="12.19.1" />
Expand Down
15 changes: 15 additions & 0 deletions arcade-services.sln
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProductConstructionService.
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProductConstructionService.ScenarioTests", "test\ProductConstructionService.ScenarioTests\ProductConstructionService.ScenarioTests.csproj", "{12D91D30-EC50-4D2B-8D67-0C19FCD2303F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProductConstructionService.Deployment", "src\ProductConstructionService\ProductConstructionService.Deployment\ProductConstructionService.Deployment.csproj", "{A4125B78-593D-4659-AA28-0E176D4644E5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -707,6 +709,18 @@ Global
{12D91D30-EC50-4D2B-8D67-0C19FCD2303F}.Release|x64.Build.0 = Release|Any CPU
{12D91D30-EC50-4D2B-8D67-0C19FCD2303F}.Release|x86.ActiveCfg = Release|Any CPU
{12D91D30-EC50-4D2B-8D67-0C19FCD2303F}.Release|x86.Build.0 = Release|Any CPU
{A4125B78-593D-4659-AA28-0E176D4644E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A4125B78-593D-4659-AA28-0E176D4644E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A4125B78-593D-4659-AA28-0E176D4644E5}.Debug|x64.ActiveCfg = Debug|Any CPU
{A4125B78-593D-4659-AA28-0E176D4644E5}.Debug|x64.Build.0 = Debug|Any CPU
{A4125B78-593D-4659-AA28-0E176D4644E5}.Debug|x86.ActiveCfg = Debug|Any CPU
{A4125B78-593D-4659-AA28-0E176D4644E5}.Debug|x86.Build.0 = Debug|Any CPU
{A4125B78-593D-4659-AA28-0E176D4644E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A4125B78-593D-4659-AA28-0E176D4644E5}.Release|Any CPU.Build.0 = Release|Any CPU
{A4125B78-593D-4659-AA28-0E176D4644E5}.Release|x64.ActiveCfg = Release|Any CPU
{A4125B78-593D-4659-AA28-0E176D4644E5}.Release|x64.Build.0 = Release|Any CPU
{A4125B78-593D-4659-AA28-0E176D4644E5}.Release|x86.ActiveCfg = Release|Any CPU
{A4125B78-593D-4659-AA28-0E176D4644E5}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -762,6 +776,7 @@ Global
{B5833185-DD07-4C64-A4DA-D8290294F7E7} = {243A4561-BF35-405A-AF12-AC57BB27796D}
{D94319F8-FCA0-495B-8B6E-190B4EEBEF93} = {1A456CF0-C09A-4DE6-89CE-1110EED31180}
{12D91D30-EC50-4D2B-8D67-0C19FCD2303F} = {1A456CF0-C09A-4DE6-89CE-1110EED31180}
{A4125B78-593D-4659-AA28-0E176D4644E5} = {243A4561-BF35-405A-AF12-AC57BB27796D}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {32B9C883-432E-4FC8-A1BF-090EB033DD5B}
Expand Down
255 changes: 146 additions & 109 deletions azure-pipelines-product-construction-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,92 +55,8 @@ variables:
value: -dev

stages:
- stage: DeployPCS
displayName: Deploy Product Construction Service
dependsOn: []
jobs:
- job: DeployPCS
displayName: Deploy Product Construction Service
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') }}:
- ${{ if ne(variables['Build.SourceBranch'], 'refs/heads/production') }}:
- 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)

- task: AzureCLI@2
name: GetAuthInfo
displayName: Get PCS Token
inputs:
azureSubscription: $(authServiceConnection)
addSpnToEnvironment: true
scriptType: pscore
scriptLocation: inlineScript
inlineScript: |
# Fetch pcs token
$token = (az account get-access-token --resource "$(MaestroAppId)" | ConvertFrom-Json).accessToken
"##vso[task.setvariable variable=Token;isOutput=true;isSecret=true]$token"
- task: AzureCLI@2
inputs:
azureSubscription: $(serviceConnectionName)
scriptType: pscore
scriptLocation: scriptPath
scriptPath: $(Build.SourcesDirectory)/eng/deployment/product-construction-service-deploy.ps1
arguments: >
-subscriptionId $(subscriptionId)
-resourceGroupName $(resourceGroupName)
-containerappName $(containerappName)
-workspaceName $(containerappWorkspaceName)
-newImageTag $(DockerTag.newDockerImageTag)
-containerRegistryName $(containerRegistryName)
-imageName $(containerName)
-token $(GetAuthInfo.Token)
-containerjobNames '$(containerjobNames)'
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: BuildRepo
displayName: Build and Publish Repo
- stage: Build
displayName: Build
dependsOn: []
jobs:
- job: BuildAndPublish
Expand Down Expand Up @@ -179,33 +95,154 @@ stages:
-projects .\test\ProductConstructionService.ScenarioTests\ProductConstructionService.ScenarioTests.csproj
displayName: Build ScenarioTests
- powershell: >
.\eng\common\build.ps1
-restore
-build
-configuration $(BuildConfig)
-projects .\src\ProductConstructionService\ProductConstructionService.Deployment\ProductConstructionService.Deployment.csproj
displayName: Build ProductConsturctionService.Deployment
- publish: $(Build.SourcesDirectory)\artifacts\bin\ProductConstructionService.ScenarioTests\$(BuildConfig)\net8.0\publish
artifact: ProductConstructionService.ScenarioTests

- publish: $(Build.SourcesDirectory)\artifacts\packages\$(BuildConfig)\NonShipping
artifact: PackageArtifacts

- stage: TestPCS
displayName: Run E2E Product Construction Service Tests
dependsOn:
- DeployPCS
- BuildRepo
- publish: $(Build.SourcesDirectory)\artifacts\bin\ProductConstructionService.Deployment\$(BuildConfig)\net8.0
artifact: ProductConstructionService.Deployment

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'

- 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') }}:
- ${{ if ne(variables['Build.SourceBranch'], 'refs/heads/production') }}:
- 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.Deployment
artifact: ProductConstructionService.Deployment

- 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
- powershell: .\eng\common\build.ps1 -restore
displayName: Install .NET

# 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.Deployment/ProductConstructionService.Deployment.exe `
--subscriptionId $(subscriptionId) `
--resourceGroupName $(resourceGroupName) `
--containerRegistryName $(containerRegistryName) `
--containerAppName $(containerappName) `
--workspaceName $(containerappWorkspaceName) `
--containerJobNames $(containerjobNames) `
--newImageTag $(newDockerImageTag) `
--imageName $(containerName) `
--azCliPath "$(azCliPath)" `
--isCi true `
--entraAppId $(MaestroAppId)
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'
Loading

0 comments on commit b8af96a

Please sign in to comment.