|
| 1 | +name: OAuth integration |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - packages/pg/lib/client.js |
| 7 | + - packages/pg/lib/connection-parameters.js |
| 8 | + - packages/pg/lib/connection.js |
| 9 | + - packages/pg/lib/crypto/sasl.js |
| 10 | + - packages/pg-protocol/src/serializer.ts |
| 11 | + - packages/pg/test/integration/client/oauth-tests.js |
| 12 | + - packages/pg/test/oauth-postgres/** |
| 13 | + - .github/workflows/oauth-integration.yml |
| 14 | + push: |
| 15 | + branches: [master] |
| 16 | + paths: |
| 17 | + - packages/pg/lib/client.js |
| 18 | + - packages/pg/lib/connection-parameters.js |
| 19 | + - packages/pg/lib/connection.js |
| 20 | + - packages/pg/lib/crypto/sasl.js |
| 21 | + - packages/pg-protocol/src/serializer.ts |
| 22 | + - packages/pg/test/integration/client/oauth-tests.js |
| 23 | + - packages/pg/test/oauth-postgres/** |
| 24 | + - .github/workflows/oauth-integration.yml |
| 25 | + workflow_dispatch: |
| 26 | + |
| 27 | +permissions: |
| 28 | + contents: read |
| 29 | + |
| 30 | +jobs: |
| 31 | + test: |
| 32 | + runs-on: ubuntu-latest |
| 33 | + timeout-minutes: 10 |
| 34 | + env: |
| 35 | + OAUTH_TEST_PGHOST: localhost |
| 36 | + OAUTH_TEST_PGPORT: 55433 |
| 37 | + OAUTH_TEST_PGUSER: oauth_test |
| 38 | + OAUTH_TEST_PGDATABASE: oauth_test |
| 39 | + OAUTH_TEST_TOKEN: node-postgres-test-token |
| 40 | + steps: |
| 41 | + - uses: actions/checkout@v4 |
| 42 | + with: |
| 43 | + persist-credentials: false |
| 44 | + - name: Setup node |
| 45 | + uses: actions/setup-node@v4 |
| 46 | + with: |
| 47 | + node-version: 22 |
| 48 | + cache: yarn |
| 49 | + - run: yarn install --frozen-lockfile |
| 50 | + - run: yarn build |
| 51 | + - uses: docker/setup-buildx-action@v3 |
| 52 | + - name: Build OAuth PostgreSQL image |
| 53 | + uses: docker/build-push-action@v6 |
| 54 | + with: |
| 55 | + context: packages/pg/test/oauth-postgres |
| 56 | + load: true |
| 57 | + tags: node-postgres-oauth |
| 58 | + cache-from: type=gha,scope=oauth-postgres |
| 59 | + cache-to: type=gha,mode=max,scope=oauth-postgres |
| 60 | + - name: Start OAuth PostgreSQL |
| 61 | + run: | |
| 62 | + docker run --detach --rm \ |
| 63 | + --name node-postgres-oauth \ |
| 64 | + --env POSTGRES_USER=postgres \ |
| 65 | + --env POSTGRES_PASSWORD=postgres \ |
| 66 | + --env POSTGRES_DB=oauth_test \ |
| 67 | + --env PGDATA=/var/lib/postgresql/data \ |
| 68 | + --publish 55433:5432 \ |
| 69 | + node-postgres-oauth |
| 70 | + - name: Wait for PostgreSQL |
| 71 | + run: | |
| 72 | + for attempt in $(seq 1 30); do |
| 73 | + if docker exec node-postgres-oauth pg_isready; then |
| 74 | + exit 0 |
| 75 | + fi |
| 76 | + sleep 1 |
| 77 | + done |
| 78 | + exit 1 |
| 79 | + - name: Test OAuth authentication |
| 80 | + run: node packages/pg/test/integration/client/oauth-tests.js |
| 81 | + - name: Show PostgreSQL logs |
| 82 | + if: failure() |
| 83 | + run: docker logs node-postgres-oauth || true |
| 84 | + - name: Stop PostgreSQL |
| 85 | + if: always() |
| 86 | + run: docker stop node-postgres-oauth || true |
0 commit comments