|
72 | 72 | echo "$ARGS" >> $GITHUB_OUTPUT
|
73 | 73 | echo "EOF" >> $GITHUB_OUTPUT
|
74 | 74 |
|
75 |
| - - run: docker context create builders |
76 |
| - - uses: docker/setup-buildx-action@v3 |
77 |
| - with: |
78 |
| - endpoint: builders |
79 |
| - - uses: docker/build-push-action@v5 |
80 |
| - with: |
81 |
| - load: true |
82 |
| - context: . |
83 |
| - file: Dockerfile-${{ env.PGMAJOR }} |
84 |
| - target: production |
85 |
| - build-args: | |
86 |
| - ${{ steps.args.outputs.result }} |
87 |
| - tags: supabase/postgres:${{ steps.settings.outputs.postgres-version }},supabase_postgres |
88 |
| - cache-from: | |
89 |
| - type=gha,scope=${{ github.ref_name }}-${{ steps.settings.outputs.postgres-version }}-${{ matrix.arch }} |
90 |
| - type=gha,scope=${{ github.base_ref }}-${{ steps.settings.outputs.postgres-version }}-${{ matrix.arch }} |
91 |
| - cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-${{ steps.settings.outputs.postgres-version }}-${{ matrix.arch }} |
92 |
| - |
93 |
| - - name: Start Postgres |
94 |
| - run: | |
95 |
| - docker run --rm --pull=never \ |
96 |
| - -e POSTGRES_PASSWORD=${{ env.POSTGRES_PASSWORD }} \ |
97 |
| - -p ${{ env.POSTGRES_PORT }}:5432 \ |
98 |
| - --name supabase_postgres \ |
99 |
| - -d supabase/postgres:${{ steps.settings.outputs.postgres-version }} |
100 |
| -
|
101 |
| - - name: Install psql |
102 |
| - run: | |
103 |
| - sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' |
104 |
| - wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - |
105 |
| - sudo apt update |
106 |
| - sudo apt install -y --no-install-recommends postgresql-client-${{ env.PGMAJOR }} |
107 |
| -
|
108 |
| - - name: Install pg_prove |
109 |
| - run: sudo cpan -T TAP::Parser::SourceHandler::pgTAP |
110 |
| - env: |
111 |
| - SHELL: /bin/bash |
112 |
| - |
113 |
| - - name: Wait for healthy database |
114 |
| - run: | |
115 |
| - count=0 |
116 |
| - until [ "$(docker inspect -f '{{.State.Health.Status}}' "$container")" == "healthy" ]; do |
117 |
| - exit=$? |
118 |
| - count=$((count + 1)) |
119 |
| - if [ $count -ge "$retries" ]; then |
120 |
| - echo "Retry $count/$retries exited $exit, no more retries left." |
121 |
| - docker stop -t 2 "$container" |
122 |
| - return $exit |
123 |
| - fi |
124 |
| - sleep 1; |
125 |
| - done; |
126 |
| - echo "$container container is healthy" |
127 |
| - env: |
128 |
| - retries: 20 |
129 |
| - container: supabase_postgres |
130 |
| - |
131 |
| - - name: Run tests |
132 |
| - run: pg_prove migrations/tests/test.sql |
133 |
| - env: |
134 |
| - PGHOST: localhost |
135 |
| - PGPORT: ${{ env.POSTGRES_PORT }} |
136 |
| - PGDATABASE: postgres |
137 |
| - PGUSER: supabase_admin |
138 |
| - PGPASSWORD: ${{ env.POSTGRES_PASSWORD }} |
139 |
| - |
140 |
| - - name: Check migrations are idempotent |
141 |
| - run: | |
142 |
| - for sql in ./migrations/db/migrations/*.sql; do |
143 |
| - echo "$0: running $sql" |
144 |
| - psql -v ON_ERROR_STOP=1 --no-password --no-psqlrc -f "$sql" |
145 |
| - done |
146 |
| - env: |
147 |
| - PGHOST: localhost |
148 |
| - PGPORT: ${{ env.POSTGRES_PORT }} |
149 |
| - PGDATABASE: postgres |
150 |
| - PGUSER: supabase_admin |
151 |
| - PGPASSWORD: ${{ env.POSTGRES_PASSWORD }} |
152 |
| - |
153 |
| - - name: Update Dockerfile.dbmate version |
154 |
| - run: | |
155 |
| - sed -i 's/%VERSION%/${{ env.PGMAJOR }}/g' migrations/Dockerfile.dbmate |
156 | 75 | #TODO PR Convert to develop branch flakeurl
|
157 | 76 | - name: verify schema.sql is committed
|
158 | 77 | run: |
|
|
0 commit comments