|
| 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 | + - name: "Setup: Copy environment variables" |
| 11 | + run: cp .env_circleci .env |
| 12 | + - name: "Setup: Create directories for MinIO (cannot be made by docker for some reason)" |
| 13 | + run: | |
| 14 | + mkdir -p var/minio/public |
| 15 | + mkdir -p var/minio/private |
| 16 | + - name: "Docker: Build containers and collect static files" |
| 17 | + run: | |
| 18 | + docker compose -f docker-compose.yml -f docker-compose.selenium.yml -f docker-compose.playwright.yml up -d |
| 19 | + docker compose -f docker-compose.yml -f docker-compose.selenium.yml exec django python manage.py collectstatic --noinput |
| 20 | + docker compose -f docker-compose.yml -f docker-compose.selenium.yml exec django python manage.py migrate |
| 21 | + docker compose -f docker-compose.yml exec django python ./manage.py createsuperuser --no-input |
| 22 | + - name: "Docker: Pull required images" |
| 23 | + run: | |
| 24 | + docker pull codalab/codalab-legacy:py37 |
| 25 | + docker pull codalab/codalab-legacy:py3 |
| 26 | + linter: |
| 27 | + name: Flake8 linter |
| 28 | + runs-on: self-hosted |
| 29 | + needs: [build] |
| 30 | + steps: |
| 31 | + - name: "Lint: Check code style with flake8" |
| 32 | + run: docker compose exec django flake8 src/ |
| 33 | + unit_tests: |
| 34 | + name: Unit test with Selenium |
| 35 | + runs-on: self-hosted |
| 36 | + needs: [linter, build] |
| 37 | + steps: |
| 38 | + - name: "Tests: Run unit/integration tests (excluding e2e)" |
| 39 | + run: docker compose -f docker-compose.yml -f docker-compose.selenium.yml exec django py.test src/ -m "not e2e" |
| 40 | + e2e: |
| 41 | + name: End to End tests with Playwright |
| 42 | + runs-on: self-hosted |
| 43 | + needs: [linter, build] |
| 44 | + steps: |
| 45 | + - name: "Tests: Run end-to-end (E2E) tests" |
| 46 | + run: docker compose -f docker-compose.yml -f docker-compose.selenium.yml exec django py.test src/tests/functional/ -m e2e |
| 47 | + cleanup: |
| 48 | + name: Cleanup |
| 49 | + runs-on: self-hosted |
| 50 | + if: ${{ always() }} |
| 51 | + needs: [unit_tests, e2e, linter] |
| 52 | + steps: |
| 53 | + - name: Cleanup |
| 54 | + run: | |
| 55 | + docker compose -f docker-compose.yml -f docker-compose.selenium.yml -f docker-compose.playwright.yml down --rmi all |
| 56 | + rm -rf ${{ github.workspace }}/* |
0 commit comments