-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathazure-pipelines.yml
More file actions
168 lines (162 loc) · 4.78 KB
/
azure-pipelines.yml
File metadata and controls
168 lines (162 loc) · 4.78 KB
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
# NestJS Example Azure DevOps Pipeline - https://github.com/LoganRupe/nestjs-example
# More info: https://aka.ms/yaml
variables:
- group: build-pipeline-vars
resources:
repositories:
- repository: ApiBuildScriptsRepo # The name used to reference this repository in the checkout step
type: github
endpoint: LoganRupe
name: LoganRupe/api-build-scripts
name: $(Date:yyyyMMdd)$(Rev:.r)
trigger:
- master
pool: Default
stages:
- stage: InstallStage
displayName: Install
jobs:
- job: PreInstallJob
displayName: Pre-Install
steps:
- task: DownloadSecureFile@1
displayName: Secure Download Development environment settings (.env)
inputs:
secureFile: $(ENV_FILENAME_DEV)
- task: CopyFiles@2
displayName: Copy environment settings to Source Folder
inputs:
SourceFolder: '$(Agent.TempDirectory)'
Contents: $(ENV_FILENAME_DEV)
TargetFolder: '$(Build.SourcesDirectory)'
overWrite: true
- task: DeleteFiles@1
displayName: 'Delete existing environment settings (.env)'
inputs:
contents: .env
- bash: mv $(ENV_FILENAME_DEV) .env
displayName: Rename environment settings file to corrent filename
- job: CleanJob
displayName: Clean Container Instances (docker-compose down)
dependsOn: [PreInstallJob]
steps:
- script: make clean
- job: InstallJob
displayName: Install
dependsOn: [CleanJob]
steps:
- script: make install
env:
CONTAINER_NAME_WORKER_SUFFIX: _d
- stage: DevBuildStage
displayName: Development Build
jobs:
- job: BuildJob
displayName: Build
steps:
- script: make build
env:
CONTAINER_NAME_WORKER_SUFFIX: _d
- stage: CodeVerificationStage
displayName: Code Verification (Lint, Audit, Unit Test)
jobs:
- job: LintJob
displayName: Lint
dependsOn: []
steps:
- script: make lint
env:
CONTAINER_NAME_WORKER_SUFFIX: _d
- job: AuditJob
displayName: Audit
dependsOn: []
steps:
- script: make audit
env:
CONTAINER_NAME_WORKER_SUFFIX: _d
- job: TestJob
displayName: Test (Unit Tests)
dependsOn: []
steps:
- script: make test
env:
CONTAINER_NAME_WORKER_SUFFIX: _d
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testRunner: JUnit
testResultsFiles: '**/junit.xml'
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/*coverage.xml'
reportDirectory: '$(System.DefaultWorkingDirectory)/**/coverage'
- stage: ProductionBuildStage
displayName: Production Build (image)
# and service)
jobs:
- job: ProdBuildContainerJob
displayName: Build Production Container (Docker Image)
steps:
- script: make build_container
# - job: ProdBuildServiceJob
# displayName: Build Production Service (docker-compose)
# steps:
# - script: make build_service
- stage: ValidateProductionStage
displayName: Validate Production (Start Service and API Test)
jobs:
- job: PreProdBuildJob
displayName: Pre-Build for Prod
steps:
- task: DownloadSecureFile@1
displayName: Secure Download Production environment settings (.env)
inputs:
secureFile: $(ENV_FILENAME_PROD)
- task: CopyFiles@2
displayName: Copy environment settings to Source Folder
inputs:
SourceFolder: '$(Agent.TempDirectory)'
Contents: $(ENV_FILENAME_PROD)
TargetFolder: '$(Build.SourcesDirectory)'
overWrite: true
- task: DeleteFiles@1
displayName: 'Delete existing environment settings (.env)'
inputs:
contents: .env
- bash: mv $(ENV_FILENAME_PROD) .env
displayName: Rename environment settings file to corrent filename
- job: ProdStartServiceJob
displayName: Start Production Service (docker-compose run)
dependsOn: [PreProdBuildJob]
steps:
- script: make start_container
env:
CONTAINER_NAME_SERVICE_SUFFIX: _d
- job: APIHealthCheckJob
displayName: API Health Check
dependsOn: [ProdStartServiceJob]
steps:
- checkout: ApiBuildScriptsRepo
- task: Bash@3
inputs:
filePath: API_health_checker.sh
arguments: $(API_HEALTH_CHECK_URL) $(API_HEALTH_CHECK_TIMEOUT)
continueOnError: true
- job: TestAPIJob
displayName: Test API (postman/newman)
dependsOn: APIHealthCheckJob
steps:
- script: make test_api
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testRunner: JUnit
testResultsFiles: '**/newman-report.xml'
- stage: CleanStage
displayName: Clean
jobs:
- job: CleanJob
displayName: Clean Container Instances (docker-compose down)
steps:
- script: make clean