Skip to content

Commit 7cf3db7

Browse files
committed
feat: add validation via stac-api-validator
Includes a local validation script and a CI job.
1 parent c3d7c14 commit 7cf3db7

File tree

2 files changed

+92
-4
lines changed

2 files changed

+92
-4
lines changed

.github/workflows/cicd.yaml

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
name: stac-fastapi
22
on:
33
push:
4-
branches: [ master ]
4+
branches: [master]
55
pull_request:
6-
branches: [ master ]
6+
branches: [master]
77

88
jobs:
99
test:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
python-version: [ '3.8', '3.9', '3.10']
13+
python-version: ["3.8", "3.9", "3.10"]
1414
timeout-minutes: 10
1515

1616
services:
@@ -118,9 +118,69 @@ jobs:
118118
POSTGRES_HOST_READER: localhost
119119
POSTGRES_HOST_WRITER: localhost
120120
POSTGRES_PORT: 5432
121+
122+
validate:
123+
runs-on: ubuntu-latest
124+
strategy:
125+
fail-fast: false
126+
matrix:
127+
backend: ["sqlalchemy", "pgstac"]
128+
services:
129+
pgstac:
130+
image: ghcr.io/stac-utils/pgstac:v0.6.11
131+
env:
132+
POSTGRES_USER: username
133+
POSTGRES_PASSWORD: password
134+
POSTGRES_DB: postgis
135+
PGUSER: username
136+
PGPASSWORD: password
137+
PGDATABASE: postgis
138+
options: >-
139+
--health-cmd pg_isready
140+
--health-interval 10s
141+
--health-timeout 5s
142+
--health-retries 5
143+
ports:
144+
- 5432:5432
145+
steps:
146+
- name: Check out repository code
147+
uses: actions/checkout@v3
148+
- name: Setup Python
149+
uses: actions/setup-python@v3
150+
with:
151+
python-version: "3.10"
152+
cache: pip
153+
cache-dependency-path: stac_fastapi/pgstac/setup.cfg
154+
- name: Install stac-fastapi and stac-api-validator
155+
run: pip install ./stac_fastapi/api ./stac_fastapi/types ./stac_fastapi/${{ matrix.backend }}[server] stac-api-validator==0.4.1
156+
- name: Run migration
157+
if: ${{ matrix.backend == 'sqlalchemy' }}
158+
run: cd stac_fastapi/sqlalchemy && alembic upgrade head
159+
env:
160+
POSTGRES_USER: username
161+
POSTGRES_PASS: password
162+
POSTGRES_DBNAME: postgis
163+
POSTGRES_HOST: localhost
164+
POSTGRES_PORT: 5432
165+
- name: Load data and validate
166+
run: python -m stac_fastapi.${{ matrix.backend }}.app & ./scripts/wait-for-it.sh localhost:8080 && python ./scripts/ingest_joplin.py http://localhost:8080 && ./scripts/validate http://localhost:8080
167+
env:
168+
POSTGRES_USER: username
169+
POSTGRES_PASS: password
170+
POSTGRES_DBNAME: postgis
171+
POSTGRES_HOST_READER: localhost
172+
POSTGRES_HOST_WRITER: localhost
173+
POSTGRES_PORT: 5432
174+
PGUSER: username
175+
PGPASSWORD: password
176+
PGHOST: localhost
177+
PGDATABASE: postgis
178+
APP_HOST: 0.0.0.0
179+
APP_PORT: 8080
180+
121181
test-docs:
122182
runs-on: ubuntu-latest
123183
steps:
124184
- uses: actions/checkout@v3
125185
- name: Test generating docs
126-
run: make docs
186+
run: make docs

scripts/validate

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env sh
2+
#
3+
# Validate a STAC server using [stac-api-validator](https://github.com/stac-utils/stac-api-validator).
4+
#
5+
# Assumptions:
6+
#
7+
# - You have stac-api-validator installed, e.g. via `pip install stac-api-validator`
8+
# - You've loaded the joplin data, probably using `python ./scripts/ingest_joplin.py http://localhost:8080``
9+
#
10+
# Currently, item-search is not checked, because it crashes stac-api-validator (probably a problem on our side).
11+
12+
set -e
13+
14+
if [ $# -eq 0 ]; then
15+
root_url=http://localhost:8080
16+
else
17+
root_url="$1"
18+
fi
19+
geometry='{"type":"Polygon","coordinates":[[[-94.6884155,37.0595608],[-94.6884155,37.0332547],[-94.6554565,37.0332547],[-94.6554565,37.0595608],[-94.6884155,37.0595608]]]}'
20+
21+
stac-api-validator --root-url "$root_url" \
22+
--conformance core \
23+
--conformance collections \
24+
--collection joplin \
25+
--conformance features \
26+
--geometry "$geometry" \
27+
--conformance filter
28+
# --conformance item-search \ # currently breaks stac-api-validator

0 commit comments

Comments
 (0)