-
Notifications
You must be signed in to change notification settings - Fork 479
/
.drone.yml
298 lines (270 loc) · 8.94 KB
/
.drone.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
292
293
294
295
296
297
298
---
# Drone CI pipeline running at: https://drone.cdn-code.org/code-dot-org/code-dot-org/
#
# Docs here: https://docs.google.com/document/d/1Qls20xfNN6T_DErOMwVQOFJsxAEAdMWFHzBDIbxyUQQ/edit#heading=h.9bln2fv2lgqd
#
# NOTE: after making changes to this file, you'll need to sign them using
# `drone sign code-dot-org/code-dot-org --save`
kind: pipeline
type: docker
name: unit
clone:
disable: true
services:
- name: unit-tests-redis
image: redis
ports:
- 6379
steps:
- name: info
image: curlimages/curl
commands:
# If running on EC2, get hostname from ec2 metadata
- "IMDS_TOKEN=$(curl -s -X PUT http://169.254.169.254/latest/api/token -H \"X-aws-ec2-metadata-token-ttl-seconds: 21600\")"
- "hostname=$(curl -s -H \"X-aws-ec2-metadata-token: $IMDS_TOKEN\" http://169.254.169.254/latest/meta-data/public-hostname)"
- echo "Running on $hostname"
# We cache a clone of staging in the `cache-staging-clone` pipeline
- name: get-cached-staging
image: plugins/s3-cache
settings:
filename: cache-staging-clone.tar
endpoint: s3://cdo-drone
restore: true
debug: true
pull: true
mount:
- .
- name: checkout
image: bitnami/git
commands:
- git lfs install --skip-repo
# We should be in a cached git repo, but clone if the cache failed
- "[ -d .git ] || (echo 'WARNING: get-cached-staging failed: checkout will be SLOW and LFS $$$!' && git clone --branch $DRONE_BRANCH $DRONE_GIT_HTTP_URL .)"
# Checkout our target branch (=the PR)
- git fetch origin $DRONE_SOURCE_BRANCH
- git checkout $DRONE_SOURCE_BRANCH
- git pull
- git reset --hard $DRONE_COMMIT
# Fetch the target branch (which is staging for pull requests.) We need this for determining which tests to run based on changed files.
- git remote set-branches --add origin $DRONE_TARGET_BRANCH
- git fetch --depth 100 origin $DRONE_TARGET_BRANCH
# Merge so we're up-to-date with the target before running tests.
- git config user.name "Drone"
- git config user.email "drone-fake-user@code.org"
- git merge origin/$DRONE_TARGET_BRANCH
- name: restore-cache
image: plugins/s3-cache
settings:
endpoint: s3://cdo-drone
debug: true
pull: true
restore: true
filename: unit-tests-cache-ubuntu-20.tar
- name: unit-tests
# see: docker/dockerfiles/Dockerfile
image: codedotorg/code-dot-org:1.9.3
pull: always
volumes:
- name: rbenv
path: /home/circleci/.rbenv
- name: mysql
path: /var/lib/mysql
environment:
# Each Drone secret below must be explicitly written to locals.yml in /docker/unit_tests.sh
CLOUDFRONT_KEY_PAIR_ID:
from_secret: CLOUDFRONT_KEY_PAIR_ID
CLOUDFRONT_PRIVATE_KEY:
from_secret: CLOUDFRONT_PRIVATE_KEY
commands:
- sudo chown -R circleci:circleci .
# cache is restored to source directory, so we need to copy it into the right place
- cp -rn "$(pwd)/home/circleci/.rbenv" /home/circleci || true
- rm -rf "$(pwd)/home/circleci/.rbenv"
# Depended on by CircleUtils: https://github.com/code-dot-org/code-dot-org/blob/56c4061afb55432ba8ccecc72b5b960ebd9480aa/lib/cdo/circle_utils.rb#L19
- export CIRCLE_SHA1=$DRONE_COMMIT
- EXIT_CODE=0
- /entrypoint.sh docker/unit_tests.sh || EXIT_CODE=$?
- while pgrep bash >/dev/null; do echo "found bash process; keeping container alive"; sleep 20; done
- exit $EXIT_CODE
- name: update-cache
image: plugins/s3-cache
volumes:
- name: rbenv
path: /home/circleci/.rbenv
settings:
endpoint: s3://cdo-drone
debug: true
pull: true
rebuild: true
filename: unit-tests-cache-ubuntu-20.tar
mount:
- /home/circleci/.rbenv
volumes:
- name: rbenv
temp: {}
- name: mysql
temp: {}
trigger:
branch:
exclude:
- "production"
- "test"
- "levelbuilder"
event:
- pull_request
---
kind: pipeline
type: docker
name: ui
clone:
disable: true
services:
- name: ui-tests-redis
image: redis
ports:
- 6379
steps:
- name: info
image: curlimages/curl
commands:
# If running on EC2, get hostname from ec2 metadata
- "IMDS_TOKEN=$(curl -s -X PUT http://169.254.169.254/latest/api/token -H \"X-aws-ec2-metadata-token-ttl-seconds: 21600\")"
- "hostname=$(curl -s -H \"X-aws-ec2-metadata-token: $IMDS_TOKEN\" http://169.254.169.254/latest/meta-data/public-hostname)"
- echo "Running on $hostname"
# We cache a clone of staging in the `cache-staging-clone` pipeline
- name: get-cached-staging
image: plugins/s3-cache
settings:
filename: cache-staging-clone.tar
endpoint: s3://cdo-drone
restore: true
debug: true
pull: true
mount:
- .
- name: checkout
image: bitnami/git
commands:
- git lfs install --skip-repo
# We should be in a cached git repo, but clone if the cache failed
- "[ -d .git ] || (echo 'get-cached-staging failed: checkout will be SLOW and LFS $$$!' && git clone --branch $DRONE_BRANCH $DRONE_GIT_HTTP_URL .)"
# Checkout our target branch (the PR's branch).
- git fetch origin $DRONE_SOURCE_BRANCH
- git checkout $DRONE_SOURCE_BRANCH
- git pull
- git reset --hard $DRONE_COMMIT
# Also fetch the target branch (which is staging or staging-next for pull requests.) We need this for determining which tests to run based on changed files.
- git remote set-branches --add origin $DRONE_TARGET_BRANCH
- git fetch --depth 100 origin $DRONE_TARGET_BRANCH
# Merge so we're up-to-date with the target before running tests.
- git config user.name "Drone"
- git config user.email "drone-fake-user@code.org"
- git merge origin/$DRONE_TARGET_BRANCH
- name: restore-cache
image: plugins/s3-cache
settings:
endpoint: s3://cdo-drone
debug: true
pull: true
restore: true
filename: ui-tests-cache-ubuntu-20.tar
- name: ui-tests
# see: docker/dockerfiles/Dockerfile
image: codedotorg/code-dot-org:1.9.3
pull: always
volumes:
- name: rbenv
path: /home/circleci/.rbenv
- name: mysql
path: /var/lib/mysql
environment:
# Each Drone secret below must be explicitly written to locals.yml in /docker/ui_tests.sh
CLOUDFRONT_KEY_PAIR_ID:
from_secret: CLOUDFRONT_KEY_PAIR_ID
CLOUDFRONT_PRIVATE_KEY:
from_secret: CLOUDFRONT_PRIVATE_KEY
PROPERTIES_ENCRYPTION_KEY:
from_secret: PROPERTIES_ENCRYPTION_KEY
FIREBASE_NAME:
from_secret: FIREBASE_NAME
FIREBASE_SECRET:
from_secret: FIREBASE_SECRET
FIREBASE_SHARED_SECRET:
from_secret: FIREBASE_SHARED_SECRET
SAUCE_USERNAME:
from_secret: SAUCE_USERNAME
SAUCE_ACCESS_KEY:
from_secret: SAUCE_ACCESS_KEY
commands:
- sudo chown -R circleci:circleci .
# cache is restored to source directory, so we need to copy it into the right place
- cp -rn "$(pwd)/home/circleci/.rbenv" /home/circleci || true
# Depended on by CircleUtils: https://github.com/code-dot-org/code-dot-org/blob/56c4061afb55432ba8ccecc72b5b960ebd9480aa/lib/cdo/circle_utils.rb#L19
- export CIRCLE_SHA1=$DRONE_COMMIT
- EXIT_CODE=0
- /entrypoint.sh docker/ui_tests.sh || EXIT_CODE=$?
- while pgrep bash >/dev/null; do echo "found bash process; keeping container alive"; sleep 20; done
- exit $EXIT_CODE
- name: update-cache
image: plugins/s3-cache
volumes:
- name: rbenv
path: /home/circleci/.rbenv
settings:
endpoint: s3://cdo-drone
debug: true
pull: true
rebuild: true
filename: ui-tests-cache-ubuntu-20.tar
mount:
- /home/circleci/.rbenv
# Used to avoid re-seeding UI test data unless something changed - see cached_ui_test task in https://github.com/code-dot-org/code-dot-org/blob/staging/dashboard/lib/tasks/seed.rake
- dashboard/db/ui_test_data.hash
- dashboard/db/ui_test_data.sql
volumes:
- name: rbenv
temp: {}
- name: mysql
temp: {}
trigger:
branch:
exclude:
- "production"
- "test"
- "levelbuilder"
event:
- pull_request
---
# On push, cache a clone of staging to drone's S3 bucket.
# The staging cache reduces git bandwidth in PR pipelines.
kind: pipeline
type: docker
name: cache-staging-clone
clone:
disable: true
steps:
- name: clone
image: bitnami/git
commands:
- git lfs install
- git clone --branch $DRONE_BRANCH $DRONE_GIT_HTTP_URL .
- name: cache-staging-clone
image: plugins/s3-cache
settings:
filename: cache-staging-clone.tar
endpoint: s3://cdo-drone
rebuild: true
debug: true
pull: true
mount:
- .
trigger:
branch:
- "staging"
- "staging-next"
event:
- push
---
kind: signature
hmac: 5915b545321c2aef2d8e34bcb394aa9929c4b48eb9c54bfb4d3c561c61c12a12
...