forked from Submitty/Submitty
-
Notifications
You must be signed in to change notification settings - Fork 0
541 lines (481 loc) · 16.7 KB
/
submitty_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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
name: Submitty CI
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
env:
PGPASSWORD: submitty_dbuser
PHP_USER: submitty_php
PHP_GROUP: submitty_php
CGI_USER: submitty_cgi
SUBMITTY_DATA_DIR: /var/local/submitty
SUBMITTY_INSTALL_DIR: /usr/local/submitty
SUBMITTY_REPOSITORY: /usr/local/submitty/GIT_CHECKOUT/Submitty
POSTGRES_HOST: localhost
PHP_VER: 8.1
NODE_VERSION: 20
PYTHON_VERSION: "3.10"
concurrency:
# If this is a PR, cancel all previously running jobs on source branch
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
css-lint:
runs-on: ubuntu-22.04
defaults:
run:
working-directory: site
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache Node Modules
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-cache-node-modules-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-cache-node-modules-
- run: npm install
- name: Run stylelint
run: npm run css-stylelint
js-lint:
runs-on: ubuntu-22.04
defaults:
run:
working-directory: site
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache Node Modules
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-cache-node-modules-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-cache-node-modules-
- run: npm install
- name: Run eslint
run: npm run eslint
- name: Run npm build (tsc and esbuild)
run: npm run build
js-unit:
runs-on: ubuntu-22.04
defaults:
run:
working-directory: site
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache Node Modules
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-cache-node-modules-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-cache-node-modules-
- run: npm install
- run: npm run test
- name: Upload Coverage
uses: codecov/codecov-action@v3
with:
files: site/tests/report/jest/clover.xml
flags: js
php-lint:
runs-on: ubuntu-22.04
defaults:
run:
working-directory: site
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@2.30.0
with:
php-version: ${{ env.PHP_VER }}
- name: Cache Composer
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Install Composer
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --prefer-dist --dev
- name: Check syntax
run: find -L . -path ./vendor -prune -o -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l
- name: Lint PHP code
run: |
php vendor/bin/phpcs --version
php vendor/bin/phpcs
- name: Static analysis
run: |
php vendor/bin/phpstan --version
php vendor/bin/phpstan analyze app public/index.php socket/index.php
php-unit:
runs-on: ubuntu-22.04
defaults:
run:
working-directory: site
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@2.30.0
with:
php-version: ${{ env.PHP_VER }}
extensions: imagick
coverage: pcov
- name: Cache Composer
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Install Composer
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --prefer-dist --dev
- name: Run php unit tests
run: php vendor/bin/phpunit
- name: Upload Coverage
uses: codecov/codecov-action@v3
with:
files: site/tests/report/clover.xml
flags: php
python-lint:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Cache Pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-${{ github.job }}-pip-${{ github.sha }}
restore-keys: |
${{ runner.os }}-${{ github.job }}-pip-
- name: Install python libraries
run: python3 -m pip install -r .setup/pip/dev_requirements.txt
- name: Run python linting
run: python3 -m flake8
python-unit:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Cache Pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-${{ github.job }}-pip-${{ hashFiles('**/system_requirements.txt') }}
restore-keys: |
${{ runner.os }}-${{ github.job }}-pip-
- name: Install python libraries
run: |
python3 -m pip install -r .setup/pip/system_requirements.txt
python3 -m pip install coverage # Testing util.
# Submitty utils install & unit testing, must be put before auto grader
# testing as auto grader depends on submitty utils to function.
- name: Run python_submitty_utils python unit tests
working-directory: python_submitty_utils
run: |
pip3 install .
coverage run -m unittest discover
coverage xml
- name: Upload submitty python utils Coverage
uses: codecov/codecov-action@v3
with:
files: python_submitty_utils/coverage.xml
flags: python_submitty_utils
# Migrator unit test
- name: Run migrator python unit tests
working-directory: migration
run: |
coverage run -m unittest discover
coverage xml
- name: Upload migrator Coverage
uses: codecov/codecov-action@v3
with:
files: migration/coverage.xml
flags: migrator
# Auto grader unit test
- name: Run autograder python unit tests
working-directory: autograder
run: |
coverage run -m unittest discover
coverage xml
- name: Upload autograder Coverage
uses: codecov/codecov-action@v3
with:
files: autograder/coverage.xml
flags: autograder
# submitty_daemon_jobs unit tests
- name: Install bulk upload dependencies
run: |
sudo apt-get update
sudo apt-get install -y poppler-utils
sudo apt-get install -y libzbar0
- name: Run bulk upload unit tests
working-directory: sbin/submitty_daemon_jobs
run: |
coverage run -m unittest discover tests -t .
coverage xml -i
- name: Upload submitty_daemon_jobs Coverage
uses: codecov/codecov-action@v3
with:
files: sbin/submitty_daemon_jobs/coverage.xml
flags: submitty_daemon_jobs
yaml-lint:
name: yaml-lint
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: install yamllint
run: sudo apt-get install -y yamllint
- name: Run yamllint
run: yamllint .
shellcheck:
name: ShellCheck
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: install ShellCheck
run: sudo apt-get install -y shellcheck
- name: Run ShellCheck
run: python3 run_shellcheck.py # Uses the default Python installed with Ubuntu
Cypress-System:
runs-on: ubuntu-22.04
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: submitty_dbuser
POSTGRES_USER: postgres
TZ: America/New_York
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: ./.github/actions/e2e-Setup-Composite
# TODO: Remove this block after upgrading jsPDF
- name: Cache Node Modules
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-cache-node-modules-dev-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-cache-node-modules-dev
- name: Install node dependencies
working-directory: ${{env.SUBMITTY_REPOSITORY}}/site
run: |
npm install file-saver --save
npm install --production=false
- name: Run accessibility test
uses: cypress-io/github-action@v6
with:
config: baseUrl=http://localhost
spec: cypress/e2e/Cypress-System/accessibility.spec.js
working-directory: ${{env.SUBMITTY_REPOSITORY}}/site
browser: chrome
- name: Run API tests
working-directory: ${{env.SUBMITTY_REPOSITORY}}/site
run: npm run test:api
env:
BASE_URL: http://localhost
- name: Stop autograding services
run: |
sudo systemctl stop submitty_autograding_worker
sudo systemctl stop submitty_autograding_shipper
- name: Run autograding status test
uses: cypress-io/github-action@v6
with:
config: baseUrl=http://localhost
spec: cypress/e2e/Cypress-System/autograding_status_1.spec.js
working-directory: ${{env.SUBMITTY_REPOSITORY}}/site
browser: chrome
env: autograding_shipper_off=True
- name: Restart autograding shipper
run: |
sudo systemctl restart submitty_autograding_shipper
- name: Run autograding status test
uses: cypress-io/github-action@v6
with:
config: baseUrl=http://localhost
spec: cypress/e2e/Cypress-System/autograding_status_2.spec.js
working-directory: ${{env.SUBMITTY_REPOSITORY}}/site
browser: chrome
env: autograding_shipper_off=True
- name: Restart autograding worker
run: |
sudo systemctl restart submitty_autograding_worker
- name: Run cypress e2e login tests with PAM auth
uses: cypress-io/github-action@v6
with:
config: baseUrl=http://localhost,chromeWebSecurity=false
spec: cypress/e2e/Cypress-System/login.spec.js
working-directory: ${{env.SUBMITTY_REPOSITORY}}/site
browser: chrome
- name: Switch to database auth
run: sudo sed -ie "s/Pam/Database/g" ${SUBMITTY_INSTALL_DIR}/config/authentication.json
- name: Run cypress e2e login tests with database auth
uses: cypress-io/github-action@v6
with:
config: baseUrl=http://localhost
spec: cypress/e2e/Cypress-System/login.spec.js
working-directory: ${{env.SUBMITTY_REPOSITORY}}/site
browser: chrome
- name: Switch to LDAP auth
run: sudo sed -ie "s/Database/Ldap/g" ${SUBMITTY_INSTALL_DIR}/config/authentication.json
- name: Run cypress e2e login tests with LDAP auth
uses: cypress-io/github-action@v6
with:
config: baseUrl=http://localhost
spec: cypress/e2e/Cypress-System/login.spec.js
working-directory: ${{env.SUBMITTY_REPOSITORY}}/site
browser: chrome
- name: Setup SAML
run: |
cd $SUBMITTY_REPOSITORY
sudo -E env "PATH=$PATH" bash .setup/testing/setup_saml.sh
- name: Switch to SAML auth
run: sudo sed -ie "s/Ldap/Saml/g" ${SUBMITTY_INSTALL_DIR}/config/authentication.json
- name: Run cypress e2e login tests with SAML auth
uses: cypress-io/github-action@v6
with:
config: baseUrl=http://localhost,chromeWebSecurity=false
spec: cypress/e2e/Cypress-System/login.spec.js
working-directory: ${{env.SUBMITTY_REPOSITORY}}/site
browser: chrome
- name: Setup HTTP/2
run: |
cd $SUBMITTY_REPOSITORY
if [ -f .setup/dev-upgrade-h2.sh ]; then
sudo sed -e "s/:80/:443/g" --in-place /etc/apache2/sites-available/submitty.conf
sudo -E env "PATH=$PATH" bash .setup/dev-upgrade-h2.sh up --i-know-what-i-am-doing-please-go-ahead \
&& echo "Setup OK" \
|| {
echo "::warning::Setup Failed"
sudo sed -e "s/:443/:80/g" --in-place /etc/apache2/sites-available/submitty.conf
}
else
echo "Could not find dev-upgrade-h2.sh, skipping"
fi
- name: Test HTTP/2 Connection
run: |
http_ver=$(curl -ksI https://localhost -o/dev/null -w "%{http_version}\n")
[ "$http_ver" = "2" ] && echo "Pass" || echo "::warning::Failed"
- uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-screenshots
path: ${{env.SUBMITTY_REPOSITORY}}/site/cypress/screenshots
- uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-videos
path: ${{env.SUBMITTY_REPOSITORY}}/site/cypress/videos
- name: Check for site errors
working-directory: ${{ env.SUBMITTY_REPOSITORY }}
run: sudo bash tests/test_site_error_log.sh
Cypress:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
containers: ["Gradeable", "Admin", "UI", "Feature"]
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: submitty_dbuser
POSTGRES_USER: postgres
TZ: America/New_York
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: ./.github/actions/e2e-Setup-Composite
# TODO: Remove this block after upgrading jsPDF
- name: Cache Node Modules
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-cache-node-modules-dev-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-cache-node-modules-dev
- name: Install node dependencies
working-directory: ${{env.SUBMITTY_REPOSITORY}}/site
run: |
npm install file-saver --save
npm install --production=false
- name: Run cypress e2e tests with pam auth
uses: cypress-io/github-action@v6
with:
config: baseUrl=http://localhost
working-directory: ${{env.SUBMITTY_REPOSITORY}}/site
spec: cypress/e2e/Cypress-${{matrix.containers}}/*
browser: chrome
env: run_area=CI
- name: Check for site errors
working-directory: ${{ env.SUBMITTY_REPOSITORY }}
run: sudo bash tests/test_site_error_log.sh
- uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-screenshots
path: ${{env.SUBMITTY_REPOSITORY}}/site/cypress/screenshots
- uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-videos
path: ${{env.SUBMITTY_REPOSITORY}}/site/cypress/videos
Integration:
runs-on: ubuntu-22.04
# Postgres should not be needed for the integration tests.
# But unfortunately Configure test suite seems to use it at the moment, and
# Configure test suite seems to be necessary for the Integration tests
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: submitty_dbuser
POSTGRES_USER: postgres
TZ: America/New_York
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: ./.github/actions/e2e-Setup-Composite
- name: Run integration tests
run: sudo -E env "PATH=$PATH" python3 /usr/local/submitty/test_suite/integrationTests/run.py