From 69a4d5a08458fd8205d6e314506e8529a189deca Mon Sep 17 00:00:00 2001 From: agatha Date: Sun, 10 May 2026 19:19:14 -0400 Subject: [PATCH] CI: Try different approach to running PostgreSQL --- .gitea/workflows/pipeline.yml | 97 ++++++++++++++++++++--------------- 1 file changed, 55 insertions(+), 42 deletions(-) diff --git a/.gitea/workflows/pipeline.yml b/.gitea/workflows/pipeline.yml index 929c0d3..f1847c7 100644 --- a/.gitea/workflows/pipeline.yml +++ b/.gitea/workflows/pipeline.yml @@ -65,18 +65,20 @@ jobs: api-unit: name: API Unit Tests runs-on: ubuntu-latest + container: + image: ghcr.io/astral-sh/uv:python3.12-bookworm steps: - - uses: actions/checkout@v4 - - - name: Install uv + - name: Install Node (for JS actions) run: | - curl -LsSf https://astral.sh/uv/install.sh | sh - echo "$HOME/.local/bin" >> $GITHUB_PATH + apt-get update -qq + apt-get install -y --no-install-recommends nodejs ca-certificates curl + + - uses: actions/checkout@v4 - name: Cache uv store uses: actions/cache@v3 with: - path: ~/.cache/uv + path: /root/.cache/uv key: uv-${{ hashFiles('api/uv.lock') }} restore-keys: uv- @@ -102,53 +104,68 @@ jobs: api-lint: name: API Lint runs-on: ubuntu-latest + container: + image: ghcr.io/astral-sh/uv:python3.12-bookworm steps: + - name: Install Node (for JS actions) + run: | + apt-get update -qq + apt-get install -y --no-install-recommends nodejs ca-certificates curl + - uses: actions/checkout@v4 - name: Run Ruff - run: | - curl -LsSf https://astral.sh/uv/install.sh | sh - ~/.local/bin/uvx ruff check . + run: uvx ruff check . working-directory: api api-integration: name: API Integration Tests runs-on: ubuntu-latest - timeout-minutes: 15 + container: + image: ghcr.io/astral-sh/uv:python3.12-bookworm + services: + postgres: + image: postgres:16 + env: + POSTGRES_USER: reactbin + POSTGRES_PASSWORD: reactbin + POSTGRES_DB: reactbin_test + options: >- + --health-cmd pg_isready + --health-interval 5s + --health-timeout 5s + --health-retries 10 + minio: + image: quay.io/minio/minio + env: + MINIO_ROOT_USER: minioadmin + MINIO_ROOT_PASSWORD: minioadmin + options: >- + --entrypoint sh + --health-cmd "curl -f http://localhost:9000/minio/health/live || exit 1" + --health-interval 5s + --health-timeout 5s + --health-retries 10 + cmd: ["-c", "minio server /data"] steps: + - name: Install Node and curl (for JS actions and mc) + run: | + apt-get update -qq + apt-get install -y --no-install-recommends nodejs ca-certificates curl + - uses: actions/checkout@v4 - - name: Start services + - name: Create MinIO bucket run: | - docker run -d --name ci-postgres \ - --network container:$(hostname) \ - -e POSTGRES_USER=reactbin \ - -e POSTGRES_PASSWORD=reactbin \ - -e POSTGRES_DB=reactbin_test \ - postgres:16 - docker run -d --name ci-minio \ - --network container:$(hostname) \ - -e MINIO_ROOT_USER=minioadmin \ - -e MINIO_ROOT_PASSWORD=minioadmin \ - quay.io/minio/minio server /data - - - name: Wait for services and create bucket - run: | - until docker exec ci-postgres pg_isready -U reactbin; do sleep 2; done curl -fsSL https://dl.min.io/client/mc/release/linux-amd64/mc -o /tmp/mc chmod +x /tmp/mc - until /tmp/mc alias set local http://localhost:9000 minioadmin minioadmin; do sleep 2; done - /tmp/mc mb local/reactbin-test - - - name: Install uv - run: | - curl -LsSf https://astral.sh/uv/install.sh | sh - echo "$HOME/.local/bin" >> $GITHUB_PATH + until /tmp/mc alias set local http://minio:9000 minioadmin minioadmin; do sleep 2; done + /tmp/mc mb local/reactbin-test --ignore-existing - name: Cache uv store uses: actions/cache@v3 with: - path: ~/.cache/uv + path: /root/.cache/uv key: uv-${{ hashFiles('api/uv.lock') }} restore-keys: uv- @@ -160,9 +177,9 @@ jobs: run: uv run pytest tests/integration/ -q working-directory: api env: - TEST_DATABASE_URL: postgresql+asyncpg://reactbin:reactbin@localhost/reactbin_test - DATABASE_URL: postgresql+asyncpg://reactbin:reactbin@localhost/reactbin_test - S3_ENDPOINT_URL: http://localhost:9000 + TEST_DATABASE_URL: postgresql+asyncpg://reactbin:reactbin@postgres/reactbin_test + DATABASE_URL: postgresql+asyncpg://reactbin:reactbin@postgres/reactbin_test + S3_ENDPOINT_URL: http://minio:9000 S3_BUCKET_NAME: reactbin-test S3_ACCESS_KEY_ID: minioadmin S3_SECRET_ACCESS_KEY: minioadmin @@ -172,10 +189,6 @@ jobs: OWNER_USERNAME: testowner OWNER_PASSWORD: testpass - - name: Stop services - if: always() - run: docker stop ci-postgres ci-minio || true && docker rm ci-postgres ci-minio || true - # ── Image builds (tag-only, gated on all jobs) ──────────────────────────────── build-api: @@ -226,4 +239,4 @@ jobs: push: true tags: | ${{ vars.REGISTRY }}/${{ vars.REPOSITORY }}/reactbin-ui:${{ github.ref_name }} - ${{ vars.REGISTRY }}/${{ vars.REPOSITORY }}/reactbin-ui:latest + ${{ vars.REGISTRY }}/${{ vars.REPOSITORY }}/reactbin-ui:latest \ No newline at end of file