-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
291 lines (271 loc) · 6.55 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
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
stages:
- scan
- push
- pages
- release
cache: &global_cache
key:
files:
- package-lock.json
paths:
- .npm/
Prettier:
stage: scan
tags:
- docker
image: node:20.3.0-slim
cache:
<<: *global_cache
before_script:
- npm ci --cache .npm --prefer-offline
script:
- npm run format
only:
refs:
- merge_requests
ESLint:
stage: scan
tags:
- docker
image: node:20.3.0-slim
cache:
<<: *global_cache
before_script:
- npm ci --cache .npm --prefer-offline
script:
- npm run lint
only:
refs:
- merge_requests
StyleLint:
stage: scan
tags:
- docker
image: node:20.3.0-slim
cache:
<<: *global_cache
before_script:
- npm ci --cache .npm --prefer-offline
script:
- npm run lint:css
only:
refs:
- merge_requests
RemarkLint:
stage: scan
tags:
- docker
image: node:20.3.0-slim
cache:
<<: *global_cache
before_script:
- npm ci --cache .npm --prefer-offline
script:
- npm run lint:md
only:
refs:
- merge_requests
CheckTypo:
stage: scan
tags:
- docker
image: node:20.3.0-slim
cache:
<<: *global_cache
before_script:
- npm ci --cache .npm --prefer-offline
script:
- npm run check:spell
only:
refs:
- merge_requests
Test:
stage: scan
tags:
- docker
image: node:20.3.0-slim
cache:
<<: *global_cache
before_script:
- npm ci --cache .npm --prefer-offline
script:
- npm run test:ci
only:
refs:
- merge_requests
sync-repositories:
stage: push
tags:
- docker
image: bitnami/git
script:
# prepare remote repositories
- git remote set-url origin https://gitlab-ci-token:$GITLAB_TOKEN@${CI_REPOSITORY_URL##*@}
- git config remote.github.url >&- && git remote set-url github https://$GITHUB_USERNAME:[email protected]/fixstars/amplify-benchmark-viewer.git || git remote add github https://$GITHUB_USERNAME:[email protected]/fixstars/amplify-benchmark-viewer.git
- git config user.email "[email protected]"
- git config user.name "GitLab Bot"
- git fetch github main
- git fetch origin main gitlab_main
# git rebase --abort when git rebase exists
- >
if [[ -d "$(git rev-parse --git-path rebase-merge)" || -d "$(git rev-parse --git-path rebase-apply)" ]]; then
echo "Rebase in progress, aborting..."
git rebase --abort
echo "Rebase aborted."
else
echo "No rebase in progress."
fi
- git switch -C gitlab_main origin/gitlab_main
- git clean -xfd
# rebase and push
- git status
- git rebase github/main
- git push origin gitlab_main -f
- git push origin gitlab_main:main -f
- git push github gitlab_main:main
- git push --follow-tags github
rules:
- if: '$CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "gitlab_main" || $CI_COMMIT_TAG =~ /^v\d+.\d+.\d+/'
check_schema:
stage: scan
tags:
- docker
image: node:20.3.0-slim
cache:
<<: *global_cache
before_script:
- npm ci --cache .npm --prefer-offline
script:
- apt-get update -y
- apt-get install git -y
- npx json2ts ./schema/report_data.json > src/@types/report_data.d.ts --style.singleQuote --style.trailingComma=all --no-style.semi
- >
if [[ $(git diff --name-only HEAD | grep 'src/@types/report_data.d.ts' || echo '') != "" ]]; then
RED="\e[31m"
END_COLOR="\e[0m"
echo ""
echo -e "${RED}###########################################################${END_COLOR}"
echo -e "${RED}# The report_data.d.ts of the report page do not match. #${END_COLOR}"
echo -e "${RED}# Please npx json2ts report_data.json before committing. #${END_COLOR}"
echo -e "${RED}###########################################################${END_COLOR}"
echo ""
exit 1
fi
only:
refs:
- merge_requests
scan_secrets:
stage: scan
tags:
- docker
image: golang:latest
script:
- git clone -b v3.41.1 https://github.com/trufflesecurity/trufflehog.git
- cd trufflehog; go install
- cd ..
- rm -rf trufflehog
- trufflehog git file://. --only-verified --fail --no-update --since-commit=main
only:
refs:
- merge_requests
test_pages:
stage: pages
tags:
- docker
image: node:20.3.0-slim
cache:
<<: *global_cache
before_script:
- npm ci --cache .npm --prefer-offline
script:
- npm run build
artifacts:
paths:
- dist
only:
- merge_requests
Check_license:
stage: scan
tags:
- docker
image: bitnami/git
script:
- bash add_license_to_files.sh
- >
if [[ $(git diff --name-only HEAD | grep -e src/ || echo '') != "" ]]; then
RED="\e[31m"
END_COLOR="\e[0m"
echo ""
echo -e "${RED}######################################################################${END_COLOR}"
echo -e "${RED}# Some of the files in the src folder do not have the LICENSE block. #${END_COLOR}"
echo -e "${RED}# Please sh add_license_to_files.sh before committing. #${END_COLOR}"
echo -e "${RED}######################################################################${END_COLOR}"
echo ""
exit 1
fi
only:
refs:
- merge_requests
.build: &build
tags:
- docker
image: node:20.3.0-slim
cache:
<<: *global_cache
before_script:
- npm ci --cache .npm --prefer-offline
script:
- npm run build
- cp -rp dist/* public
artifacts:
paths:
- public
pages:
stage: pages
<<: *build
only:
- gitlab_main
build_for_release:
stage: release
tags:
- docker
image: node:20.3.0-slim
cache:
<<: *global_cache
before_script:
- npm ci --cache .npm --prefer-offline
script:
- bash add_google_analytics_tag.sh
- npm run build
- cp -rp dist/* public
artifacts:
paths:
- public
only:
refs:
- tags
variables:
- $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+.*/
release:
stage: release
tags:
- docker
image: registry.gitlab.com/gitlab-org/release-cli:latest
needs:
- job: build_for_release
artifacts: true
script:
- echo "running release for $CI_COMMIT_TAG"
release:
name: '$CI_COMMIT_TAG'
description: 'Release $CI_COMMIT_TAG'
tag_name: '$CI_COMMIT_TAG'
assets:
links:
- name: 'build result'
url: 'https://gitlab.fixstars.com/$CI_PROJECT_PATH/-/jobs/artifacts/$CI_COMMIT_TAG/download?job=build_for_release'
only:
refs:
- tags
variables:
- $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+.*/