feat: pin versions and detect PostGIS version for image tags #8
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: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| include: | |
| - pg_version: "17.9" | |
| pgvector_version: "0.8.2" | |
| - pg_version: "16.13" | |
| pgvector_version: "0.8.2" | |
| - pg_version: "15.17" | |
| pgvector_version: "0.8.2" | |
| - pg_version: "14.22" | |
| pgvector_version: "0.8.2" | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Build Docker image | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: . | |
| load: true | |
| tags: postgres-test:pg${{ matrix.pg_version }} | |
| build-args: | | |
| PG_VERSION=${{ matrix.pg_version }} | |
| PGVECTOR_VERSION=${{ matrix.pgvector_version }} | |
| - name: Start PostgreSQL container and test extensions | |
| run: | | |
| IMAGE_TAG="postgres-test:pg${{ matrix.pg_version }}" | |
| echo "Testing image: $IMAGE_TAG" | |
| docker run -d --name test-db \ | |
| -e POSTGRES_PASSWORD=test \ | |
| -e POSTGRES_USER=test \ | |
| -e POSTGRES_DB=test \ | |
| $IMAGE_TAG \ | |
| postgres -c shared_preload_libraries=vector | |
| echo "Waiting for PostgreSQL to start..." | |
| sleep 15 | |
| echo "PostgreSQL logs:" | |
| docker logs test-db | |
| echo "Checking PostGIS version..." | |
| docker exec test-db psql -U test -d test -c "SELECT postgis_full_version();" | |
| echo "Checking pgvector extension version..." | |
| docker exec test-db psql -U test -d test -c "CREATE EXTENSION IF NOT EXISTS vector; SELECT extversion FROM pg_extension WHERE extname = 'vector';" | |
| echo "Attempting to create a table with a vector column and insert data..." | |
| docker exec test-db psql -U test -d test -c "CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3)); INSERT INTO items (embedding) VALUES ('[1,2,3]'), ('[4,5,6]'); SELECT COUNT(*) FROM items;" | |
| - name: Stop and remove container | |
| if: always() | |
| run: | | |
| docker stop test-db || true | |
| docker rm test-db || true |