@@ -18,6 +18,8 @@ variables:
18
18
# gitlab checkout
19
19
DOCS_REPO_NAME : documentation
20
20
REPO_URL : " https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.ddbuild.io/DataDog/${DOCS_REPO_NAME}.git"
21
+ # yarn/node cache dirs
22
+ YARN_CACHE_FOLDER : " ${CI_PROJECT_DIR}/.yarn/cache/"
21
23
22
24
# ================== copy scripts =============== #
23
25
before_script :
@@ -27,11 +29,27 @@ before_script:
27
29
- " [ -f /etc/profile ] && source /etc/profile" # for golang on path
28
30
- mkdir -p logs
29
31
30
- cache : &cache
31
- key : $CI_COMMIT_REF_SLUG-$CI_PROJECT_DIR
32
- paths :
33
- - node_modules/
34
- - tmp/.htmltest/
32
+ # set policy for the common case
33
+ # yarn cache is used in a lot but only built during build job so lets default to pull and explicit push in build job
34
+ .yarn_cache : &yarn_cache
35
+ - key :
36
+ files :
37
+ - yarn.lock
38
+ paths :
39
+ - package.json
40
+ - yarn.lock
41
+ - ${YARN_CACHE_FOLDER}
42
+ policy : pull
43
+
44
+ .yarn_cache_pull_push : &yarn_cache_pull_push
45
+ - key :
46
+ files :
47
+ - yarn.lock
48
+ paths :
49
+ - package.json
50
+ - yarn.lock
51
+ - ${YARN_CACHE_FOLDER}
52
+ policy : pull-push
35
53
36
54
# ================== templates ================== #
37
55
.base_template : &base_template
@@ -43,35 +61,13 @@ cache: &cache
43
61
only :
44
62
- branches
45
63
46
- # ================== Install Node Dependencies ================== #
47
- install_dependencies :
48
- << : *base_template
49
- stage : bootstrap
50
- cache :
51
- << : *cache
52
- variables :
53
- GIT_STRATEGY : none
54
- script :
55
- - git version
56
- - git clone --branch $CI_COMMIT_REF_NAME --depth 1 --filter=blob:none --no-checkout $REPO_URL sparse-docs
57
- - cd sparse-docs && git sparse-checkout init --cone && git sparse-checkout set local && git checkout $CI_COMMIT_REF_NAME && cd ..
58
- - mkdir -p ./local/bin/sh && cp --remove-destination ./sparse-docs/local/bin/sh/preinstall.sh ./local/bin/sh/preinstall.sh
59
- - cp --remove-destination ./sparse-docs/package.json ./package.json
60
- - cp --remove-destination ./sparse-docs/yarn.lock ./yarn.lock
61
- - yarn install --link-duplicates --frozen-lockfile --cache-folder .yarn
62
- - rm -rf ./sparse-docs # cleanup runner
63
- only :
64
- changes :
65
- - yarn.lock
66
-
67
64
# ================== preview ================== #
68
65
# If the branch has a name of <slack-user>/<feature-name> then ci builds a preview site
69
66
build_preview :
70
67
<< : *base_template
71
68
stage : build
72
69
cache :
73
- << : *cache
74
- policy : pull
70
+ - *yarn_cache_pull_push
75
71
environment : " preview"
76
72
variables :
77
73
URL : ${PREVIEW_DOMAIN}
@@ -81,6 +77,7 @@ build_preview:
81
77
LOCAL : " False"
82
78
script :
83
79
- post_dd_event "documentation deploy ${CI_COMMIT_REF_NAME} started" "${CI_PROJECT_URL}/pipelines/${CI_PIPELINE_ID}" "info"
80
+ - yarn install --immutable
84
81
- touch Makefile.config
85
82
- make BRANCH=${CI_COMMIT_REF_NAME} examples
86
83
- sync_integration_descriptions
@@ -156,11 +153,11 @@ index_algolia_preview:
156
153
tags : ["runner:main"]
157
154
stage : post-deploy
158
155
cache :
159
- << : *cache
160
- policy : pull
156
+ - *yarn_cache
161
157
environment : " preview"
162
158
timeout : 1h 30m
163
159
script :
160
+ - yarn install --immutable
164
161
- |-
165
162
echo APPLICATION_ID=$(get_secret 'ci.documentation.algolia_preview_application_id') > .env
166
163
echo API_KEY=$(get_secret 'ci.documentation.algolia_preview_api_key') >> .env
@@ -178,10 +175,10 @@ replica_algolia_preview:
178
175
<< : *base_template
179
176
stage : post-deploy
180
177
cache :
181
- << : *cache
182
- policy : pull
178
+ - *yarn_cache
183
179
environment : " preview"
184
180
script :
181
+ - yarn install --immutable
185
182
- ALGOLIA_APP_ID=$(get_secret 'algolia_preview_application_id') ALGOLIA_ADMIN_KEY=$(get_secret 'algolia_preview_api_key') yarn run algolia:config
186
183
dependencies :
187
184
- build_preview
@@ -194,10 +191,10 @@ sourcemaps_preview:
194
191
<< : *base_template
195
192
stage : post-deploy
196
193
cache :
197
- << : *cache
198
- policy : pull
194
+ - *yarn_cache
199
195
environment : " preview"
200
196
script :
197
+ - yarn install --immutable
201
198
# Rename any js.map files to include SHA if correlating JS file is fingerprinted. Hugo's asset build system seems to lose the fingerprint value when generating source maps.
202
199
- find ./public -type f -name "*.*.js" -exec bash -c 'x={}; hash=$(basename $x | cut -d '.' -f 2); map=${x/$hash./}.map; mv $map ${map/.js/.$hash.js}' \;
203
200
- DATADOG_API_KEY="$(get_secret 'dd-api-key')" ./node_modules/.bin/datadog-ci sourcemaps upload ./public/static --service docs --minified-path-prefix "https://docs-staging.datadoghq.com/${CI_COMMIT_REF_NAME}/static/" --release-version "${CI_COMMIT_SHORT_SHA}"
@@ -213,8 +210,7 @@ build_live:
213
210
<< : *base_template
214
211
stage : build
215
212
cache :
216
- << : *cache
217
- policy : pull
213
+ - *yarn_cache_pull_push
218
214
environment : " live"
219
215
variables :
220
216
CONFIG : ${LIVE_CONFIG}
@@ -225,6 +221,7 @@ build_live:
225
221
script :
226
222
- post_dd_event "documentation deploy ${CI_COMMIT_REF_NAME} started" "${CI_PROJECT_URL}/pipelines/${CI_PIPELINE_ID}" "info"
227
223
- notify_slack "<https://github.com/DataDog/documentation/commit/${CI_COMMIT_SHA}|${CI_COMMIT_SHA:0:8}> sent to gitlab for production deployment. <${CI_PROJECT_URL}/pipelines/${CI_PIPELINE_ID}|details>" "#FFD700"
224
+ - yarn install --immutable
228
225
- touch Makefile.config
229
226
- make clean-examples
230
227
- make examples
@@ -295,11 +292,11 @@ index_algolia:
295
292
tags : ["runner:main"]
296
293
stage : post-deploy
297
294
cache :
298
- << : *cache
299
- policy : pull
295
+ - *yarn_cache
300
296
environment : " live"
301
297
timeout : 1h 30m
302
298
script :
299
+ - yarn install --immutable
303
300
- |-
304
301
echo APPLICATION_ID=$(get_secret 'ci.documentation.algolia_docsearch_application_id') > .env
305
302
echo API_KEY=$(get_secret 'ci.documentation.algolia_docsearch_api_key') >> .env
@@ -315,10 +312,10 @@ replica_algolia:
315
312
<< : *base_template
316
313
stage : post-deploy
317
314
cache :
318
- << : *cache
319
- policy : pull
315
+ - *yarn_cache
320
316
environment : " live"
321
317
script :
318
+ - yarn install --immutable
322
319
- ALGOLIA_APP_ID=$(get_secret 'algolia_docsearch_application_id') ALGOLIA_ADMIN_KEY=$(get_secret 'algolia_docsearch_api_key') yarn run algolia:config
323
320
dependencies :
324
321
- build_live
@@ -329,10 +326,10 @@ sourcemaps_live:
329
326
<< : *base_template
330
327
stage : post-deploy
331
328
cache :
332
- << : *cache
333
- policy : pull
329
+ - *yarn_cache
334
330
environment : " live"
335
331
script :
332
+ - yarn install --immutable
336
333
# Rename any js.map files to include SHA if correlating JS file is fingerprinted. Hugo's asset build system seems to lose the fingerprint value when generating source maps.
337
334
- find ./public -type f -name "*.*.js" -exec bash -c 'x={}; hash=$(basename $x | cut -d '.' -f 2); map=${x/$hash./}.map; mv $map ${map/.js/.$hash.js}' \;
338
335
- DATADOG_API_KEY="$(get_secret 'dd-api-key')" ./node_modules/.bin/datadog-ci sourcemaps upload ./public/static --service docs --minified-path-prefix "https://docs.datadoghq.com/static/" --release-version "${CI_COMMIT_SHORT_SHA}"
@@ -412,12 +409,12 @@ test_pa11y:
412
409
<< : *base_template
413
410
stage : post-deploy
414
411
cache :
415
- << : *cache
416
- policy : pull
412
+ - *yarn_cache
417
413
environment : " live"
418
414
dependencies :
419
415
- build_live
420
416
script :
417
+ - yarn install --immutable
421
418
- node ./local/bin/js/pa11y.js --env live --dd_api_key $(get_secret 'dd-api-key')
422
419
only :
423
420
- schedules
0 commit comments