-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
125 lines (125 loc) · 3.95 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
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' || $CI_PIPELINE_SOURCE == 'schedule' || $CI_PIPELINE_SOURCE == 'web'
# See https://docs.gitlab.com/ee/ci/yaml/workflow.html#switch-between-branch-pipelines-and-merge-request-pipelines
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS == null && $CI_COMMIT_BRANCH !~ /^docs\//
changes:
- .eslintrc
- .gitlab-ci.yml
- package{-lock,}.json
- packages/**/*
variables:
GIT_DEPTH: '5'
DEFAULT_NODE_VERSION: '16'
LINUX_DISTRO: bullseye
NPM_CONFIG_AUDIT: 'false'
NPM_CONFIG_CACHE: &npm_cache_dir .cache/npm
NPM_CONFIG_FUND: 'false'
NPM_CONFIG_PREFER_OFFLINE: 'true'
ENABLE_WINDOWS_JOB:
value: ''
description: Enter 1 to enable the Windows job. Note that the Windows job is automatically enabled if RELEASE_VERSION is specified.
RELEASE_VERSION:
value: ''
description: The version to release from the selected protected branch if the build succeeds. To enable, specify an exact version or increment keyword.
default:
image: node:$DEFAULT_NODE_VERSION-$LINUX_DISTRO
interruptible: true
.defs:
- &if_docs_mr
rules:
- if: &docs_mr $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME =~ /^docs\//
- &if_release_rule
if: $CI_PIPELINE_SOURCE == 'web' && $CI_PROJECT_PATH == 'antora/antora' && $CI_COMMIT_BRANCH && $CI_COMMIT_REF_PROTECTED && $RELEASE_VERSION
- &if_schedule_rule
if: $CI_PIPELINE_SOURCE == 'schedule' || ($CI_PIPELINE_SOURCE == 'web' && $CI_JOB_NAME == 'test:windows' && $ENABLE_WINDOWS_JOB)
- &if_release
rules:
- *if_release_rule
- &if_release_or_schedule
rules:
- *if_release_rule
- *if_schedule_rule
- &unless_docs_mr
rules:
- if: *docs_mr
when: never
- if: $CI_JOB_NAME == 'lint' && $CI_PIPELINE_SOURCE == 'push' && $CI_PROJECT_PATH != 'antora/antora'
when: manual
- when: on_success
- &platform_info node -p '`${os.type()} ${os.release()}\nNode.js ${process.version}`'
- &save_report_artifacts
artifacts:
when: always
paths:
- reports/lcov-report
reports:
coverage_report:
coverage_format: cobertura
path: reports/cobertura-coverage.xml
junit: reports/tests-xunit.xml
.npm:
stage: test
<<: *if_release_or_schedule
before_script:
- *platform_info
- npm ci --audit --quiet
cache: &npm_cache
key: npm-cache
paths:
- *npm_cache_dir
policy: pull
script: npm test
# this job signals success to the MR UI
docs:
stage: test
<<: *if_docs_mr
script: echo 'we love docs!'
# this job also seeds the dependency cache
lint:
extends: .npm
stage: .pre
<<: *unless_docs_mr
cache:
<<: *npm_cache
policy: pull-push
script:
- npm run deps
- npm run lint
- if [ -n "$(npm --silent run format && git --no-pager diff --name-only)" ]; then git --no-pager diff && false; fi
test:node-16-linux:
extends: .npm
<<: *unless_docs_mr
script: npm run coverage
coverage: '/^All files *[|] *([0-9.]+) *[|]/'
<<: *save_report_artifacts
test:node-18-linux:
extends: .npm
image: node:18-$LINUX_DISTRO
<<: *unless_docs_mr
test:macos:
extends: .npm
image: macos-12-xcode-14
tags: [saas-macos-medium-m1]
<<: *unless_docs_mr
# https://gitlab.com/gitlab-org/ci-cd/shared-runners/images/gcp/windows-containers/-/blob/main/cookbooks/preinstalled-software/README.md
test:windows:
extends: .npm
tags: [windows]
# cache does not currently work with the shared Windows runner
cache: []
before_script:
- choco upgrade -y nodejs --version=16.17.0
- *platform_info
- npm ci --quiet
script: npm run coverage
<<: *save_report_artifacts
release:
stage: deploy
interruptible: false
environment: releases
<<: *if_release
script:
- npm/release.sh
# NOTE docker-antora only has a single branch, so the ref will always be main for now
- env $(echo -en $(cat releaserc)) sh -c 'curl -o /dev/null -s -X POST -F "token=$CI_JOB_TOKEN" -F "ref=main" -F "variables[ANTORA_VERSION]=$RELEASE_VERSION" $DOCKER_IMAGE_PIPELINE_TRIGGER'