Skip to content

Commit

Permalink
Use a PostgreSQL service container in the GitHub workflow (#3680)
Browse files Browse the repository at this point in the history
* Use a PostgreSQL service container in the GitHub workflow

As documented here: https://docs.github.com/en/actions/use-cases-and-examples/using-containerized-services/creating-postgresql-service-containers

* Update CHANGELOG.md
  • Loading branch information
robstradling authored Nov 15, 2024
1 parent 67056f5 commit e0740d4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
29 changes: 15 additions & 14 deletions .github/workflows/test_pgdb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@ jobs:

integration-and-unit-tests:
runs-on: ubuntu-latest

services:
postgres:
image: postgres
env:
POSTGRES_HOST_AUTH_METHOD: trust
options: >-
--name pgsql
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

Expand All @@ -44,20 +59,6 @@ jobs:
- name: Build before tests
run: go mod download && go build ./...

- name: Run PostgreSQL
run: docker run --rm -d --name=pgsql -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust postgres:latest

- name: Wait for PostgreSQL
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
with:
timeout_seconds: 15
max_attempts: 3
retry_on: error
command: docker exec pgsql psql -U postgres -c "SELECT 1"

- name: Get PostgreSQL logs
run: docker logs pgsql 2>&1

- name: Run integration tests
run: ./integration/integration_test.sh
env:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Add PostgreSQL quota manager and storage backend by @robstradling in https://github.com/google/trillian/pull/3644
* PostgreSQL deployment example by @robstradling in https://github.com/google/trillian/pull/3675
* PostgreSQL documentation / consistency fixes by @robstradling in https://github.com/google/trillian/pull/3676
* Use a PostgreSQL service container in the GitHub workflow by @robstradling in https://github.com/google/trillian/pull/3680

### Misc

Expand Down

0 comments on commit e0740d4

Please sign in to comment.