-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy path.gitlab-ci.yml
216 lines (195 loc) · 5.89 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
image: docker
variables:
DOCKER_DRIVER: overlay2
GIT_SUBMODULE_STRATEGY: recursive
ADAPT_RUN_LONG_TESTS: 1
ADAPT_TEST_HEAPDUMP: 1
# Be explicit about the default Node version for jobs that don't specify
ADAPT_TEST_NODE_VERSION: "12"
# This is for certs to be shared between docker client and dind. Must match
# a volume mount path in gitlab runner's config.toml.
DOCKER_TLS_CERTDIR: "/certs"
ADAPT_BUILD_LOGDIR: build/logs
ADAPT_CI_REPORT: 1
services:
- name: docker:stable-dind
command: [ "dockerd", "--host=unix:///var/run/docker.sock", "--host=tcp://0.0.0.0:2376", "--host=tcp://0.0.0.0:2375", "--storage-driver=overlay2" ]
stages:
- build
- test
- release
- publish
before_script:
- mkdir -p "$ADAPT_BUILD_LOGDIR"
- apk update && apk add bash git moreutils
- ./bin/dnsmasq
- |
if [ "${DOCKER_AUTH_CONFIG}" = "" ]; then
echo No DOCKER_AUTH_CONFIG CI variable set in Gitlab web UI
exit 1
fi
- |
if [ "${CI_PROJECT_PATH}" = "unboundedsystems/adapt" -a -z "$ADAPT_UNIT_TEST_GCLOUD_SVCACCT_JSON" ]; then
echo No ADAPT_UNIT_TEST_GCLOUD_SVCACCT_JSON set for main unboundedsystems/adapt CI
exit 1
fi
- . ./bin/setup-docker-auth.sh
# Resource monitor logging
- echo "Time CPU Rd Wr Mem eth0" > "${ADAPT_BUILD_LOGDIR}/system_resource.log"
- nohup nmeter "%t %c %b %[mf] %[neth0]" >> "${ADAPT_BUILD_LOGDIR}/system_resource.log" &
# In order to fool make into not re-building in the test stages, save the
# .install_success files (from artifacts) that make uses and run yarn here.
- |
if [[ -f node_modules/.install_success ]]; then
tar -cf temp.tar node_modules/.install_success */node_modules/.install_success
./bin/yarn
tar -xf temp.tar
rm temp.tar
fi
# Set timestamps for all source files to earlier than now so make doesn't
# rebuild due to timestamps
- git ls-files -z | xargs -0 touch -d '2020-01-01 00:00'
# Job parameters common to all jobs except build stage
.job_common: &job_common
artifacts:
name: "$CI_COMMIT_REF_NAME-$CI_JOB_NAME-$CI_JOB_ID"
paths:
- "$ADAPT_BUILD_LOGDIR"
when: always
expire_in: 30 days
# Job to test build and do checks
build:
stage: build
only:
- branches
- web
- schedules
variables:
ADAPT_TEST_NODE_VERSION: "12"
script:
- |
bash -o pipefail -c './bin/make build check-uncommitted lint web-test \
|& tee >(ts > "${ADAPT_BUILD_LOGDIR}/test${ADAPT_TEST_NODE_VERSION}_make_output.log")'
artifacts:
name: "$CI_COMMIT_REF_NAME-$CI_JOB_NAME-$CI_JOB_ID"
paths:
- "$ADAPT_BUILD_LOGDIR"
- "*/dist"
- "*/build/docs"
- ".doctoc-updated"
- "core/generated"
- "node_modules/.install_success"
- "*/node_modules/.install_success"
when: always
expire_in: 30 days
# Job definition used for testing different versions of Node
# Must also set the ADAPT_TEST_NODE_VERSION variable to the desired Node version
.node_version_test_job: &node_version_test_job
stage: test
only:
- branches
- web
- schedules
script:
- |
bash -o pipefail -c './bin/make ${MAKE_TARGETS} \
|& tee >(ts > "${ADAPT_BUILD_LOGDIR}/test${ADAPT_TEST_NODE_VERSION}_make_output.log")'
dependencies: ["build"]
test-cli:12:
<<: *job_common
<<: *node_version_test_job
variables:
ADAPT_TEST_NODE_VERSION: "12"
MAKE_TARGETS: "cli-test"
test-cloud:12:
<<: *job_common
<<: *node_version_test_job
variables:
ADAPT_TEST_NODE_VERSION: "12"
MAKE_TARGETS: "cloud-test"
test-core:12:
<<: *job_common
<<: *node_version_test_job
variables:
ADAPT_TEST_NODE_VERSION: "12"
MAKE_TARGETS: "core-test"
test-systemtest:12:
<<: *job_common
<<: *node_version_test_job
variables:
ADAPT_TEST_NODE_VERSION: "12"
MAKE_TARGETS: "systemtest-test"
test-other:12:
<<: *job_common
<<: *node_version_test_job
variables:
ADAPT_TEST_NODE_VERSION: "12"
MAKE_TARGETS: "dom-parser-test testutils-test utils-test"
test-cli:14:
<<: *job_common
<<: *node_version_test_job
variables:
ADAPT_TEST_NODE_VERSION: "14"
MAKE_TARGETS: "cli-test"
test-cloud:14:
<<: *job_common
<<: *node_version_test_job
variables:
ADAPT_TEST_NODE_VERSION: "14"
MAKE_TARGETS: "cloud-test"
test-core:14:
<<: *job_common
<<: *node_version_test_job
variables:
ADAPT_TEST_NODE_VERSION: "14"
MAKE_TARGETS: "core-test"
test-systemtest:14:
<<: *job_common
<<: *node_version_test_job
variables:
ADAPT_TEST_NODE_VERSION: "14"
MAKE_TARGETS: "systemtest-test"
test-other:14:
<<: *job_common
<<: *node_version_test_job
variables:
ADAPT_TEST_NODE_VERSION: "14"
MAKE_TARGETS: "dom-parser-test testutils-test utils-test"
release:
<<: *job_common
stage: release
only:
# Only run the release job if:
# - the pipeline was kicked off manually
# - ADAPT_RELEASE_TYPE is set (during manual trigger)
refs:
- web
variables:
- $ADAPT_RELEASE_TYPE
variables:
ADAPT_RELEASE_TESTS: 1
script:
# Confirm correct setup:
# - there's a GitLab personal access token in the environment (token must
# have write access to the adapt repo)
# - there's an NPM token in the enviroment (token must have write
# access to publish the Adapt packages)
- |
if [ -z "${ADAPT_WEB_TOKEN}" ]; then printf "\n\nERROR: ADAPT_WEB_TOKEN must be set\n\n"; exit 1; fi
if [ -z "${ADAPT_NPM_TOKEN}" ]; then printf "\n\nERROR: ADAPT_NPM_TOKEN must be set\n\n"; exit 1; fi
- ./scripts/ci/checkout_branch.sh
- ./bin/make release
dependencies: ["build"]
docs:
<<: *job_common
stage: publish
only:
refs:
- master@unboundedsystems/adapt
# Only run the publish job if there's a personal access token in the
# environment. The token must have write access to the adapt-web repo.
variables:
- $ADAPT_WEB_TOKEN
script:
- ./bin/make web-release-master
dependencies: ["build"]