-
Notifications
You must be signed in to change notification settings - Fork 22
/
.gitlab-ci.yml
182 lines (161 loc) · 3.83 KB
/
.gitlab-ci.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
image: ${CODE_REGISTRY}/devops/images/usgs/ng-cli-e2e:latest
include:
- project: 'ghsc/hazdev/pipeline-build-template'
ref: '1.1.5'
file: 'templates/library.yml'
- template: 'Workflows/Branch-Pipelines.gitlab-ci.yml'
stages:
- install
- test
- build
- deploy
variables:
CI_REGISTRY: ${CODE_REGISTRY}
CI_REGISTRY_IMAGE: ${CODE_REGISTRY_IMAGE}
DOCKER_DRIVER: overlay2
IMAGE_NAME: ${CI_PROJECT_NAME}:${CI_COMMIT_REF_SLUG}
## --------------------------------------------------
# Templates
## --------------------------------------------------
.adjust_image_names:
before_script:
- IMAGE_NAME=${IMAGE_NAME/:master/:latest}
- INTERNAL_IMAGE_NAME=${CI_REGISTRY_IMAGE}/${IMAGE_NAME}
.deploy:
cache: {}
extends:
- .adjust_image_names
image: ${CODE_REGISTRY}/ghsc/hazdev/container-deploy:latest
parallel:
matrix:
- APP_NAME: earthquake-eventpages
BASE_HREF: earthquakes/eventpage
EVENT_TYPE: actual
STACK_NAME: earthquake-eventpages
- APP_NAME: scenario-eventpages
BASE_HREF: scenarios/eventpage
EVENT_TYPE: scenario
STACK_NAME: scenario-eventpages
script:
- export REGISTRY=${CI_REGISTRY_IMAGE}
- cp -v
/container-deploy/default.config.sh
/container-deploy/default.funcs.sh
/container-deploy/deploy.sh
scripts/.
- scripts/deploy.sh
stage: deploy
tags:
- deploy
- swarm
## --------------------------------------------------
# install Stage
## --------------------------------------------------
Node Modules Installation:
artifacts:
paths:
- node_modules
expire_in: 1 week
stage: install
script:
- npm ci
tags:
- development
## --------------------------------------------------
# Test Stage
## --------------------------------------------------
Build Application:
script:
- npm run build
stage: test
tags:
- development
End to End Tests:
script:
# download version of chromedriver that matches installed version of chrome
- npx webdriver-manager update --versions.chrome=$(google-chrome --version | grep Chrome | awk '{ print $3}')
- npm run e2e
stage: test
tags:
- development
Lint:
script:
- npm run lint
stage: test
tags:
- development
NPM Audit:
allow_failure: true # fails due to outdated angular version
image: ${CODE_REGISTRY}/devops/images/usgs/node:12
script:
- npm audit --prod
stage: test
tags:
- development
Unit Tests:
artifacts:
reports:
cobertura: coverage/cobertura-coverage.xml
script:
- npm run test:ci
stage: test
tags:
- development
## --------------------------------------------------
# Build Stage
## --------------------------------------------------
Build Docker Image:
extends:
- .adjust_image_names
- .build
image: ${DEVOPS_REGISTRY}docker:19.03-git
rules:
- if: $CI_PROJECT_NAMESPACE == 'ghsc/hazdev'
when: on_success
- when: never
services:
- name: ${DEVOPS_REGISTRY}docker:19.03-dind
alias: docker
stage: build
variables:
DOCKER_BUILD_ARGS: |
BUILD_IMAGE=${CODE_REGISTRY}/devops/images/usgs/node:12
DOCKER_IMAGE=${IMAGE_NAME}
FROM_IMAGE=${CODE_REGISTRY}/devops/images/usgs/nginx:latest
GIT_BRANCH_NAME=${CI_COMMIT_REF_NAME}
GIT_COMMIT_SHA=${CI_COMMIT_SHA}
## --------------------------------------------------
# Deploy Stage
## --------------------------------------------------
Production01:
extends:
- .deploy
- .production-manual
tags:
- deploy
- swarm
- production01
Production02:
extends:
- .deploy
- .production-manual
tags:
- deploy
- swarm
- production02
Staging01:
extends:
- .deploy
- .staging
tags:
- deploy
- swarm
- staging01
Staging02:
extends:
- .deploy
- .staging
tags:
- deploy
- swarm
- staging02