1+ name : build_and_test
2+ on : [push]
3+ jobs :
4+ build :
5+ name : Build necessary services
6+ runs-on : self-hosted
7+ steps :
8+ - name : Check out repository code
9+ uses : actions/checkout@v5
10+
11+ - name : " Setup: Copy environment variables"
12+ run : cp .env_circleci .env
13+
14+ - name : " Setup: Create directories for MinIO (cannot be made by docker for some reason)"
15+ run : |
16+ mkdir -p var/minio/public
17+ mkdir -p var/minio/private
18+
19+ - name : " Setup: Prepare the playwright environment"
20+ run : |
21+ cd tests
22+ curl -LsSf https://astral.sh/uv/install.sh | sh
23+ $HOME/.local/bin/uv sync --frozen
24+ $HOME/.local/bin/uv run playwright install
25+ - name : " Docker: Build containers"
26+ run : |
27+ docker compose up -d
28+
29+ - name : " Get compute worker, site worker and django logs"
30+ run : |
31+ mkdir dockerLogs
32+ docker compose logs -f site_worker compute_worker django > dockerLogs/django_workers.log &
33+ linter :
34+ name : Flake8 linter
35+ runs-on : self-hosted
36+ needs : [build]
37+ steps :
38+ - name : " Lint: Check code style with flake8"
39+ run : docker compose exec django flake8 src/
40+ unit_tests :
41+ name : Unit tests
42+ runs-on : self-hosted
43+ needs : [linter,build]
44+ steps :
45+ - name : " Tests: Run unit/integration tests (excluding e2e)"
46+ run : docker compose exec django py.test src/ -m "not e2e"
47+ e2e :
48+ name : End to End tests with Playwright
49+ runs-on : self-hosted
50+ needs : [linter,build]
51+ steps :
52+ - name : " Tests: Run end-to-end (E2E) tests"
53+ run : |
54+ docker compose exec django python ./manage.py createsuperuser --no-input
55+ docker compose exec django python ./manage.py collectstatic --no-input
56+ docker compose exec django python ./manage.py migrate --no-input
57+ cd tests && CI=True $HOME/.local/bin/uv run pytest test_auth.py test_account_creation.py test_competition.py test_submission.py
58+ artifacts :
59+ name : " Store Artifacts"
60+ runs-on : self-hosted
61+ needs : [linter,build,unit_tests,e2e]
62+ steps :
63+ - name : " Docker logs"
64+ uses : actions/upload-artifact@v4
65+ with :
66+ name : " Docker logs"
67+ path : |
68+ dockerLogs/
69+ - name : " Playwright results (on-failure)"
70+ uses : actions/upload-artifact@v4
71+ with :
72+ name : " Playwright results (on-failure)"
73+ path : |
74+ tests/test-results
75+ cleanup :
76+ name : Cleanup
77+ runs-on : self-hosted
78+ if : ${{ always() }}
79+ needs : [unit_tests,e2e,linter,artifacts]
80+ steps :
81+ - name : Cleanup
82+ run : |
83+ docker compose down --rmi all
84+ rm -rf ${{ github.workspace }}/*
0 commit comments