-
Notifications
You must be signed in to change notification settings - Fork 6
/
azure-pipelines.yml
197 lines (193 loc) · 8.12 KB
/
azure-pipelines.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
name: Volley Management-3.0$(Rev:.r)
variables:
docker_repository_name: sdiachen/volleymanagement
sln_path: ./src/VolleyManagement.sln
trigger:
batch: true
branches:
include:
- master
paths:
exclude:
- docs/*
- dev-env/*
- archive/*
pr:
autoCancel: true
branches:
include:
- master
stages:
- stage: build
displayName: Build
jobs:
- job: build_code
pool:
vmImage: "ubuntu-latest"
displayName: "Source Code"
steps:
- template: build/azure-pipeline/setup-dotnet-cli.yml
parameters:
version: 8.0.100
# Need to set this var for the build to avoid Specflow issue https://github.com/SpecFlowOSS/SpecFlow/issues/1912
- script: echo "##vso[task.setvariable variable=MSBUILDSINGLELOADCONTEXT;]1"
- task: DotNetCoreCLI@2
displayName: .net build
inputs:
command: "build"
projects: $(sln_path)
arguments: "-c Release -o $(Build.ArtifactStagingDirectory)"
- task: DotNetCoreCLI@2
displayName: .net test
inputs:
command: "test"
testRunTitle: "Unit Tests"
projects: $(sln_path)
arguments: "--filter Category=unit"
- publish: $(Build.SourcesDirectory)/tests/unit-tests #note: files which are published controlled by .artifactignore file
artifact: unitTestsResults
condition: succeededOrFailed() #publish even if tests failed - it is useful for debugging
- pwsh: ./migrations/publish-azure-storage-migration.ps1
displayName: Prepare Azure Storage migration
- publish: $(Build.SourcesDirectory)/migrations/azure-storage-migrations
artifact: azureStorageMigration
- job: container_build
displayName: Container
dependsOn: build_code
pool:
vmImage: "ubuntu-latest"
steps:
- template: build/azure-pipeline/set-docker-tag.yml
- task: Docker@2
displayName: Docker Build and Push
inputs:
containerRegistry: "VM on Personal DockerHub"
repository: $(docker_repository_name)
command: "buildAndPush"
Dockerfile: "./Dockerfile"
buildContext: "."
tags: $(image_tag)
- stage: integration
displayName: "Integration"
dependsOn: build
jobs:
- job: integration_test
displayName: Integration Tests
pool:
vmImage: "ubuntu-latest"
steps:
- template: build/azure-pipeline/setup-dotnet-cli.yml
parameters:
version: 8.0.100
# Need to set this var for the build to avoid Specflow issue https://github.com/SpecFlowOSS/SpecFlow/issues/1912
# - script: echo "##vso[task.setvariable variable=MSBUILDSINGLELOADCONTEXT;]1"
- script: |
echo "##vso[task.setvariable variable=VOLLEYM_TESTTARGET;]AzureCloud"
echo "##vso[task.setvariable variable=VOLLEYM_IDENTITYCONTEXTTABLESTORAGEOPTIONS__CONNECTIONSTRING;]$(vm_azstorage_connection_string_staging)"
echo "##vso[task.setvariable variable=VOLLEYM_PLAYERSCONTEXTTABLESTORAGEOPTIONS__CONNECTIONSTRING;]$(vm_azstorage_connection_string_staging)"
- task: DotNetCoreCLI@2
displayName: .NET test
inputs:
command: "test"
testRunTitle: "Azure Cloud Integration Tests"
projects: $(sln_path)
arguments: "--filter Category=azurecloud -- xunit.maxParallelThreads=1 -v n"
- publish: $(Build.SourcesDirectory)/tests/unit-tests #note: files which are published controlled by .artifactignore file
artifact: integrationTestsResults
condition: succeededOrFailed() #publish even if tests failed - it is useful for debugging
- job: azure_storage_migrations
displayName: Run Azure Storage Migrations
pool:
vmImage: "ubuntu-latest"
steps:
- download: current
artifact: azureStorageMigration
- template: build/azure-pipeline/setup-dotnet-cli.yml
parameters:
version: 8.0.100
- pwsh: |
cd $(Pipeline.Workspace)/azureStorageMigration
dotnet VolleyM.Tools.MigrationTool.dll
displayName: Run migration
env:
VOLLEYM_MIGRATION_ENVIRONMENTNAME: Staging
VOLLEYM_MIGRATION_IDENTITYCONTEXTTABLESTORAGEOPTIONS__CONNECTIONSTRING: $(vm_azstorage_connection_string_staging)
VOLLEYM_MIGRATION_PLAYERSCONTEXTTABLESTORAGEOPTIONS__CONNECTIONSTRING: $(vm_azstorage_connection_string_staging)
- job: deploy_app_service_int
displayName: Deploy App Service
pool:
vmImage: "ubuntu-latest"
dependsOn:
- azure_storage_migrations
steps:
- template: build/azure-pipeline/set-docker-tag.yml
- task: AzureWebAppContainer@1
displayName: "Deploy App Service"
inputs:
azureSubscription: staging-v3-arm
appName: "staging-volley-mgmt"
containers: "$(docker_repository_name):$(image_tag)"
appSettings: >-
-ASPNETCORE_ENVIRONMENT Staging
-IDENTITYCONTEXTTABLESTORAGEOPTIONS__CONNECTIONSTRING $(vm_azstorage_connection_string_staging)
-PLAYERSCONTEXTTABLESTORAGEOPTIONS__CONNECTIONSTRING $(vm_azstorage_connection_string_staging)
- job: run_api_tests
displayName: API Tests
pool:
vmImage: "ubuntu-latest"
dependsOn:
- deploy_app_service_int
steps:
- task: UniversalPackages@0
displayName: "Download Karate from Artifacts"
inputs:
command: download
vstsFeed: "VolleyManagement"
vstsFeedPackage: "karate"
vstsPackageVersion: "0.9.6-rc2-final"
downloadDirectory: "$(Agent.ToolsDirectory)/karate/"
- script: |
java -jar $(Agent.ToolsDirectory)/karate/karate.jar -e staging .
env:
VM_KARATE_AUTH0_CLIENT_SECRET: $(vm_api_tests_auth0_secret)
displayName: "Run Karate tests"
- stage: deploy_prod
displayName: "Deploy Production"
dependsOn: integration
condition: and(succeeded(), eq(0, variables['System.PullRequest.PullRequestId']), eq(variables['Build.SourceBranchName'], 'master'))
jobs:
- job: azure_storage_migrations
displayName: Run Azure Storage Migrations
pool:
vmImage: "ubuntu-latest"
steps:
- download: current
artifact: azureStorageMigration
- template: build/azure-pipeline/setup-dotnet-cli.yml
parameters:
version: 8.0.100
- pwsh: |
cd $(Pipeline.Workspace)/azureStorageMigration
dotnet VolleyM.Tools.MigrationTool.dll
displayName: Run migration
env:
VOLLEYM_MIGRATION_ENVIRONMENTNAME: Production
VOLLEYM_MIGRATION_IDENTITYCONTEXTTABLESTORAGEOPTIONS__CONNECTIONSTRING: $(vm_azstorage_connection_string_production)
VOLLEYM_MIGRATION_PLAYERSCONTEXTTABLESTORAGEOPTIONS__CONNECTIONSTRING: $(vm_azstorage_connection_string_production)
- job: deploy_app_service_prod
displayName: Deploy App Service
pool:
vmImage: "ubuntu-latest"
dependsOn: azure_storage_migrations
steps:
- template: build/azure-pipeline/set-docker-tag.yml
- task: AzureWebAppContainer@1
displayName: "Deploy App Service"
inputs:
azureSubscription: prod-v3-arm
appName: "volley-prod"
containers: "$(docker_repository_name):$(image_tag)"
appSettings: >-
-ASPNETCORE_ENVIRONMENT Production
-IDENTITYCONTEXTTABLESTORAGEOPTIONS__CONNECTIONSTRING $(vm_azstorage_connection_string_production)
-PLAYERSCONTEXTTABLESTORAGEOPTIONS__CONNECTIONSTRING $(vm_azstorage_connection_string_production)