- Split validation into 4 granular CI steps (Config, Timescale, Vector, Hybrid) - Added cleanup step for Docker images in CI - Created SQL test scripts in tests/ for robustness
104 lines
3.1 KiB
YAML
104 lines
3.1 KiB
YAML
name: 🚀 Docker Build and Push
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
pg_version: [15, 16, 17, 18]
|
|
steps:
|
|
- name: 📥 Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: 🛠️ Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: 🔐 Login to Gitea Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: gitea.killinger.fr
|
|
username: maxime.killinger
|
|
password: ${{ secrets.DOCKER_TOKEN }}
|
|
|
|
- name: 📦 Build Docker image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
load: true
|
|
build-args: |
|
|
PG_VERSION=${{ matrix.pg_version }}
|
|
tags: |
|
|
postgres-ts-vectors:pg${{ matrix.pg_version }}-test
|
|
|
|
- name: 🧪 Test image - Start container
|
|
run: |
|
|
docker run -d --name test-pg${{ matrix.pg_version }} \
|
|
-e POSTGRES_PASSWORD=testpass \
|
|
postgres-ts-vectors:pg${{ matrix.pg_version }}-test
|
|
|
|
# Wait for PostgreSQL to be ready
|
|
echo "Waiting for PostgreSQL to start..."
|
|
for i in {1..30}; do
|
|
if docker exec test-pg${{ matrix.pg_version }} pg_isready -U postgres > /dev/null 2>&1; then
|
|
echo "PostgreSQL is ready!"
|
|
break
|
|
fi
|
|
sleep 2
|
|
done
|
|
|
|
- name: ⚙️ Setup Tests
|
|
run: |
|
|
# Wait for valid startup
|
|
sleep 10
|
|
docker cp tests/ test-pg${{ matrix.pg_version }}:/tmp/tests/
|
|
|
|
- name: 🧪 Test 1: Configuration
|
|
run: docker exec test-pg${{ matrix.pg_version }} psql -U postgres -f /tmp/tests/test-1-config.sql
|
|
|
|
- name: 🧪 Test 2: TimescaleDB
|
|
run: docker exec test-pg${{ matrix.pg_version }} psql -U postgres -f /tmp/tests/test-2-timescale.sql
|
|
|
|
- name: 🧪 Test 3: VectorChord
|
|
run: docker exec test-pg${{ matrix.pg_version }} psql -U postgres -f /tmp/tests/test-3-vector.sql
|
|
|
|
- name: 🧪 Test 4: Hybrid Scenarios
|
|
run: docker exec test-pg${{ matrix.pg_version }} psql -U postgres -f /tmp/tests/test-4-hybrid.sql
|
|
|
|
- name: 🧹 Cleanup test container
|
|
if: always()
|
|
run: docker rm -f test-pg${{ matrix.pg_version }} || true
|
|
|
|
- name: 🚀 Push Docker image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: true
|
|
build-args: |
|
|
PG_VERSION=${{ matrix.pg_version }}
|
|
tags: |
|
|
gitea.killinger.fr/maxime.killinger/postgres-ts-vectors:pg${{ matrix.pg_version }}
|
|
|
|
- name: 🏷️ Tag latest (PG18 only)
|
|
if: matrix.pg_version == 18
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: true
|
|
build-args: |
|
|
PG_VERSION=18
|
|
tags: |
|
|
gitea.killinger.fr/maxime.killinger/postgres-ts-vectors:latest
|
|
|
|
- name: 🧹 Cleanup Docker images
|
|
if: always()
|
|
run: |
|
|
docker rmi postgres-ts-vectors:pg${{ matrix.pg_version }}-test || true
|
|
docker image prune -f
|
|
|
|
|