|
| 1 | +name: Integration Postgres |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - '.github/workflows/integration-postgres.yml' |
| 7 | + - 'tests/integration/postgres/**' |
| 8 | + workflow_run: |
| 9 | + workflows: ['Release'] |
| 10 | + branches: [main] |
| 11 | + types: [completed] |
| 12 | + workflow_dispatch: |
| 13 | + inputs: |
| 14 | + image_tag: |
| 15 | + description: 'supabase/edge-runtime image tag to test against (e.g. v1.2.3). Defaults to the latest release.' |
| 16 | + required: false |
| 17 | + default: '' |
| 18 | + |
| 19 | +permissions: |
| 20 | + contents: read |
| 21 | + |
| 22 | +jobs: |
| 23 | + test: |
| 24 | + if: >- |
| 25 | + github.event_name == 'pull_request' || |
| 26 | + github.event_name == 'workflow_dispatch' || |
| 27 | + github.event.workflow_run.conclusion == 'success' |
| 28 | + name: test (${{ matrix.db.name }}) |
| 29 | + runs-on: blacksmith-4vcpu-ubuntu-2404 |
| 30 | + |
| 31 | + strategy: |
| 32 | + fail-fast: false |
| 33 | + matrix: |
| 34 | + db: |
| 35 | + - name: postgres |
| 36 | + image: postgres:17 |
| 37 | + initdb_args: '' |
| 38 | + - name: orioledb |
| 39 | + image: orioledb/orioledb:latest-pg17 |
| 40 | + initdb_args: '--locale=C' |
| 41 | + |
| 42 | + services: |
| 43 | + postgres: |
| 44 | + image: ${{ matrix.db.image }} |
| 45 | + env: |
| 46 | + POSTGRES_USER: postgres |
| 47 | + POSTGRES_PASSWORD: postgres |
| 48 | + POSTGRES_DB: postgres |
| 49 | + POSTGRES_INITDB_ARGS: ${{ matrix.db.initdb_args }} |
| 50 | + ports: |
| 51 | + - 5432:5432 |
| 52 | + options: >- |
| 53 | + --health-cmd pg_isready |
| 54 | + --health-interval 5s |
| 55 | + --health-timeout 5s |
| 56 | + --health-retries 10 |
| 57 | +
|
| 58 | + steps: |
| 59 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4 |
| 60 | + |
| 61 | + - name: Init OrioleDB extension |
| 62 | + if: matrix.db.name == 'orioledb' |
| 63 | + run: | |
| 64 | + psql postgres://postgres:postgres@localhost:5432/postgres \ |
| 65 | + -c "CREATE EXTENSION IF NOT EXISTS orioledb;" \ |
| 66 | + -c "ALTER DATABASE postgres SET default_table_access_method = 'orioledb';" |
| 67 | +
|
| 68 | + - name: Resolve image tag |
| 69 | + id: tag |
| 70 | + run: | |
| 71 | + if [ -n "${{ inputs.image_tag }}" ]; then |
| 72 | + echo "value=${{ inputs.image_tag }}" >> "$GITHUB_OUTPUT" |
| 73 | + else |
| 74 | + tag=$(gh release view --json tagName -q .tagName) |
| 75 | + echo "value=${tag}" >> "$GITHUB_OUTPUT" |
| 76 | + fi |
| 77 | + env: |
| 78 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 79 | + |
| 80 | + - name: Extract edge-runtime binary from image |
| 81 | + run: | |
| 82 | + docker create --name er supabase/edge-runtime:${{ steps.tag.outputs.value }} |
| 83 | + docker cp er:/usr/local/bin/edge-runtime ./edge-runtime |
| 84 | + docker rm er |
| 85 | + chmod +x ./edge-runtime |
| 86 | +
|
| 87 | + - name: Start edge-runtime |
| 88 | + run: | |
| 89 | + DATABASE_URL=${{ env.DATABASE_URL }} \ |
| 90 | + ./edge-runtime start \ |
| 91 | + --main-service tests/integration/postgres \ |
| 92 | + --port 9998 \ |
| 93 | + --quiet & |
| 94 | + echo $! > edge-runtime.pid |
| 95 | + env: |
| 96 | + DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres |
| 97 | + |
| 98 | + - name: Wait for healthy |
| 99 | + run: | |
| 100 | + for i in $(seq 1 60); do |
| 101 | + if curl -sf http://localhost:9998/_internal/health > /dev/null 2>&1; then |
| 102 | + echo "edge-runtime is healthy" |
| 103 | + exit 0 |
| 104 | + fi |
| 105 | + sleep 0.5 |
| 106 | + done |
| 107 | + echo "edge-runtime did not become healthy within 30s" |
| 108 | + exit 1 |
| 109 | +
|
| 110 | + - name: Run tests |
| 111 | + run: | |
| 112 | + result=$(curl -s http://localhost:9998/) |
| 113 | + echo "$result" | jq -r ' |
| 114 | + .results[] | |
| 115 | + if .passed then |
| 116 | + "[PASS] \(.name) (\(.durationMs)ms)" |
| 117 | + else |
| 118 | + "[FAIL] \(.name) (\(.durationMs)ms)\n \(.error)" |
| 119 | + end |
| 120 | + ' |
| 121 | + echo "" |
| 122 | + echo "$result" | jq -r '"total: \(.passed + .failed) | passed: \(.passed) | failed: \(.failed) | \(.totalMs)ms"' |
| 123 | + echo "$result" | jq -e '.ok == true' > /dev/null |
| 124 | +
|
| 125 | + - name: Stop edge-runtime |
| 126 | + if: always() |
| 127 | + run: kill $(cat edge-runtime.pid) || true |
0 commit comments