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
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
|
image: registry.gitlab.com/gitlab-org/gitlab-docs:base
stages:
- build-images
- build
- test
- pre-deploy
- deploy
- post-deploy
#
# Pick the remote branch, by default master (see the Rakefile for more info)
#
variables:
BRANCH_EE: 'docs-fix-MR-links'
BRANCH_OMNIBUS: 'master'
BRANCH_RUNNER: 'master'
BRANCH_CHARTS: 'master'
BUNDLE_PATH__SYSTEM: 'false'
GIT_DEPTH: '20'
#
# Check Ruby version and install gems
#
before_script:
- ruby -v
- NOKOGIRI_USE_SYSTEM_LIBRARIES=1 bundle install --jobs 4 --path vendor
# Skip this job when it's invoked by a cross project pipeline. That will speed
# up the pipeline when a docs preview is triggered. The triggered pipeline is
# always a branch off master which should be green anyway. For more info:
# https://docs.gitlab.com/ee/development/writing_documentation.html#previewing-the-changes-live
.except_pipelines: &except_pipelines
except:
- pipelines
#
# Except stable branches (with names like '10.4', '11.2', etc.)
#
.except_stable: &except_stable
except:
- /^\d{1,2}\.\d{1,2}$/
#
# Retry a job automatically if it fails (2 times)
#
.retry: &retry
retry: 2
###############################################
# Build the website #
###############################################
.build_base: &build_base
stage: build
script:
- yarn install --cache-folder .yarn-cache
- bundle exec rake setup_git default
- bundle exec nanoc compile -VV
# Symlink all README.html to index.html so that we can have clean URLs
- for i in `find public -name README.html`; do ln -sf README.html $(dirname $i)/index.html; done
# Remove CE dir and symlink EE to CE
- if [ $CI_PIPELINE_SOURCE != 'pipeline' ]; then cd public && rm -rf ce && ln -s ee ce; fi
artifacts:
paths:
- public
expire_in: 1d
cache:
key:
files:
- Gemfile.lock
paths:
- vendor/ruby
<<: *retry
#
# Compile only on master and stable branches
#
compile_prod:
<<: *build_base
variables:
NANOC_ENV: 'production'
only:
- master
- /^\d{1,2}\.\d{1,2}$/
#
# Compile on all branches except master
#
compile_dev:
<<: *build_base
only:
- branches
except:
- master
- /^\d{1,2}\.\d{1,2}$/
###############################################
# Test the website #
###############################################
#
# Run rspec tests
#
rspec:
stage: test
script:
- bundle exec rspec
cache:
key:
files:
- Gemfile.lock
paths:
- vendor/ruby
<<: *except_pipelines
#
# Run JavaScript tests
#
jest:
stage: test
script:
- yarn install --cache-folder .yarn-cache
- yarn test
cache:
key:
files:
- Gemfile.lock
- yarn.lock
paths:
- vendor/ruby
- .yarn-cache/
<<: *except_pipelines
#
# Lint JavaScript
#
js_lint:
stage: test
script:
- yarn install --cache-folder .yarn-cache
- yarn eslint
- yarn prettier
cache:
key:
files:
- Gemfile.lock
- yarn.lock
paths:
- vendor/ruby
- .yarn-cache/
<<: *except_pipelines
#
# SCSS linting
#
scss_lint:
stage: test
script:
- bundle exec scss-lint
cache:
key:
files:
- Gemfile.lock
paths:
- vendor/ruby
<<: *except_pipelines
<<: *retry
#
# Yamllint of *.yml for .gitlab-ci.yml.
# This uses rules from project root `.yamllint`.
#
yaml_lint:
stage: test
image: sdesbure/yamllint:latest
before_script: []
dependencies: []
script:
- yamllint .gitlab-ci.yml content/_data
<<: *except_pipelines
###############################################
# Review Apps #
###############################################
#
# Deploy the Review App on a dev server
#
review:
stage: deploy
variables:
GIT_STRATEGY: none
dependencies:
- compile_dev
before_script: []
cache: {}
script:
# Rsync to the Pages dir
- rsync -av --delete public /srv/nginx/pages/$CI_COMMIT_REF_SLUG
# Remove public directory so that the next review app can run in a
# clean environment (limitation of the shell executor).
- rm -rf public
environment:
name: review/$CI_COMMIT_REF_SLUG
url: http://$CI_COMMIT_REF_SLUG.$APPS_DOMAIN
on_stop: review_stop
only:
- branches@gitlab-org/gitlab-docs
# Except master and stable branches
except:
- master
- /^\d{1,2}\.\d{1,2}$/
- /release-\d{1,2}-\d{1,2}/
tags:
- nginx
- review-apps
<<: *retry
#
# Stop the Review App
#
review_stop:
stage: deploy
variables:
GIT_STRATEGY: none
dependencies: []
artifacts: {}
before_script: []
cache: {}
script:
- rm -rf public /srv/nginx/pages/$CI_COMMIT_REF_SLUG
when: manual
environment:
name: review/$CI_COMMIT_REF_SLUG
action: stop
only:
- branches@gitlab-org/gitlab-docs
# Except master and stable branches
except:
- master
- /^\d{1,2}\.\d{1,2}$/
- /release-\d{1,2}-\d{1,2}/
tags:
- nginx
- review-apps
<<: *retry
###############################################
# GitLab Pages (production) #
###############################################
#
# Deploy to production with GitLab Pages
#
pages:
image: registry.gitlab.com/gitlab-org/gitlab-docs:latest
stage: deploy
variables:
GIT_STRATEGY: none
before_script: []
cache: {}
environment:
name: production
url: https://docs.gitlab.com
dependencies:
- compile_prod # Contains the public directory
script:
#
# We want to use the artifacts of the compile_prod job as
# the latest docs deployment, and the other versions are
# taken from /usr/share/nginx/html which are included in
# the image we pull from.
#
- mv /usr/share/nginx/html/1* public/
#
# Check the size before minifying
#
- du -sh public/
#
# Minify the assets of the resulting site. The single versions
# will be minified eventually when the minification propagates
# to all versions that are included in gitlab-docs:latest
# (around 12.7), but we also need to minify the content we
# pull from master. Currently, there's no way to exclude
# files or directories when minifying, so we minify the whole
# site (even the versions that are already minified).
# TODO: Move to top.
# When all versions are minified, we can move this script
# to run first and avoid minifying the already minified versions.
#
- /scripts/minify-assets.sh ./ public/
#
# Check the size after minifying
#
- du -sh public/
artifacts:
paths:
- public
expire_in: 1d
only:
- master@gitlab-org/gitlab-docs
<<: *retry
###############################################
# Docker images builds #
###############################################
#
# Reuse some common commands
#
.docker_prepare: &docker_prepare
image: docker:latest
services:
- docker:dind
before_script:
- docker info
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
<<: *retry
.scheduled_infrequent: &scheduled_infrequent
rules:
- if: '$PIPELINE_SCHEDULE_TIMING == "weekly" && $CI_PIPELINE_SOURCE == "schedule"'
#
# GitLab docs lint image containing all test tools
#
image:docs-lint:
<<: *docker_prepare
stage: build-images
variables:
IMAGE_NAME: $CI_REGISTRY_IMAGE:lint
DOCKERFILE: dockerfiles/Dockerfile.gitlab-docs-lint
script:
- docker build --build-arg CI_COMMIT_REF_NAME=${CI_COMMIT_REF_NAME} -t $IMAGE_NAME -f $DOCKERFILE .
- docker push $IMAGE_NAME
when: manual
#
# GitLab docs image
#
image:gitlab-docs-base:
<<: *docker_prepare
stage: build-images
variables:
IMAGE_NAME: $CI_REGISTRY_IMAGE:base
DOCKERFILE: dockerfiles/Dockerfile.gitlab-docs-base
script:
- docker build -t $IMAGE_NAME -f $DOCKERFILE .
- docker push $IMAGE_NAME
when: manual
#
# Helper Docker image containing all build dependencies.
# It must be rebuilt every time Gemfile and/or Gemfile.lock changes.
#
image:bootstrap:
<<: *docker_prepare
stage: build-images
variables:
IMAGE_NAME: $CI_REGISTRY_IMAGE:bootstrap
DOCKERFILE: dockerfiles/Dockerfile.bootstrap
script:
- docker build -t $IMAGE_NAME -f $DOCKERFILE .
- docker push $IMAGE_NAME
only:
refs:
- master
changes:
- "Gemfile*"
#
# Helper Docker image that builds the gitlab-docs website
#
image:builder-onbuild:
<<: *docker_prepare
stage: build-images
variables:
IMAGE_NAME: $CI_REGISTRY_IMAGE:builder-onbuild
DOCKERFILE: dockerfiles/Dockerfile.builder.onbuild
script:
- docker build -t $IMAGE_NAME -f $DOCKERFILE .
- docker push $IMAGE_NAME
when: manual
<<: *except_stable
#
# Helper Docker image that copies the final HTML files in a smaller image
# (no rubygems included)
#
image:nginx-onbuild:
<<: *docker_prepare
stage: build-images
variables:
IMAGE_NAME: $CI_REGISTRY_IMAGE:nginx-onbuild
DOCKERFILE: dockerfiles/Dockerfile.nginx.onbuild
script:
- docker build -t $IMAGE_NAME -f $DOCKERFILE .
- docker push $IMAGE_NAME
when: manual
<<: *except_stable
#
# Final Docker image containing a single version
# It is based on Dockerfile.single for each branch
#
image:docs-single:
<<: *docker_prepare
stage: pre-deploy
artifacts: {}
cache: {}
dependencies: []
variables:
NANOC_ENV: 'production'
IMAGE_NAME: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
DOCKERFILE: Dockerfile.$CI_COMMIT_REF_NAME
environment:
name: registry/$CI_COMMIT_REF_SLUG
script:
- docker build --build-arg NANOC_ENV=${NANOC_ENV} --build-arg CI_COMMIT_REF_NAME=${CI_COMMIT_REF_NAME} -t $IMAGE_NAME -f $DOCKERFILE .
- docker push $IMAGE_NAME
# Only branches with versions like 10.4
only:
- /^\d{1,2}\.\d{1,2}$/
except:
- tags
#
# Final Docker image containing all the archives
#
image:docs-archives:
<<: *docker_prepare
<<: *scheduled_infrequent
stage: pre-deploy
artifacts: {}
cache: {}
dependencies: []
variables:
IMAGE_NAME: $CI_REGISTRY_IMAGE:archives
environment:
name: registry/archives
script:
- docker build -t $IMAGE_NAME -f dockerfiles/Dockerfile.archives .
- docker push $IMAGE_NAME
#
# Build master containing the online archives and latest docs (on schedules)
#
image:docs-latest:
<<: *docker_prepare
<<: *scheduled_infrequent
stage: pre-deploy
artifacts: {}
cache: {}
dependencies: []
variables:
NANOC_ENV: 'production'
IMAGE_NAME: $CI_REGISTRY_IMAGE:latest
DOCKERFILE: Dockerfile.$CI_COMMIT_REF_NAME
environment:
name: registry/latest
script:
- docker build --build-arg NANOC_ENV=${NANOC_ENV} --build-arg CI_COMMIT_REF_NAME=${CI_COMMIT_REF_NAME} -t $IMAGE_NAME -f $DOCKERFILE .
- docker push $IMAGE_NAME
allow_failure: true
#
# Check for broken external links
# Set to be part of infrequent pipeline
#
test_external_links:
stage: test
script:
- bundle exec nanoc check external_links
allow_failure: true
cache:
key:
files:
- Gemfile.lock
paths:
- vendor/ruby
#
# Check for broken internal links
# Set to be part of infrequent pipeline
#
test_internal_links_and_anchors:
<<: *scheduled_infrequent
stage: test
script:
- bundle exec nanoc check internal_links
- bundle exec nanoc check internal_anchors
cache:
key:
files:
- Gemfile.lock
paths:
- vendor/ruby
|