Crashed worker to update job itself (and make the UI clearer on status) #994
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
| # This will keep the tag:latest up-to-date with all commits and pull requests | |
| name: Test PR for Docker build and run | |
| # Controls when the workflow will run | |
| on: | |
| # Triggers the workflow on pull request events but only for the "master" branch | |
| pull_request: | |
| branches: [ "master" ] | |
| jobs: | |
| # Fast static check — no Docker required. | |
| # Verifies that every column added/dropped in a migration script is also | |
| # reflected in backend/database.sql and vice versa. | |
| test_schema_consistency: | |
| name: Check database.sql / migration consistency | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install pytest | |
| run: pip install pytest | |
| - name: Run schema consistency tests | |
| run: pytest tests/test_schema_consistency.py -v | |
| test_docker_build: | |
| name: Test docker-compose up with build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Run docker compose up | |
| run: docker compose -f docker-compose_build.yml up -d | |
| - name: Check backend container is running | |
| run: | | |
| sleep 30 | |
| if [ "$(docker ps | grep 4cat_backend)" ]; then | |
| echo "Docker 4cat_backend container is running..." | |
| else | |
| echo -e "Docker 4cat_backend container is not running...\nPrinting 4cat_backend logs:\n\n$(docker container logs 4cat_backend)" | |
| exit 1 | |
| fi | |
| - name: Check frontend container is running | |
| run: | | |
| sleep 10 | |
| if [ "$(docker ps | grep 4cat_frontend)" ]; then | |
| echo "Docker 4cat_frontend container is running..." | |
| else | |
| echo -e "Docker 4cat_frontend container is not running...\nPrinting 4cat_frontend logs:\n\n$(docker container logs 4cat_frontend)" | |
| exit 1 | |
| fi | |
| - name: Run tests | |
| run: | | |
| sleep 30 | |
| echo "::group::Running tests" | |
| docker exec -e PYTHONPATH=/usr/src/app 4cat_backend pytest -v tests/ | |
| echo "::endgroup::" | |
| - name: Print log on failure | |
| if: failure() | |
| run: | | |
| if [ "$(docker ps | grep 4cat)" ]; then | |
| docker cp 4cat_backend:/usr/src/app/data/logs/backend_4cat.log ./backend_4cat.log | |
| echo "::group::Backend logs" | |
| cat backend_4cat.log | |
| echo "4cat.stderr logs" | |
| docker cp 4cat_backend:/usr/src/app/data/logs/4cat.stderr ./4cat.stderr | |
| cat 4cat.stderr | |
| echo "::endgroup::" | |
| else | |
| echo "Docker containers not running; check logs in previous steps" | |
| fi |