Last active
December 13, 2024 17:55
-
-
Save chris/99198b5cef7df3daa57df93f070c41bb to your computer and use it in GitHub Desktop.
Example of GitHub action that sets up Postgres 16 and PostGIS 3 and uses psql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test | |
| on: | |
| push: | |
| paths: | |
| - '.github/workflows/**' | |
| - 'go/somemodule/**' | |
| pull_request: | |
| paths: | |
| - '.github/workflows/**' | |
| - 'go/somemodule/**' | |
| jobs: | |
| test: | |
| name: Test somemodule Go code | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgis/postgis:16-3.4 | |
| env: | |
| # must specify password for PG Docker container image, see: https://registry.hub.docker.com/_/postgres?tab=description&page=1&name=10 | |
| POSTGRES_PASSWORD: password | |
| POSTGRES_DB: your_test_db_name | |
| ports: | |
| - 5432:5432 | |
| # needed because the postgres container does not provide a healthcheck | |
| options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
| steps: | |
| - name: Install Go | |
| uses: actions/setup-go@v2 | |
| with: | |
| go-version: 1.14.x | |
| - name: Checkout code | |
| uses: actions/checkout@v2 | |
| - name: Import DB seed data | |
| run: psql -d postgresql://postgres@localhost/your_test_db_name -f your_seed_data.sql | |
| working-directory: ./test/data | |
| env: | |
| PGPASSWORD: password | |
| - name: Test some module | |
| working-directory: ./go/somemodule | |
| run: go test | |
| env: | |
| CI_DB_URL: postgresql://postgres:password@localhost:5432/your_test_db_name |
I get this error:
pg_dump: error: server version: 16.4 (Debian 16.4-1.pgdg110+2); pg_dump version: 14.15 (Ubuntu 14.15-1.pgdg22.04+1)
pg_dump: error: aborting because of server version mismatch
Author
@JWesorick per the error message, it looks like it's running the postgres install from your Ubuntu version (Ubuntu 14 uses Postgres 14 from what I can see). This gist uses ubuntu-latest, which is Ubuntu 24 (which has Postgres 16). So, you'd likely need to either up your Ubuntu version, or use an older Postgis image (or get a newer Postgres/psql installed on your Ubuntu), depending on which version(s) match your production/desired use.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thx, very helpful