-
Notifications
You must be signed in to change notification settings - Fork 2
307 lines (253 loc) · 9.87 KB
/
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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
name: CI
on: [push]
jobs:
python-tests:
runs-on: ubuntu-latest
services:
# Label used to access the service container
db:
# Docker Hub image
image: postgres:12.20
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres # pragma: allowlist secret
POSTGRES_DB: postgres
ports:
- 5432:5432
redis:
image: redis:7.4.0
ports:
- 6379:6379
elastic:
image: docker.elastic.co/elasticsearch/elasticsearch:8.15.1
env:
network.host: "0.0.0.0"
http.cors.enabled: "true"
http.cors.allow-origin: "*"
http.max_content_length: "10mb"
rest.action.multi.allow_explicit_index: "false"
ES_JAVA_OPTS: "-Xms1024m -Xmx1024m"
discovery.type: "single-node"
ports:
- 9200:9200
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: update apt
run: sudo apt-get update -y
- name: Apt install
run: cat Aptfile | sudo xargs apt-get install
- name: Install poetry
uses: snok/install-poetry@76e04a911780d5b312d89783f7b1cd627778900a # v1
with:
version: 1.7.1
virtualenvs-create: true
virtualenvs-in-project: true
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5
with:
python-version: "3.12.6"
cache: "poetry"
- name: Validate lockfile
run: poetry check --lock
- name: Install dependencies
run: poetry install --no-interaction
- name: Create test local state
run: ./scripts/test/stub-data.sh
- name: Tests
run: |
poetry run ./manage.py collectstatic --noinput --clear
export MEDIA_ROOT="$(mktemp -d)"
./scripts/test/python_tests.sh
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres # pragma: allowlist secret
MITOL_SECURE_SSL_REDIRECT: "False"
MITOL_DB_DISABLE_SSL: "True"
MITOL_FEATURES_DEFAULT: "True"
OPENSEARCH_URL: localhost:9200
CELERY_TASK_ALWAYS_EAGER: "True"
CELERY_BROKER_URL: redis://localhost:6379/4
CELERY_RESULT_BACKEND: redis://localhost:6379/4
TIKA_CLIENT_ONLY: "True"
MITOL_APP_BASE_URL: http://localhost:8062/
MAILGUN_KEY: fake_mailgun_key
MAILGUN_SENDER_DOMAIN: other.fake.site
OPENSEARCH_INDEX: testindex
INDEXING_API_USERNAME: mitodl
MITOL_COOKIE_DOMAIN: localhost
MITOL_COOKIE_NAME: cookie_monster
- name: Upload coverage to CodeCov
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
with:
file: ./coverage.xml
javascript-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
with:
node-version: "^20"
cache: yarn
cache-dependency-path: yarn.lock
- name: Setup environment
run: sudo apt-get install libelf1
- name: Install dependencies
run: yarn install --immutable
- name: Dependencies are consistent
run: yarn syncpack list-mismatches
- name: Format check
run: yarn workspace frontends fmt-check
- name: Style lint
run: yarn run style-lint
- name: Webpack build
run: yarn run build
env:
MITOL_API_BASE_URL: https://api.mitlearn-test.odl.mit.edu
- name: Lints
run: yarn run lint-check
- name: Typecheck
run: yarn run typecheck
- name: Get number of CPU cores
id: cpu-cores
uses: SimenB/github-actions-cpu-cores@97ba232459a8e02ff6121db9362b09661c875ab8 # v2
- name: Tests
run: yarn test --max-workers ${{ steps.cpu-cores.outputs.count }}
env:
CODECOV: true
NODE_ENV: test
- name: Upload frontend build
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4
with:
name: frontend-build
path: frontends/mit-learn/build
- name: Upload coverage to CodeCov
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
with:
file: coverage/lcov.info
build-storybook:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
with:
node-version: "^20"
cache: yarn
cache-dependency-path: yarn.lock
- name: Install dependencies
run: yarn install
- name: Build Storybook
run: yarn workspace mit-learn build-storybook
openapi-generated-client-check-v0:
# This job checks that the output of openapi-generator-typescript-axios that
# is checked into version control is up-to-date.
env:
OPENAPI_SCHEMA: ./openapi/specs/v0.yaml
GENERATOR_IGNORE_FILE: ./frontends/api/.openapi-generator-ignore
GENERATOR_OUTPUT_DIR_CI: ./frontends/api/tmp/generated/v0
GENERATOR_OUTPUT_DIR_VC: ./frontends/api/src/generated/v0
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
with:
node-version: "^20"
cache: yarn
cache-dependency-path: yarn.lock
- name: Install dependencies
run: yarn install --immutable
- name: Generate Fresh API Client
uses: openapi-generators/openapitools-generator-action@v1
with:
generator: typescript-axios
openapi-file: $OPENAPI_SCHEMA
generator-tag: v7.2.0
command-args: |
--output $GENERATOR_OUTPUT_DIR_CI \
--ignore-file-override $GENERATOR_IGNORE_FILE \
-c scripts/openapi-configs/typescript-axios-v0.yaml
- name: Format freshly generated client
run: npx prettier $GENERATOR_OUTPUT_DIR_CI/**/*.ts --no-semi --write
- name: Check VC client is up-to-date
run: |
diff $GENERATOR_OUTPUT_DIR_CI $GENERATOR_OUTPUT_DIR_VC \
|| { echo "OpenAPI spec is out of date. Please regenerate via ./scripts/generate_openapi.sh"; exit 1; }
openapi-generated-client-check-v1:
# This job checks that the output of openapi-generator-typescript-axios that
# is checked into version control is up-to-date.
env:
OPENAPI_SCHEMA: ./openapi/specs/v1.yaml
GENERATOR_IGNORE_FILE: ./frontends/api/.openapi-generator-ignore
GENERATOR_OUTPUT_DIR_CI: ./frontends/api/tmp/generated/v1
GENERATOR_OUTPUT_DIR_VC: ./frontends/api/src/generated/v1
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
with:
node-version: "^20"
cache: yarn
cache-dependency-path: yarn.lock
- name: Install dependencies
run: yarn install --immutable
- name: Generate Fresh API Client
uses: openapi-generators/openapitools-generator-action@v1
with:
generator: typescript-axios
openapi-file: $OPENAPI_SCHEMA
generator-tag: v7.2.0
command-args: |
--output $GENERATOR_OUTPUT_DIR_CI \
--ignore-file-override $GENERATOR_IGNORE_FILE \
-c scripts/openapi-configs/typescript-axios-v1.yaml
- name: Format freshly generated client
run: npx prettier $GENERATOR_OUTPUT_DIR_CI/**/*.ts --no-semi --write
- name: Check VC client is up-to-date
run: |
diff $GENERATOR_OUTPUT_DIR_CI $GENERATOR_OUTPUT_DIR_VC \
|| { echo "OpenAPI spec is out of date. Please regenerate via ./scripts/generate_openapi.sh"; exit 1; }
e2e-tests:
# Disabling the E2E tests for now
if: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
with:
node-version: "^20"
cache: yarn
cache-dependency-path: e2e_testing/yarn.lock
- name: Install frontend dependencies
run: yarn install --immutable
- name: Build frontend
run: NODE_ENV=production yarn build
- name: Build exported components
run: NODE_ENV=production yarn workspace mit-learn build-exports
- name: Build services
run: docker compose -f docker-compose-e2e-tests.yml build
- name: Start services
run: docker compose -f docker-compose-e2e-tests.yml up nginx web --detach --wait
- name: Apply test data
run: ./e2e_testing/scripts/apply-fixtures.sh
- name: Install E2E test dependencies
working-directory: e2e_testing
run: yarn install --immutable
- name: Install Playwright browsers
working-directory: e2e_testing
run: yarn playwright install --with-deps chromium
- name: Run E2E tests
working-directory: e2e_testing
run: BASE_URL=http://localhost:8063 CI=true yarn test
- name: Setup Pages
if: always()
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5
- name: Upload artifact
if: always()
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4
with:
name: playwright-report
path: e2e_testing/playwright-report