diff --git a/.dockerignore b/.dockerignore index 0af8ca6..0fabbf0 100644 --- a/.dockerignore +++ b/.dockerignore @@ -7,4 +7,4 @@ test-data/ *.log *.md .DS_Store -docker-postgres-upgrade/ \ No newline at end of file +docker-postgres-upgrade/ diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index b595f03..150adb7 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -31,7 +31,6 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Log in to the Container registry - if: github.event_name != 'pull_request' uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} @@ -51,15 +50,20 @@ jobs: type=sha - name: Build and push Docker image + id: build uses: docker/build-push-action@v5 with: context: . platforms: linux/amd64,linux/arm64 - push: ${{ github.event_name != 'pull_request' }} + push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max + cache-from: | + type=gha + type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache + cache-to: | + type=gha,mode=max + type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max - name: Output image id: image @@ -97,13 +101,16 @@ jobs: if: matrix.platform == 'linux/arm64' uses: docker/setup-qemu-action@v3 + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Set image name run: | - if [ "${{ github.event_name }}" == "pull_request" ]; then - echo "TEST_IMAGE=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:pr-${{ github.event.pull_request.number }}" >> $GITHUB_ENV - else - echo "TEST_IMAGE=${{ needs.build.outputs.image }}" >> $GITHUB_ENV - fi + echo "TEST_IMAGE=${{ needs.build.outputs.image }}" >> $GITHUB_ENV - name: Pull test image run: | @@ -125,49 +132,69 @@ jobs: -e POSTGRES_DB=testdb \ postgres:${{ matrix.test.from }}-bookworm \ bash -c " + set -e + set -o pipefail + docker-entrypoint.sh postgres & PGPID=\$! sleep 10 - + # Create testuser and test database - psql -U postgres -d testdb </dev/null || true + + # Stop and remove container + docker stop -t 10 $CONTAINER_ID 2>/dev/null || true + docker rm $CONTAINER_ID 2>/dev/null || true + exit 0 - name: Verify upgraded data run: | @@ -176,30 +203,38 @@ jobs: -e POSTGRES_PASSWORD=testpass \ postgres:${{ matrix.test.to }}-bookworm \ bash -c " + set -e + set -o pipefail + docker-entrypoint.sh postgres & PGPID=\$! sleep 10 - + # Verify data - psql -U testuser -d testdb <