Merge pull request #826 from iragm/copilot/fix-ci-tests-failure #2966
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: Test | |
| on: | |
| push: | |
| pull_request: | |
| branches: [master] | |
| jobs: | |
| lint: | |
| name: Lint (ruff via pre-commit) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| - uses: pre-commit/action@v3.0.1 | |
| django-tests: | |
| name: Django tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - run: ./.github/scripts/prepare-ci.sh | |
| - run: docker compose build | |
| - name: Run Django tests in parallel | |
| # Override entrypoint.sh — it ignores its args and unconditionally | |
| # exec's uvicorn/gunicorn, which would never run the test command. | |
| run: docker compose run --rm --entrypoint python3 web -u manage.py test --parallel auto | |
| - name: Print service logs on failure | |
| if: failure() | |
| run: | | |
| echo "=== docker compose ps ===" | |
| docker compose ps -a || true | |
| echo "=== db logs ===" | |
| docker compose logs db || true | |
| echo "=== web logs ===" | |
| docker compose logs web || true | |
| - run: docker compose down | |
| if: always() | |
| selenium-tests: | |
| name: Selenium browser tests | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - run: ./.github/scripts/prepare-ci.sh | |
| - name: Build containers | |
| run: | | |
| docker compose --profile selenium build | |
| - name: Start database first and wait for health | |
| run: | | |
| echo "Starting database container..." | |
| docker compose up -d db | |
| echo "Waiting for database to be healthy (up to 240 seconds)..." | |
| for i in {1..80}; do | |
| STATUS=$(docker inspect --format='{{.State.Health.Status}}' db 2>/dev/null || echo "not_found") | |
| if [ "$STATUS" = "healthy" ]; then | |
| echo "Database is healthy!" | |
| exit 0 | |
| fi | |
| echo "Database status: $STATUS (attempt $i/80)" | |
| sleep 3 | |
| done | |
| echo "ERROR: Database failed to become healthy" | |
| docker compose logs db | |
| exit 1 | |
| - name: Start remaining services | |
| run: | | |
| echo "Starting all services including selenium profile..." | |
| docker compose --profile selenium up -d | |
| echo "Waiting for services to initialize..." | |
| sleep 10 | |
| - name: Wait for services to be ready | |
| run: | | |
| echo "Waiting for services to start..." | |
| for i in {1..24}; do | |
| if docker exec django python3 -c "import django; django.setup()" 2>/dev/null; then | |
| echo "Django service is ready" | |
| break | |
| fi | |
| echo "Waiting for Django... ($i/24)" | |
| sleep 5 | |
| done | |
| for i in {1..12}; do | |
| if docker exec selenium curl -sSL http://localhost:4444/status 2>/dev/null | grep -qE '"ready"[[:space:]]*:[[:space:]]*true'; then | |
| echo "Selenium service is ready" | |
| break | |
| fi | |
| echo "Waiting for Selenium... ($i/12)" | |
| sleep 5 | |
| done | |
| docker compose ps | |
| - name: Install Selenium in Django container | |
| run: | | |
| docker exec -u root django pip install selenium | |
| - name: Run Selenium tests | |
| run: | | |
| docker exec django python3 manage.py test auctions.tests_selenium --tag=selenium -v 2 | |
| - name: Show logs on failure | |
| if: failure() | |
| run: | | |
| echo "=== Database logs ===" | |
| docker compose logs db | |
| echo "=== Web logs ===" | |
| docker compose logs web | |
| echo "=== Selenium logs ===" | |
| docker compose logs selenium | |
| echo "=== Container status ===" | |
| docker compose ps -a |