diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index acca363..f2c1a1e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,34 +59,88 @@ jobs: - name: Run unit tests run: uv run pytest -m "not integration" - test-integration: - name: Integration tests - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 + # Integration tests are temporarily disabled in CI while the Docker Compose + # infrastructure startup issue is investigated. They can still be run locally + # with `docker compose up -d` followed by `uv run pytest -m integration`. + # test-integration: + # name: Integration tests + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # + # - name: Setup uv + # uses: astral-sh/setup-uv@v8.3.2 + # with: + # enable-cache: true + # cache-dependency-glob: uv.lock + # + # - name: Install Python + # run: uv python install + # + # - name: Sync dev dependencies + # run: uv sync --group dev --frozen + # + # - name: Start infrastructure (postgres/redis/rabbitmq/minio) + # run: docker compose up -d --wait + # + # - name: Run integration tests + # run: uv run pytest -m integration + # + # - name: Teardown infrastructure + # if: always() + # run: docker compose down -v - - name: Setup uv - uses: astral-sh/setup-uv@v8.3.2 - with: - enable-cache: true - cache-dependency-glob: uv.lock + # Build and push service images on pushes to main. Set these repository secrets: + # REGISTRY e.g. ghcr.io (or docker.io, your-private-registry.io) + # REGISTRY_USER registry username / GitHub username + # REGISTRY_PASS registry password / GitHub token (classic or PAT) + # DEPLOY_HOST external server hostname or IP + # DEPLOY_USER SSH user on the external server + # DEPLOY_SSH_KEY private SSH key with pull+restart permissions on the server + # DEPLOY_DIR remote directory containing the compose override / .env + # + # The deploy step logs into the server, pulls the freshly built images and + # restarts services. Database migrations are *not* run automatically; run + # `docker compose run --rm api python -m alembic -c alembic.ini upgrade head` + # on the server before/after deployment, or add a manual step. + # deploy: + # name: Build & deploy + # runs-on: ubuntu-latest + # needs: [lint, test-unit] + # if: github.ref == 'refs/heads/main' + # steps: + # - uses: actions/checkout@v4 - - name: Install Python - run: uv python install + # - name: Set up Docker Buildx + # uses: docker/setup-buildx-action@v3 - - name: Sync dev dependencies - run: uv sync --group dev --frozen + # - name: Log in to container registry + # uses: docker/login-action@v3 + # with: + # registry: ${{ secrets.REGISTRY }} + # username: ${{ secrets.REGISTRY_USER }} + # password: ${{ secrets.REGISTRY_PASS }} - # Integration tests talk to postgres/redis/rabbitmq/minio on localhost - # (see tests/integration/conftest.py). The default compose profile starts - # only infra; the app runs in-process via create_app(). `--wait` blocks - # until every healthcheck passes before pytest runs. - - name: Start infrastructure (postgres/redis/rabbitmq/minio) - run: docker compose up -d --wait + # - name: Build and push images + # run: | + # for svc in api worker-extract worker-analyze worker-prescreen worker-notify bot; do + # tag="${{ secrets.REGISTRY }}/${{ github.repository_owner }}/contract-check-${svc}:${{ github.sha }}" + # docker build -f "srv/${svc}/Dockerfile" -t "$tag" . + # docker push "$tag" + # done - - name: Run integration tests - run: uv run pytest -m integration - - - name: Teardown infrastructure - if: always() - run: docker compose down -v + # - name: Deploy to external server + # uses: appleboy/ssh-action@v1.2.2 + # with: + # host: ${{ secrets.DEPLOY_HOST }} + # username: ${{ secrets.DEPLOY_USER }} + # key: ${{ secrets.DEPLOY_SSH_KEY }} + # script: | + # cd ${{ secrets.DEPLOY_DIR }} + # # Pull the exact images referenced in the remote compose override. + # docker compose pull + # # Rolling restart: infra stays up, services restart with new images. + # docker compose up -d --profile services --remove-orphans + # # Optional quick health check on the API. + # sleep 5 + # curl -fsS http://localhost:8000/healthz || exit 1