-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
executable file
·375 lines (348 loc) · 10.9 KB
/
.gitlab-ci.yml
File metadata and controls
executable file
·375 lines (348 loc) · 10.9 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
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
---
variables:
DEFAULT_LOCALE: en
.staging:
variables: &staging
FIREBASE_DOMAIN: https://staging.adblockplus.dev/
PREVIEW_CHANNEL_EXPIRATION: 30d
.production:
variables: &production
DOMAIN: adblockplus.org
FIREBASE_DOMAIN: https://www.adblockplus.dev/
.images:
node: &NODE_IMAGE node:16-alpine
cloud_sdk: &GOOGLE_CLOUD_SDK_IMAGE google/cloud-sdk:409.0.0
build: &BUILD_IMAGE registry.gitlab.com/eyeo/websites/docker/adblockinc-cms-202208.1:latest
default:
tags:
- "eyeo-small-runner"
stages:
- prebuild_firebase
- build_firebase
- deploy_cloud_run
- deploy_firebase
- test
pre_review_build:
stage: prebuild_firebase
except:
- master
- schedules
image: *NODE_IMAGE
before_script:
- npm install -g firebase-tools@11.13.0
- cp $GCP_SERVICE_ACCOUNT_CREDENTIALS ~/gcp.json
- export GOOGLE_APPLICATION_CREDENTIALS=~/gcp.json
script:
- cd services/firebase
- firebase use staging
- node ./prebuild_staging.mjs
after_script:
- rm -rf ~/gcp.json
artifacts:
reports:
dotenv: services/firebase/build.env
environment:
name: review/$CI_COMMIT_REF_SLUG
build:review:
stage: build_firebase
except:
- master
- schedules
variables:
<<: *staging
image: *BUILD_IMAGE
dependencies:
- pre_review_build
before_script:
- python3 -m pip install -q crudini
script:
- crudini --set settings.ini general siteurl "$REVIEW_URL"
- python3 -m cms.bin.generate_static_pages $PWD services/firebase/public
- python services/firebase/utils/html_extender.py services/firebase/public
# copy contents of default locale to base of public root (for firebase),
# this addresses getting canonical page if no language translation available
- cp -a services/firebase/public/$DEFAULT_LOCALE/. services/firebase/public/.
artifacts:
name: $CI_COMMIT_REF_SLUG
paths:
- services/firebase/public
build:review:staging:
stage: build_firebase
except:
- schedules
variables:
<<: *staging
image: *BUILD_IMAGE
before_script:
- python3 -m pip install -q crudini
script:
- crudini --set settings.ini general siteurl "$FIREBASE_DOMAIN"
- python3 -m cms.bin.generate_static_pages $PWD services/firebase/public
- python services/firebase/utils/html_extender.py services/firebase/public
# copy contents of default locale to base of public root (for firebase),
# this addresses getting canonical page if no language translation available
- cp -a services/firebase/public/$DEFAULT_LOCALE/. services/firebase/public/.
artifacts:
name: $CI_COMMIT_REF_SLUG
paths:
- services/firebase/public
only:
- master
build:production:
stage: build_firebase
except:
- schedules
variables:
<<: *production
image: *BUILD_IMAGE
before_script:
- python3 -m pip install -q crudini
script:
- crudini --set settings.ini general siteurl https://$DOMAIN
- python3 -m cms.bin.generate_static_pages $PWD services/firebase/public
- python services/firebase/utils/html_extender.py services/firebase/public
# copy contents of default locale to base of public root (for firebase),
# this addresses getting canonical page if no language translation available
- cp -a services/firebase/public/$DEFAULT_LOCALE/. services/firebase/public/.
artifacts:
name: $CI_COMMIT_REF_SLUG
paths:
- services/firebase/public
only:
- master
deploy_cloud_run:review:
stage: deploy_cloud_run
except:
- master
- schedules
image: *GOOGLE_CLOUD_SDK_IMAGE
before_script:
- gcloud auth activate-service-account --key-file $GCP_SERVICE_ACCOUNT_CREDENTIALS
- gcloud config set project $GCP_PROJECT_ID
script:
- cd services/cloudrun
- gcloud builds submit --tag europe-west1-docker.pkg.dev/$GCP_PROJECT_ID/$GCP_PROJECT_ID/$CI_COMMIT_REF_SLUG
- gcloud run deploy b-$CI_COMMIT_REF_SLUG --image europe-west1-docker.pkg.dev/$GCP_PROJECT_ID/$GCP_PROJECT_ID/$CI_COMMIT_REF_SLUG:latest --region europe-west1 --allow-unauthenticated
environment:
name: review/$CI_COMMIT_REF_SLUG
on_stop: teardown_cloud_run:review
auto_stop_in: 30d
teardown_cloud_run:review:
stage: deploy_cloud_run
except:
- master
- schedules
image: *GOOGLE_CLOUD_SDK_IMAGE
dependencies: []
before_script:
- gcloud auth activate-service-account --key-file $GCP_SERVICE_ACCOUNT_CREDENTIALS
- gcloud config set project $GCP_PROJECT_ID
script:
- gcloud run services delete b-$CI_COMMIT_REF_SLUG --region europe-west1 --quiet
environment:
name: review/$CI_COMMIT_REF_SLUG
action: stop
when: manual
deploy_cloud_run:review:staging:
stage: deploy_cloud_run
except:
- schedules
image: *GOOGLE_CLOUD_SDK_IMAGE
before_script:
- gcloud auth activate-service-account --key-file $GCP_SERVICE_ACCOUNT_CREDENTIALS
- gcloud config set project $GCP_PROJECT_ID
script:
- cd services/cloudrun
- gcloud builds submit --tag europe-west1-docker.pkg.dev/$GCP_PROJECT_ID/$GCP_PROJECT_ID/$CI_COMMIT_REF_SLUG
- gcloud run deploy $CI_COMMIT_REF_SLUG --image europe-west1-docker.pkg.dev/$GCP_PROJECT_ID/$GCP_PROJECT_ID/$CI_COMMIT_REF_SLUG:latest --region europe-west1 --allow-unauthenticated
environment:
name: review/staging/$CI_COMMIT_REF_SLUG
only:
- master
deploy_cloud_run:production:
stage: deploy_cloud_run
except:
- schedules
image: *GOOGLE_CLOUD_SDK_IMAGE
before_script:
- gcloud auth activate-service-account --key-file $GCP_SERVICE_ACCOUNT_CREDENTIALS
- gcloud config set project $GCP_PROJECT_ID
script:
- cd services/cloudrun
- gcloud builds submit --tag europe-west1-docker.pkg.dev/$GCP_PROJECT_ID/$GCP_PROJECT_ID/$CI_COMMIT_REF_SLUG
- gcloud run deploy $CI_COMMIT_REF_SLUG --image europe-west1-docker.pkg.dev/$GCP_PROJECT_ID/$GCP_PROJECT_ID/$CI_COMMIT_REF_SLUG:latest --region europe-west1 --allow-unauthenticated
environment:
name: production/$CI_COMMIT_REF_SLUG
only:
- master
deploy_firebase_hosting:review:
stage: deploy_firebase
except:
- master
- schedules
image: *NODE_IMAGE
variables:
<<: *staging
dependencies:
- pre_review_build
- build:review
before_script:
- npm install -g firebase-tools@11.13.0
- npm install commander@"~9.4.0"
- npm install json5@"~2.2.1"
- cp $GCP_SERVICE_ACCOUNT_CREDENTIALS ~/gcp.json
- export GOOGLE_APPLICATION_CREDENTIALS=~/gcp.json
script:
- npm run rename-service-ids -- --input ./services/firebase/firebase.json --name b-$CI_COMMIT_REF_SLUG
- cd services/firebase
- firebase use staging
- firebase hosting:channel:deploy $CI_COMMIT_REF_SLUG --expires $PREVIEW_CHANNEL_EXPIRATION
after_script:
- rm -rf ~/gcp.json
environment:
name: review/$CI_COMMIT_REF_SLUG
url: $REVIEW_URL
on_stop: teardown_firebase_hosting:review
teardown_firebase_hosting:review:
stage: deploy_firebase
except:
- master
- schedules
image: *NODE_IMAGE
before_script:
- npm install -g firebase-tools@11.13.0
- cp $GCP_SERVICE_ACCOUNT_CREDENTIALS ~/gcp.json
- export GOOGLE_APPLICATION_CREDENTIALS=~/gcp.json
script:
- cd services/firebase
- firebase use staging
- firebase hosting:channel:delete $CI_COMMIT_REF_SLUG -f
environment:
name: review/$CI_COMMIT_REF_SLUG
action: stop
when: manual
deploy_firebase_hosting:review:staging:
stage: deploy_firebase
except:
- schedules
image:
*NODE_IMAGE
variables:
<<: *staging
dependencies:
- build:review:staging
before_script:
- npm install -g firebase-tools@11.13.0
- npm install commander@"~9.4.0"
- npm install json5@"~2.2.1"
- cp $GCP_SERVICE_ACCOUNT_CREDENTIALS ~/gcp.json
- export GOOGLE_APPLICATION_CREDENTIALS=~/gcp.json
script:
- npm run rename-service-ids -- --input ./services/firebase/firebase.json --name $CI_COMMIT_REF_SLUG
- cd services/firebase
- firebase use staging
- firebase deploy --only hosting
after_script:
- rm -rf ~/gcp.json
environment:
name: review/staging/$CI_COMMIT_REF_SLUG
url: $FIREBASE_DOMAIN
only:
- master
deploy_firebase_hosting:production:
stage: deploy_firebase
except:
- schedules
image: *NODE_IMAGE
variables:
<<: *production
dependencies:
- build:production
before_script:
- npm install -g firebase-tools@11.13.0
- npm install commander@"~9.4.0"
- npm install json5@"~2.2.1"
- cp $GCP_SERVICE_ACCOUNT_CREDENTIALS ~/gcp.json
- export GOOGLE_APPLICATION_CREDENTIALS=~/gcp.json
script:
- npm run rename-service-ids -- --input ./services/firebase/firebase.json --name $CI_COMMIT_REF_SLUG
- cd services/firebase
- firebase use production
- firebase deploy --only hosting
after_script:
- rm -rf ~/gcp.json
environment:
name: production/$CI_COMMIT_REF_SLUG
url: $FIREBASE_DOMAIN
only:
- master
# ============================================================================
# TEST JOBS
# ============================================================================
.playwright-artifacts: &playwright-artifacts
artifacts:
when: always
paths:
- test-results/
- playwright-report/
expire_in: 1 week
.playwright-base: &playwright-base
stage: test
image: mcr.microsoft.com/playwright:v1.53.2-jammy
before_script:
- npm ci
- export CI_RUN=1
<<: *playwright-artifacts
# This only works with TEST_ARGS that do not contain quotes
.playwright-test-script: &playwright-test-script
|-
if [ -z "${REVIEW_URL}" ]; then
echo "${CI_JOB_NAME} will run on getadblock.com"
npx playwright test ${TEST_ARGS} --retries=0
else
echo "${CI_JOB_NAME} will run on ${REVIEW_URL}"
STAGING=1 STAGING_URL=${REVIEW_URL} npx playwright test ${TEST_ARGS} --retries=0
fi
chromium_tests:
<<: *playwright-base
tags:
- eyeo-medium-runner
except:
- schedules
script:
- npx playwright install --with-deps
- |-
if [ -z "${REVIEW_URL}" ]; then
echo "The tests will run on Chromium on adblockplus.org"
npx playwright test --project chromium --grep-invert "@third_party_link|@all_browsers|@visual_regression" --retries=0
else
echo "The tests will run on Chromium using ${REVIEW_URL}"
STAGING=1 STAGING_URL=${REVIEW_URL} npx playwright test --project chromium --grep-invert "@third_party_link|@all_browsers|@visual_regression" --retries=0
fi
browser_tests:
<<: *playwright-base
except:
- schedules
variables:
TEST_ARGS: '--grep @all_browsers'
script:
- npx playwright install chrome msedge --with-deps
- *playwright-test-script
visual_regression_tests:
<<: *playwright-base
variables:
TEST_ARGS: '--project chromium --grep @visual_regression'
when: manual
allow_failure: true
script:
- npx playwright install --with-deps
- *playwright-test-script
all_website_tests:
<<: *playwright-base
only:
- schedules
tags:
- eyeo-medium-runner
script:
- npx playwright install chrome msedge --with-deps
- npx playwright test