@@ -82,32 +82,118 @@ jobs:
82
82
cache-from : type=gha
83
83
cache-to : type=gha, mode=max
84
84
85
- # test:
86
- # runs-on: ubuntu-latest
87
- # steps:
88
- # - uses: actions/checkout@v4
89
- # - uses: docker/setup-buildx-action@v3
90
- # - name: Build and Cache Docker layers
91
- # uses: docker/bake-action@master
92
- # with:
93
- # push: false
94
- # load: true
95
- # allow:
96
- # network.host
97
- # files: |-
98
- # docker-compose.yml
99
- # docker-compose-cache.json
100
- # - name: Run docker compose
101
- # run: |
102
- # docker compose up -d pgstac
85
+ check-pypgstac-base :
86
+ runs-on : ubuntu-latest
87
+ permissions :
88
+ pull-requests : read
89
+ outputs :
90
+ pypgstac-image-exists : ${{ steps.pypgstac_image_check.outputs.pypgstac-image-exists }}
91
+ pypgstac-image-hash : ${{ steps.pypgstac_image_check.outputs.pypgstac-image-hash }}
92
+
93
+ steps :
94
+ - uses : actions/checkout@v4
95
+ - name : Check if pypgstac-base docker image needs to be updated
96
+ id : pypgstac_image_check
97
+ run : |
98
+ set -e
99
+ IMAGE=stac-utils/pypgstac-base
100
+ HASH=$(git log -1 --pretty="format:%h" -- docker/pypgstac)
101
+ TAG="\"$HASH\""
102
+ TOKEN=$(curl -s https://ghcr.io/token\?scope\="repository:$IMAGE:pull" | jq -r .token)
103
+ EXISTS=$(curl -s -H "Authorization: Bearer $TOKEN" https://ghcr.io/v2/$IMAGE/tags/list | jq "try(any(.tags[]; . == $TAG))")
104
+ echo "pypgstac-image-exists=$EXISTS" >>$GITHUB_OUTPUT
105
+ echo "pypgstac-image-hash=$HASH" >>$GITHUB_OUTPUT
106
+ echo "pypgstac-image-exists: $EXISTS"
107
+ echo "pypgstac-image-hash: $HASH"
103
108
104
- # - name: Execute tests in the running services
105
- # run: |
106
- # scripts/test --nobuild
109
+ buildpypgstacbase :
110
+ name : Build and push base postgres image
111
+ needs : [check-pypgstac-base]
112
+ if : ${{ needs.check-pypgstac-base.outputs.pypgstac-image-exists != 'true' }}
113
+ runs-on : ubuntu-latest
114
+ steps :
115
+ - name : Display inputs
116
+ run : |
117
+ echo "Inputs:"
118
+ echo ${{ needs.check-pypgstac-base.outputs.pypgstac-image-exists }}
119
+ echo ${{ needs.check-pypgstac-base.outputs.pypgstac-image-hash }}
120
+ - uses : actions/checkout@v4
121
+ - uses : docker/setup-buildx-action@v3
122
+ - name : Log in to the Container registry
123
+ uses : docker/login-action@v3
124
+ with :
125
+ registry : ${{ env.REGISTRY }}
126
+ username : ${{ github.actor }}
127
+ password : ${{ secrets.GITHUB_TOKEN }}
128
+ - name : Build and Push Base Postgres
129
+ uses : docker/build-push-action@v6
130
+ with :
131
+ platforms : linux/amd64
132
+ context : .
133
+ target : pypgstac-base
134
+ file : docker/pgstac/Dockerfile
135
+ tags : ghcr.io/stac-utils/pypgstac-base:${{ needs.check-pypgstac-base.outputs.pypgstac-image-hash }}
136
+ push : true
137
+ cache-from : type=gha
138
+ cache-to : type=gha, mode=max
139
+ wheels :
140
+ runs-on : ubuntu-latest
141
+ steps :
142
+ - uses : actions/checkout@v4
143
+ - name : Build wheels
144
+ uses : PyO3/maturin-action@v1
145
+ with :
146
+ working-directory : src/pypgstac
147
+ target : x86_64
148
+ args : --release --out /home/runner/work/pgstac/pgstac/dist
149
+ sccache : ' true'
150
+ manylinux : auto
151
+ - name : Upload wheels
152
+ uses : actions/upload-artifact@v4
153
+ with :
154
+ name : wheels
155
+ path : /home/runner/work/pgstac/pgstac/dist/*
156
+ if-no-files-found : error
157
+ test :
158
+ needs : [buildpg, buildpypgstacbase, wheels]
159
+ if : ${{ always() && !failure() && !cancelled() }}
160
+ runs-on : ubuntu-latest
161
+ container : ghcr.io/stac-utils/pypgstac-base:${{ needs.check-pypgstac-base.outputs.pypgstac-image-hash }}
162
+ env :
163
+ PGHOST : localhost
164
+ PGUSER : postgres
165
+ PGPASSWORD : postgres
166
+ PGDATABASE : postgres
167
+ services :
168
+ pg :
169
+ image : ghcr.io/stac-utils/pgstac-base:${{ needs.check-pgstac-base.outputs.pgstac-image-hash }}
170
+ env :
171
+ POSTGRES_PASSWORD : postgres
172
+ POSTGRES_USER : postgres
173
+ POSTGRES_DATABASE : postgres
174
+ options : >-
175
+ --health-cmd pg_isready
176
+ --health-interval 10s
177
+ --health-timeout 5s
178
+ --health-retries 5
107
179
108
- # - name: Stop Docker
109
- # run: |
110
- # scripts/nuke
180
+ steps :
181
+ - uses : actions/checkout@v4
182
+ - name : Get Wheel
183
+ uses : actions/download-artifact@v4
184
+ with :
185
+ name : wheels
186
+ path : /tmp/wheels
187
+ - name : Install pypgstac
188
+ run : |
189
+ cd /home/runner/work/pgstac/pgstac/src/pypgstac
190
+ source $UV_PROJECT_ENVIRONMENT/bin/activate
191
+ uv pip install --offline --find-links /tmp/wheels pypgstac
192
+ - name : Run tests
193
+ run : |
194
+ cd /home/runner/work/pgstac/pgstac/src/pypgstac
195
+ source $UV_PROJECT_ENVIRONMENT/bin/activate
196
+ $SCRIPTS/test
111
197
112
198
# linux_x86_64:
113
199
# runs-on: ubuntu-latest
@@ -218,54 +304,4 @@ jobs:
218
304
# path: /home/runner/work/pgstac/pgstac/dist/*
219
305
# if-no-files-found: error
220
306
221
- # test:
222
- # name: test
223
- # needs: [buildpg, linux_x86_64]
224
- # runs-on: ubuntu-latest
225
- # container:
226
- # env:
227
- # PGHOST: localhost
228
- # UV_FROZEN: true
229
- # UV_FIND_LINKS: /tmp/wheels
230
- # UV_PROJECT_ENVIRONMENT: /home/runner/work/pgstac/pgstac/src/pypgstac/.venv
231
- # VIRTUAL_ENVIRONMENT: /home/runner/work/pgstac/pgstac/src/pypgstac/.venv
232
-
233
- # services:
234
- # postgres:
235
- # image: ghcr.io/stac-utils/pgstac-postgres:latest
236
- # env:
237
- # POSTGRES_PASSWORD: postgres
238
- # POSTGRES_USER: postgres
239
- # POSTGRES_DATABASE: postgres
240
- # options: >-
241
- # --health-cmd pg_isready
242
- # --health-interval 10s
243
- # --health-timeout 5s
244
- # --health-retries 5
245
-
246
- # steps:
247
- # - uses: actions/checkout@v4
248
- # - name: Setup UV
249
- # uses: astral-sh/setup-uv@v3
250
- # with:
251
- # enable-cache: true
252
- # - name: Get Wheel
253
- # uses: actions/download-artifact@v4
254
- # with:
255
- # name: wheels-x86_64
256
- # path: /tmp/wheels
257
- # - name: Install pypgstac
258
- # run: |
259
- # cd /home/runner/work/pgstac/pgstac/src/pypgstac
260
- # uv venv
261
- # source $UV_PROJECT_ENVIRONMENT/bin/activate
262
- # uv pip install psycopg[binary] psycopg-pool
263
- # uv sync --frozen --no-install-project --extra test --extra dev
264
- # uv pip install --offline --find-links /tmp/wheels pypgstac
265
-
266
-
267
- # - name: Run tests
268
- # run: |
269
- # cd /home/runner/work/pgstac/pgstac/src/pypgstac
270
- # source $UV_PROJECT_ENVIRONMENT/bin/activate
271
- # $SCRIPTS/test
307
+ #
0 commit comments