|
31 | 31 | trusted-public-keys = nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= |
32 | 32 | max-jobs = 4 |
33 | 33 |
|
34 | | - - name: Evaluate PG17 derivation |
35 | | - run: nix build --dry-run .#packages.x86_64-linux."psql_17/bin" --accept-flake-config |
| 34 | + - name: Evaluate PG17 slim derivation |
| 35 | + run: nix build --dry-run .#packages.x86_64-linux."psql_17_slim/bin" --accept-flake-config |
36 | 36 |
|
37 | 37 | detect-version: |
38 | 38 | runs-on: ubuntu-latest |
|
75 | 75 | echo "changed=true" >> $GITHUB_OUTPUT |
76 | 76 | fi |
77 | 77 |
|
78 | | - build-and-release: |
| 78 | + build-test-release: |
79 | 79 | needs: [check, detect-version] |
80 | 80 | if: | |
81 | 81 | github.event_name == 'workflow_dispatch' || |
@@ -111,33 +111,66 @@ jobs: |
111 | 111 | username: ${{ github.actor }} |
112 | 112 | password: ${{ secrets.GITHUB_TOKEN }} |
113 | 113 |
|
114 | | - - name: Get build args from vars.yml |
115 | | - id: args |
| 114 | + # Step 1: Build locally (no push yet) |
| 115 | + - name: Build Docker image locally |
116 | 116 | run: | |
117 | | - nix run nixpkgs#nushell -- -c ' |
118 | | - open ansible/vars.yml |
119 | | - | items { |key value| {name: $key, item: $value} } |
120 | | - | where { |it| ($it.item | describe) == "string" } |
121 | | - | each { |it| $"($it.name)=($it.item)" } |
122 | | - | str join "\n" |
123 | | - | save --append $env.GITHUB_OUTPUT |
124 | | - ' |
125 | | -
|
126 | | - - name: Build and push Docker image |
127 | | - uses: docker/build-push-action@v5 |
128 | | - with: |
129 | | - push: true |
130 | | - build-args: | |
131 | | - ${{ steps.args.outputs.result }} |
132 | | - target: production |
133 | | - tags: | |
134 | | - ghcr.io/${{ needs.detect-version.outputs.owner }}/postgres:${{ needs.detect-version.outputs.tag }} |
135 | | - ghcr.io/${{ needs.detect-version.outputs.owner }}/postgres:latest |
136 | | - platforms: linux/amd64 |
137 | | - cache-from: type=gha,scope=${{ github.ref_name }}-pg17-kbve |
138 | | - cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-pg17-kbve |
139 | | - file: Dockerfile-17 |
| 117 | + docker build \ |
| 118 | + -f Dockerfile-17 \ |
| 119 | + -t pg-test:17 \ |
| 120 | + --target production \ |
| 121 | + . |
| 122 | +
|
| 123 | + # Step 2: Test the image |
| 124 | + - name: Start PostgreSQL container |
| 125 | + run: | |
| 126 | + docker run -d \ |
| 127 | + --name pg-test-17 \ |
| 128 | + -e POSTGRES_PASSWORD=testpass \ |
| 129 | + -e POSTGRES_HOST_AUTH_METHOD=trust \ |
| 130 | + -p 5432:5432 \ |
| 131 | + pg-test:17 |
| 132 | +
|
| 133 | + - name: Wait for PostgreSQL to be ready |
| 134 | + run: | |
| 135 | + echo "Waiting for PostgreSQL to start..." |
| 136 | + for i in $(seq 1 30); do |
| 137 | + if docker exec pg-test-17 pg_isready -U postgres -h localhost 2>/dev/null; then |
| 138 | + echo "PostgreSQL is ready" |
| 139 | + exit 0 |
| 140 | + fi |
| 141 | + echo "Attempt $i/30 - waiting..." |
| 142 | + sleep 2 |
| 143 | + done |
| 144 | + echo "PostgreSQL failed to start" |
| 145 | + docker logs pg-test-17 |
| 146 | + exit 1 |
| 147 | +
|
| 148 | + - name: Run PostgreSQL health checks |
| 149 | + run: | |
| 150 | + echo "=== PostgreSQL version ===" |
| 151 | + docker exec pg-test-17 psql -U supabase_admin -d postgres -c "SELECT version();" |
140 | 152 |
|
| 153 | + echo "=== Installed extensions ===" |
| 154 | + docker exec pg-test-17 psql -U supabase_admin -d postgres -c "SELECT name, default_version FROM pg_available_extensions ORDER BY name;" |
| 155 | +
|
| 156 | + echo "=== Test basic SQL ===" |
| 157 | + docker exec pg-test-17 psql -U supabase_admin -d postgres -c "CREATE TABLE test_health (id serial PRIMARY KEY, data text); INSERT INTO test_health (data) VALUES ('ok'); SELECT * FROM test_health; DROP TABLE test_health;" |
| 158 | +
|
| 159 | + - name: Cleanup test container |
| 160 | + if: always() |
| 161 | + run: docker rm -f pg-test-17 || true |
| 162 | + |
| 163 | + # Step 3: Push to GHCR (only after tests pass) |
| 164 | + - name: Tag and push Docker image |
| 165 | + run: | |
| 166 | + OWNER="${{ needs.detect-version.outputs.owner }}" |
| 167 | + TAG="${{ needs.detect-version.outputs.tag }}" |
| 168 | + docker tag pg-test:17 "ghcr.io/${OWNER}/postgres:${TAG}" |
| 169 | + docker tag pg-test:17 "ghcr.io/${OWNER}/postgres:latest" |
| 170 | + docker push "ghcr.io/${OWNER}/postgres:${TAG}" |
| 171 | + docker push "ghcr.io/${OWNER}/postgres:latest" |
| 172 | +
|
| 173 | + # Step 4: Create release |
141 | 174 | - name: Create GitHub Release |
142 | 175 | uses: softprops/action-gh-release@v1 |
143 | 176 | with: |
|
0 commit comments