This repository has been archived by the owner on Mar 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
azure-pipelines.yml
150 lines (140 loc) · 4.96 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
name: $(BuildID)
trigger:
batch: false
branches:
include:
- '*'
tags:
include:
- '*'
pr:
autoCancel: true
branches:
include:
- '*'
variables:
DOCKER_IMAGE_NAME: 'nhsuk/$(PROJECT_NAME)'
GITHUB_REPO_NAME: 'nhsuk/$(PROJECT_NAME)'
PROJECT_NAME: 'sexual-health-service-finder'
VAULT_SERVER: 'vault.nhswebsite.nhs.uk'
PERF_TEST_DURATION: 600
PERF_TEST_RAMPUP: 60
PERF_TEST_THROUGHPUT: 30
PERF_TEST_USER_COUNT: 10
PERF_TEST_AVG_RESPONSE_THRESHOLD: 600
PERF_TEST_PCT_CHECK: 90
PERF_TEST_PCT_THRESHOLD: 1000
stages:
- stage: build
jobs:
- job: RunTests
displayName: 'Run tests and publish results including code coverage'
pool:
vmImage: 'Ubuntu 16.04'
variables:
COVERALLS_SERVICE_NAME: 'Azure Devops'
steps:
- bash: |
./scripts/devops/run-ci-tests
env:
COVERALLS_REPO_TOKEN: $(COVERALLS_REPO_TOKEN)
displayName: 'Run tests, copy test artifacts to host and upload code coverage'
- task: PublishCodeCoverageResults@1
condition: succeededOrFailed()
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(System.DefaultWorkingDirectory)/coverage/cobertura-coverage.xml'
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testRunner: JUnit
testResultsFiles: '$(System.DefaultWorkingDirectory)/test-results.xml'
- job: PushImageToRepo
dependsOn: RunTests
condition: and(succeeded(), or(startsWith(variables['Build.SourceBranch'], 'refs/heads/master'), startsWith(variables['Build.SourceBranch'], 'refs/pull/'), startsWith(variables['Build.SourceBranch'], 'refs/tags/')))
displayName: 'Push image to repository'
pool:
vmImage: 'Ubuntu 16.04'
steps:
- task: Docker@1
displayName: 'Login to Docker Hub'
inputs:
containerregistrytype: 'Container Registry'
dockerRegistryEndpoint: 'sexual-health'
command: login
- bash: ./scripts/devops/push-image
displayName: 'Push image to Docker Hub'
- job: PublishRancherConfig
dependsOn: RunTests
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
displayName: 'Publish Rancher config for use in deployment to Production'
pool:
vmImage: 'Ubuntu 16.04'
steps:
- publish: $(System.DefaultWorkingDirectory)/rancher-config/
artifact: rancher-config
- job: PublishScripts
dependsOn: RunTests
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
displayName: 'Publish scripts so they can be used in deployment to Production'
pool:
vmImage: 'Ubuntu 16.04'
steps:
- publish: $(System.DefaultWorkingDirectory)/scripts/devops/
artifact: scripts
- stage: deployReviewEnvironment
displayName: 'Deploy to Review Environment'
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/pull/'))
dependsOn: build
jobs:
- job: DeployReviewEnvironment
displayName: 'Deploy to Review Environment'
pool:
vmImage: 'Ubuntu 16.04'
variables:
RELEASE_ENVIRONMENTNAME: 'dev'
steps:
- bash: ./scripts/devops/deploy-environment
env:
VAULT_TOKEN: $(VAULT_TOKEN)
displayName: 'Deploy Environment'
- stage: deployIntEnvironment
displayName: 'Deploy to Int Environment'
dependsOn: build
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
jobs:
- job: DeployIntEnvironment
displayName: 'Deploy to Int Environment'
pool:
vmImage: 'Ubuntu 16.04'
variables:
RELEASE_ENVIRONMENTNAME: 'dev'
steps:
- bash: ./scripts/devops/deploy-environment
env:
VAULT_TOKEN: $(VAULT_TOKEN)
displayName: 'Deploy Environment'
- stage: deployStagingEnvironment
displayName: 'Deploy to Staging Environment'
dependsOn: build
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
jobs:
- job: DeployStagingEnvironment
displayName: 'Deploy to Staging Environment'
pool:
vmImage: 'Ubuntu 16.04'
variables:
RELEASE_ENVIRONMENTNAME: 'staging'
PERF_TEST_HOSTNAME: nhswebsite-staging.nhs.uk
steps:
- bash: ./scripts/devops/deploy-environment
env:
VAULT_TOKEN: $(VAULT_TOKEN)
displayName: 'Deploy Environment'
- bash: ./scripts/devops/run-performance-tests
displayName: 'Run Performance Tests'
- bash: ./scripts/devops/check-performance-test-results
displayName: 'Check Performance Test Results'
- publish: ./test/performance/dashboards
artifact: 'Performance Test Dashboard'
displayName: 'Publish Performance Test Results'