fix: CI/CD robustness #93
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: CI/CD | |
| on: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| branches: [main] | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ["3.12"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Run tests | |
| run: pytest tests/ -v --tb=short -n auto --dist loadfile | |
| docker: | |
| runs-on: ubuntu-latest | |
| needs: test | |
| if: github.ref == 'refs/heads/main' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build Docker image | |
| run: docker build -t resgov:${{ github.sha }} . | |
| - name: Test Docker image | |
| run: | | |
| docker run -d --name resgov-test \ | |
| -p 8080:8080 \ | |
| -e RESGOV_ADMIN_TOKEN=test-ci-token \ | |
| -e RESGOV_UPSTREAM_API_KEY=test \ | |
| resgov:${{ github.sha }} | |
| for i in $(seq 1 60); do | |
| if curl -sf http://localhost:8080/health > /dev/null 2>&1; then | |
| echo "Container ready after ${i}s" | |
| break | |
| fi | |
| echo "Waiting for container... (${i}/60)" | |
| sleep 1 | |
| done | |
| curl -sf http://localhost:8080/health || (docker logs resgov-test && exit 1) | |
| docker stop resgov-test |