cromper #2740
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: PR | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| jobs: | |
| backend_test_docker_dev: | |
| name: backend tests (docker dev container) | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build decompme_backend image | |
| run: |- | |
| docker build backend -t decompme_backend | |
| - name: Run tests | |
| run: |- | |
| # NOTE: CI does not run as 'ubuntu' user | |
| export USER_1000=$(getent passwd 1000 | cut -d: -f1) | |
| sudo chown -R "${USER_1000}:${USER_1000}" . | |
| docker run \ | |
| -v $(pwd):/decomp.me \ | |
| --entrypoint /bin/bash \ | |
| decompme_backend \ | |
| -c 'cd /decomp.me/backend && \ | |
| uv sync && \ | |
| uv run python manage.py test' | |
| backend_test_docker_prod: | |
| name: backend tests (docker prod container) | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build decompme_backend image | |
| run: |- | |
| docker build backend --target prod -t decompme_backend | |
| - name: Run tests | |
| run: |- | |
| mkdir -p local_files && sudo chown ${USER_1000}:${USER_1000} local_files | |
| docker run \ | |
| -v $(pwd)/local_files:/local_files \ | |
| --entrypoint /bin/bash \ | |
| -e LOCAL_FILE_DIR=/local_files \ | |
| -e DATABASE_URL=sqlite:///:memory: \ | |
| -e SECRET_KEY=secret-key-secret-key-secret-key-secret-key-secret-key-secret-key \ | |
| decompme_backend \ | |
| -c 'uv run python manage.py test' | |
| # TODO: run cromper unit tests | |
| docker_compose_test: | |
| name: test docker compose | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Fetch compilers and libraries | |
| run: | | |
| python3 -m pip install requests | |
| python3 cromper/compilers/download.py | |
| python3 cromper/libraries/download.py | |
| export USER_1000=$(getent passwd 1000 | cut -d: -f1) | |
| sudo chown -R ${USER_1000}:${USER_1000} cromper/compilers | |
| sudo chown -R ${USER_1000}:${USER_1000} cromper/libraries | |
| - name: Setup dummy docker.prod.dev | |
| run: | | |
| echo 'POSTGRES_USER=decompme' >> docker.prod.env | |
| echo 'POSTGRES_PASSWORD=decompme' >> docker.prod.env | |
| echo 'SECRET_KEY=secret-key-secret-key-secret-key-secret-key-secret-key-secret-key' >> docker.prod.env | |
| echo 'DATABASE_URL=psql://decompme:decompme@postgres:5432/decompme' >> docker.prod.env | |
| echo 'CONN_MAX_AGE=60' >> docker.prod.env | |
| echo 'CONN_HEALTH_CHECKS="true"' >> docker.prod.env | |
| echo 'SANDBOX_DISABLE_PROC="true"' >> docker.prod.env | |
| echo 'ALLOWED_HOSTS="backend,localhost,127.0.0.1"' >> docker.prod.env | |
| echo 'USE_SANDBOX_JAIL="on"' >> docker.prod.env | |
| echo 'CROMPER_URL=http://cromper:8888' >> docker.prod.env | |
| echo 'CI=true' >> docker.prod.env | |
| - name: Comment out SSL server configuration from nginx | |
| run: | | |
| sed -i '/{{HTTPS_SERVER_BLOCK_START}}/,/{{HTTPS_SERVER_BLOCK_END}}/s/^/#/' nginx/production.conf | |
| - name: Bring up postgres and nginx containers | |
| run: | | |
| docker compose -f docker-compose.prod.yaml up -d postgres nginx | |
| timeout 15s docker compose -f docker-compose.prod.yaml logs -f || true | |
| docker compose logs nginx | grep "ready for start up" | |
| ! docker compose logs nginx | grep -q "nginx-1 exited with code" | |
| - name: Build and bring up cromper container | |
| run: | | |
| docker compose -f docker-compose.prod.yaml build cromper | |
| docker compose -f docker-compose.prod.yaml up -d cromper | |
| timeout 15s docker compose -f docker-compose.prod.yaml logs -f || true | |
| - name: Build and bring up up backend container | |
| run: | | |
| docker compose -f docker-compose.prod.yaml build backend | |
| docker compose -f docker-compose.prod.yaml up -d backend | |
| timeout 15s docker compose -f docker-compose.prod.yaml logs -f || true | |
| - name: Build and bring up up frontend container | |
| run: | | |
| docker compose -f docker-compose.prod.yaml -f docker-compose.build.yaml build frontend | |
| docker compose -f docker-compose.prod.yaml up -d frontend | |
| timeout 15s docker compose -f docker-compose.prod.yaml logs -f || true | |
| - name: Sanity check the endpoints | |
| run: | | |
| curl --silent http://localhost:8080/ | head -c 256 | |
| curl --silent http://localhost:8000/api/ | jq | |
| curl --silent http://localhost:8000/api/platform | jq | |
| - name: Shut everything down | |
| run: | | |
| docker compose -f docker-compose.prod.yaml down | |
| - name: Print out image sizes | |
| run: | | |
| docker image ls | |
| frontend_lint: | |
| name: biome | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js 24 | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| cache: yarn | |
| cache-dependency-path: frontend/yarn.lock | |
| - name: Install frontend dependencies | |
| run: | | |
| cd frontend | |
| yarn --frozen-lockfile | |
| - name: Run Biome | |
| run: | | |
| cd frontend | |
| yarn lint | |
| backend_lint: | |
| name: backend lint and type check | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| version: "latest" | |
| - name: Setup Python 3.12 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - run: |- | |
| cd backend | |
| uv sync --all-extras | |
| uv run mypy . | |
| uv run ruff check | |
| uv run ruff format --check | |
| cromper_lint: | |
| name: cromper lint and type check | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| version: "latest" | |
| - name: Setup Python 3.12 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - run: |- | |
| cd cromper | |
| uv sync --all-extras | |
| uv run mypy . | |
| uv run ruff check | |
| uv run ruff format --check |