/
config.yml
313 lines (280 loc) · 9.69 KB
/
config.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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
# THIS FILE WAS AUTOMATICALLY GENERATED.
# Please edit src/config.tpl file instead.
# Open edX
# Docker containers CI
version: 2
# Templates
defaults: &defaults # We use the machine executor, i.e. a VM, not a container
machine:
# Cache docker layers so that we strongly speed up this job execution
# This cache will be available to future jobs (although because jobs run
# in parallel, CircleCI does not guarantee that a given job will see a
# specific version of the cache. See documentation for details)
docker_layer_caching: true
working_directory: ~/fun
build_steps: &build_steps
steps:
# Checkout openedx-docker sources
- checkout
# Login to DockerHub with encrypted credentials stored as secret
# environment variables (set in CircleCI project settings) if the expected
# environment variable is set; switch to anonymous mode otherwise.
- run:
name: Login to DockerHub
command: >
test -n "$DOCKER_USER" &&
echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin ||
echo "Docker Hub anonymous mode"
# Skip release build & testing if changes are not targeting it
- run:
name: Check if changes are targeting the current release
command: bin/ci checkpoint
# Install a recent docker-compose release
- run:
name: Upgrade docker-compose
command: |
curl -L "https://github.com/docker/compose/releases/download/1.25.1/docker-compose-$(uname -s)-$(uname -m)" -o ~/docker-compose
chmod +x ~/docker-compose
sudo mv ~/docker-compose /usr/local/bin/docker-compose
# Production image build
- run:
name: Build production image
command: |
source $(bin/ci activate_path)
make build
# Development image build. It uses the "development" Dockerfile target
# file
- run:
name: Build development image
command: |
source $(bin/ci activate_path)
make dev-build
# Bootstrap
- run:
name: Bootstrap the CMS & LMS
command: |
source $(bin/ci activate_path)
make tree
make migrate
make run
# Check that the production build starts
- run:
name: Check production build
command: |
source $(bin/ci activate_path)
make test-cms
make test-lms
# Check that the demo course can be imported
- run:
name: Import demonstration course
command: |
source $(bin/ci activate_path)
make demo-course
# List openedx-docker jobs that will be integrated and executed in a workflow
jobs:
# Quality jobs
# Check that the git history is clean and complies with our expectations
lint-git:
docker:
- image: circleci/python:3.7-stretch
auth:
username: $DOCKER_USER
password: $DOCKER_PASS
working_directory: ~/fun
steps:
- checkout
# Make sure the changes don't add a "print" statement to the code base.
# We should exclude the ".circleci" folder from the search as the very command that checks
# the absence of "print" is including a "print(" itself.
- run:
name: enforce absence of print statements in code
command: |
! git diff origin/master..HEAD -- . ':(exclude).circleci' | grep "print("
- run:
name: Check absence of fixup commits
command: |
! git log | grep 'fixup!'
- run:
name: Install gitlint
command: |
pip install --user gitlint
- run:
name: lint commit messages added to master
command: |
~/.local/bin/gitlint --commits origin/master..HEAD
# Check that the CHANGELOG has been updated in the current branch
check-changelog:
docker:
- image: circleci/buildpack-deps:stretch-scm
auth:
username: $DOCKER_USER
password: $DOCKER_PASS
working_directory: ~/fun
steps:
- checkout
- run:
name: Check that the CHANGELOG has been modified in the current branch
command: |
git whatchanged --name-only --pretty="" origin..HEAD | grep CHANGELOG
# Check that the CHANGELOG max line length does not exceed 80 characters
lint-changelog:
docker:
- image: debian:stretch
auth:
username: $DOCKER_USER
password: $DOCKER_PASS
working_directory: ~/fun
steps:
- checkout
- run:
name: Check CHANGELOG max line length
command: |
# Get the longuest line width (ignoring release links)
test $(cat CHANGELOG.md | grep -Ev "^\[.*\]: https://github.com/openfun" | wc -L) -le 80
check-configuration:
machine:
docker_layer_caching: true
steps:
- checkout
- run:
name: Check that the circle-ci config.yml file has been updated in the current branch
command: bin/ci check_configuration
working_directory: ~/fun
# Build jobs
#
# Note that the job name should match the EDX_RELEASE value
# No changes detected for dogwood.3-bare
# No changes detected for dogwood.3-fun
# No changes detected for eucalyptus.3-bare
# No changes detected for eucalyptus.3-wb
# Run jobs for the hawthorn.1-bare release
hawthorn.1-bare:
<<: [*defaults, *build_steps]
# Run jobs for the hawthorn.1-oee release
hawthorn.1-oee:
<<: [*defaults, *build_steps]
# No changes detected for ironwood.2-bare
# No changes detected for ironwood.2-oee
# Run jobs for the master.0-bare release
master.0-bare:
<<: [*defaults, *build_steps]
# Hub job
hub:
<<: *defaults
steps:
- checkout
# Login to DockerHub with encrypted credentials stored as secret
# environment variables (set in CircleCI project settings)
- run:
name: Login to DockerHub
command: echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin
# Install a recent docker-compose release
- run:
name: Upgrade docker-compose
command: |
curl -L "https://github.com/docker/compose/releases/download/1.25.1/docker-compose-$(uname -s)-$(uname -m)" -o ~/docker-compose
chmod +x ~/docker-compose
sudo mv ~/docker-compose /usr/local/bin/docker-compose
# Thanks to docker layer caching, rebuilding the image should be blazing
# fast!
- run:
name: Rebuild production image
command: |
source $(bin/ci activate_path)
make build
# Tag images with our DockerHub namespace (fundocker/), and list images to
# check that they have been properly tagged.
- run:
name: Tag production image
command: |
source $(bin/ci activate_path)
docker tag edxapp:${EDX_RELEASE}-${FLAVOR} fundocker/edxapp:${CIRCLE_TAG}
docker images fundocker/edxapp:${CIRCLE_TAG}
- run:
name: Tag nginx production images
command: |
source $(bin/ci activate_path)
docker tag edxapp-nginx:${EDX_RELEASE}-${FLAVOR} fundocker/edxapp-nginx:${CIRCLE_TAG}
docker images fundocker/edxapp-nginx:${CIRCLE_TAG}
# Publish the production images to DockerHub
- run:
name: Publish production image
command: |
docker push fundocker/edxapp:${CIRCLE_TAG}
docker push fundocker/edxapp-nginx:${CIRCLE_TAG}
# CI workflows
workflows:
version: 2
# We have a single workflow
edxapp:
jobs:
# Quality
- lint-git:
filters:
branches:
ignore: master
tags:
ignore: /.*/
- check-changelog:
filters:
branches:
ignore: master
tags:
ignore: /.*/
- lint-changelog:
filters:
branches:
ignore: master
tags:
ignore: /.*/
- check-configuration:
filters:
branches:
ignore: master
tags:
ignore: /.*/
# Build jobs
# No changes detected so no job to run for dogwood.3-bare
# No changes detected so no job to run for dogwood.3-fun
# No changes detected so no job to run for eucalyptus.3-bare
# No changes detected so no job to run for eucalyptus.3-wb
# Run jobs for the hawthorn.1-bare release
- hawthorn.1-bare:
requires:
- check-configuration
filters:
tags:
ignore: /.*/
# Run jobs for the hawthorn.1-oee release
- hawthorn.1-oee:
requires:
- check-configuration
filters:
tags:
ignore: /.*/
# No changes detected so no job to run for ironwood.2-bare
# No changes detected so no job to run for ironwood.2-oee
# Run jobs for the master.0-bare release
- master.0-bare:
requires:
- check-configuration
filters:
tags:
ignore: /.*/
# We are pushing to Docker only images that are the result of a tag respecting the pattern:
# **{branch-name}-x.y.z**
#
# Where branch-name is of the form: **{edx-version}[-{fork-name}]**
# - **edx-version:** name of the upstream `edx-platform` version (e.g. ginkgo.1),
# - **fork-name:** name of the specific project fork, if any (e.g. funwb).
#
# Some valid examples:
# - dogwood.3-1.0.3
# - dogwood.2-funmooc-17.6.1
# - eucalyptus-funwb-2.3.19
- hub:
filters:
branches:
ignore: /.*/
tags:
only: /^[a-z0-9.]*-?[a-z]*-(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/