forked from code-dot-org/code-dot-org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.drone.yml
295 lines (267 loc) · 8.69 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
---
kind: pipeline
name: unit
clone:
disable: true
steps:
- name: clone
image: docker:git
commands:
- git clone --branch $DRONE_SOURCE_BRANCH --depth 100 $DRONE_GIT_HTTP_URL .
- git reset --hard $DRONE_COMMIT
# Also 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
- name: verify-pr
image: joshlory/code-dot-org:0.10
pull: always
commands:
- |
if [ -z "$DRONE_PULL_REQUEST" ]; then
echo "Not a pull request."
exit 0
fi
# Check to see if PR is from fork. If so, exit, as the test run provides access to secrets.
- head_repo=$(curl -s "https://api.github.com/repos/code-dot-org/code-dot-org/pulls/$DRONE_PULL_REQUEST" | jq .head.repo.full_name)
- echo $head_repo
- |
if [ "$head_repo" != '"code-dot-org/code-dot-org"' ]; then
echo "Pull request is from fork $head_repo; exiting."
exit 1
fi
- name: restore-cache
image: plugins/s3-cache
settings:
pull: true
restore: true
filename: unit-tests-cache.tar
- name: unit-tests
image: joshlory/code-dot-org:0.10
pull: always
volumes:
- name: rbenv
path: /home/circleci/.rbenv
- name: mysql
path: /var/lib/mysql
environment:
CLOUDFRONT_KEY_PAIR_ID:
from_secret: CLOUDFRONT_KEY_PAIR_ID
CLOUDFRONT_PRIVATE_KEY:
from_secret: CLOUDFRONT_PRIVATE_KEY
CODECOV_TOKEN:
from_secret: CODECOV_TOKEN
commands:
# If running on EC2, get hostname from ec2 metadata
- hostname=$(curl -s --max-time 3 http://169.254.169.254/latest/meta-data/public-hostname || echo $DRONE_RUNNER_HOSTNAME); echo "Running on $hostname"
- 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:
pull: true
rebuild: true
filename: unit-tests-cache.tar
mount:
- /home/circleci/.rbenv
volumes:
- name: rbenv
temp: {}
- name: mysql
temp: {}
trigger:
branch:
- 'staging'
- 'staging-next'
event:
- pull_request
---
kind: pipeline
name: ui
clone:
disable: true
services:
- name: ui-tests-redis
image: redis
ports:
- 6379
steps:
- name: clone
image: docker:git
commands:
- git clone --branch $DRONE_SOURCE_BRANCH --depth 100 $DRONE_GIT_HTTP_URL .
- 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. We only do this for UI tests, not unit tests,
# since it disrupts Codecov pull request reports.
- git config user.name "Drone"
- git config user.email "[email protected]"
- git merge origin/$DRONE_TARGET_BRANCH
- name: verify-pr
image: joshlory/code-dot-org:0.10
pull: always
commands:
- |
if [ -z "$DRONE_PULL_REQUEST" ]; then
echo "Not a pull request."
exit 0
fi
# Check to see if PR is from fork. If so, exit, as the test run provides access to secrets.
- head_repo=$(curl -s "https://api.github.com/repos/code-dot-org/code-dot-org/pulls/$DRONE_PULL_REQUEST" | jq .head.repo.full_name)
- echo $head_repo
- |
if [ "$head_repo" != '"code-dot-org/code-dot-org"' ]; then
echo "Pull request is from fork $head_repo; exiting."
exit 1
fi
- name: restore-cache
image: plugins/s3-cache
settings:
pull: true
restore: true
- name: ui-tests
image: joshlory/code-dot-org:0.10
volumes:
- name: rbenv
path: /home/circleci/.rbenv
- name: mysql
path: /var/lib/mysql
environment:
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
SAUCE_USERNAME:
from_secret: SAUCE_USERNAME
SAUCE_ACCESS_KEY:
from_secret: SAUCE_ACCESS_KEY
commands:
# If running on EC2, get hostname from ec2 metadata
- hostname=$(curl -s --max-time 3 http://169.254.169.254/latest/meta-data/public-hostname || echo $DRONE_RUNNER_HOSTNAME); echo "Running on $hostname"
- 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:
pull: true
rebuild: true
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:
- 'staging'
- 'staging-next'
event:
- pull_request
---
# We run unit tests only on commits to staging to upload coverage reports.
kind: pipeline
name: staging-codecov
clone:
disable: true
steps:
- name: clone
image: docker:git
commands:
- git clone --branch $DRONE_SOURCE_BRANCH --depth 100 $DRONE_GIT_HTTP_URL .
- git reset --hard $DRONE_COMMIT
# Also 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
# Create empty commit with tag to force all tests to run
- git config user.name "Drone"
- git config user.email "[email protected]"
- git commit --allow-empty -m "[test all]"
- name: restore-cache
image: plugins/s3-cache
settings:
pull: true
restore: true
filename: staging-codecov-cache.tar
- name: unit-tests
image: joshlory/code-dot-org:0.10
pull: always
volumes:
- name: rbenv
path: /home/circleci/.rbenv
- name: mysql
path: /var/lib/mysql
environment:
CLOUDFRONT_KEY_PAIR_ID:
from_secret: CLOUDFRONT_KEY_PAIR_ID
CLOUDFRONT_PRIVATE_KEY:
from_secret: CLOUDFRONT_PRIVATE_KEY
CODECOV_TOKEN:
from_secret: CODECOV_TOKEN
commands:
# If running on EC2, get hostname from ec2 metadata
- hostname=$(curl -s --max-time 3 http://169.254.169.254/latest/meta-data/public-hostname || echo $DRONE_RUNNER_HOSTNAME); echo "Running on $hostname"
- 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
# Set this to current commit, which is the empty commit we created during the clone step with the "test all" tag
- export CIRCLE_SHA1=$(git rev-parse HEAD)
- /entrypoint.sh docker/unit_tests.sh
- name: update-cache
image: plugins/s3-cache
volumes:
- name: rbenv
path: /home/circleci/.rbenv
settings:
pull: true
rebuild: true
filename: staging-codecov-cache.tar
mount:
- /home/circleci/.rbenv
volumes:
- name: rbenv
temp: {}
- name: mysql
temp: {}
trigger:
branch:
- staging
event:
- push
---
kind: signature
hmac: 01ee6c1bbb77b26fa4056b0077f005ce737a8c5070ee7e50131c8adcc22f9c57
...