Repository navigation
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
247 lines (213 loc) · 5.97 KB
/
Copy path.gitlab-ci.yml
File metadata and controls
247 lines (213 loc) · 5.97 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
# Note: This GitLab CI configuration is used for internal testing, users can ignore it.
include:
- project: '${CI_PROJECT_NAMESPACE}/ci-libs-for-client-libraries'
file:
- '/${CI_PROJECT_NAME}/.gitlab-ci.yml'
- project: 'deepl-org/deepl/devex/gitlab-ci-lib'
file:
- '/templates/.secret-detection.yml'
- template: Security/SAST.gitlab-ci.yml
# Global --------------------------
# Use Active LTS (22)
image: node:22-alpine
workflow:
rules:
# The tag pipeline must run: that is where the registry publish job fires.
- if: $CI_COMMIT_TAG
# The release commit carries only the version and the changelog, both
# derived from commits that were already checked on the way in.
- if: $CI_COMMIT_MESSAGE =~ /^chore\(release\):/
when: never
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
cache:
key:
files:
- package.json
- package-lock.lock
paths:
- node_modules/
stages:
- check
- build
- test
- publish
before_script:
- npm install
variables:
GITLAB_ADVANCED_SAST_ENABLED: 'true'
# stage: check ----------------------
.eslint_base:
stage: check
script:
- npm run lint
eslint_scheduled:
extends: .eslint_base
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
retry: 2
eslint_manual:
extends: .eslint_base
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"
.audit_base:
stage: check
script:
- npm audit --production
# Suppressing NPM audit failures on dev dependencies due to CVE-2022-25883
# in semver <7.5.2, used by test dependencies.
# See: https://github.com/npm/node-semver/pull/564
# Currently npm audit fix cannot resolve this issue.
- npm audit || echo "Suppressing npm audit failures for dev dependencies"
audit_scheduled:
extends: .audit_base
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
retry: 2
audit_manual:
extends: .audit_base
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"
.format_base:
stage: check
script:
- npm run format
format_scheduled:
extends: .format_base
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
retry: 2
format_manual:
extends: .format_base
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"
secret_detection:
extends: .secret-detection
stage: check
image: !reference [.secret-detection, image]
before_script:
- echo "overriding default before_script..."
rules:
- if: $CI_MERGE_REQUEST_ID
gitlab-advanced-sast:
stage: check
rules:
- when: always
before_script:
- ''
variables:
SAST_EXCLUDED_PATHS: '$DEFAULT_SAST_EXCLUDED_PATHS'
GIT_STRATEGY: clone
semgrep-sast:
stage: check
rules:
- when: always
before_script:
- ''
variables:
SAST_EXCLUDED_PATHS: '$DEFAULT_SAST_EXCLUDED_PATHS'
GIT_STRATEGY: clone
# stage: build ----------------------
build:
stage: build
script:
- npm run clean
- npm run build
artifacts:
paths:
- dist
# stage: test ----------------------
.test_offline_base:
stage: test
variables:
KUBERNETES_MEMORY_LIMIT: 8Gi
parallel:
matrix:
- DOCKER_IMAGE: 'node:16-alpine'
- DOCKER_IMAGE: 'node:17-alpine'
- DOCKER_IMAGE: 'node:18-alpine'
- DOCKER_IMAGE: 'node:20-alpine'
- DOCKER_IMAGE: 'node:22-alpine'
- DOCKER_IMAGE: 'node:24-alpine'
image: ${DOCKER_IMAGE}
script:
- npm run test:offline -- --coverage --reporters="default" --reporters="jest-junit" --maxWorkers=5
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage/clover.xml
junit:
- junit.xml
when: always
test_offline_scheduled:
extends: .test_offline_base
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
retry: 2
test_offline_manual:
extends: .test_offline_base
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"
# Every endpoint once against the real API; no retry, as a retry repeats every request.
.test_real_api_base:
stage: test
extends: .test
variables:
KUBERNETES_MEMORY_LIMIT: 8Gi
image: node:24-alpine
script:
- npm run test:real-api -- --coverage --reporters="default" --reporters="jest-junit"
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage/clover.xml
junit:
- junit.xml
when: always
test_real_api_scheduled:
extends: .test_real_api_base
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
test_real_api_manual:
extends: .test_real_api_base
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"
.examples_base:
stage: test
extends: .test
image: node:24-alpine
before_script: # Note: replaces global before_script
- npm install --production
script:
- cd $CI_PROJECT_DIR/examples/commonjs
- npm install
- node index.js
- cd $CI_PROJECT_DIR/examples/esmodule
- npm install
- node index.js
- cd $CI_PROJECT_DIR/examples/typescript
- npm install
- npm run build
- node index.js
examples_scheduled:
extends: .examples_base
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
retry: 2
examples_manual:
extends: .examples_base
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"
# stage: publish ----------------------
publish to NPM:
stage: publish
extends: .publish
dependencies:
- build
rules:
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/'
script:
- npm config set //registry.npmjs.org/:_authToken ${NPM_PUBLISH_TOKEN}
- npm publish