Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions .github/workflows/openapi-validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: OpenAPI validate

# Validates the generated meos-openapi.json against the OpenAPI 3.1 spec on
# every PR that touches the parser, generator, or meta files — and on every
# push to master. Fails the build if the projection is not a valid OpenAPI
# document. Runs the same regenerate path a downstream consumer would: clone
# MobilityDB master for headers, parse with libclang, produce the enriched
# catalog, project to OpenAPI, validate.

on:
pull_request:
paths:
- 'parser/**'
- 'generator/**'
- 'meta/**'
- 'generate_openapi.py'
- 'run.py'
- 'requirements.txt'
- '.github/workflows/openapi-validate.yml'
push:
branches: [master]
workflow_dispatch:

jobs:
openapi-validate:
name: Regenerate + validate meos-openapi.json
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.11"

# libclang (Python wheel) needs the system C headers MEOS depends on
# so types like `size_t`, `json_object *`, `GSERIALIZED *`, … resolve
# to their real names instead of degrading to `int` / `int *`. Mirror
# the same install set as MobilityAPI's vendor-drift workflow so the
# two regenerate paths produce byte-identical catalogs.
- name: Install dev headers for libclang sysroot
run: |
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends \
clang libclang-dev \
libjson-c-dev libgsl-dev libproj-dev libgeos-dev \
postgresql-server-dev-16

- name: Clone MobilityDB master (MEOS headers source)
run: |
git clone --depth 1 https://github.com/MobilityDB/MobilityDB \
"$RUNNER_TEMP/mobilitydb"
echo "MOBILITYDB_HEADERS=$RUNNER_TEMP/mobilitydb/meos/include" \
>> "$GITHUB_ENV"

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install openapi-spec-validator

- name: Regenerate the catalog (parse + reconcile + enrich in one step)
run: python3 run.py "$MOBILITYDB_HEADERS"

- name: Project to OpenAPI 3.1
run: python3 generate_openapi.py

- name: Validate meos-openapi.json against OpenAPI 3.1
run: |
python3 -c "
import json
from openapi_spec_validator import OpenAPIV31SpecValidator
spec = json.load(open('output/meos-openapi.json'))
# OpenAPIV31SpecValidator(spec).validate() raises on violation,
# returns None on success. Works with openapi-spec-validator 0.9.x.
OpenAPIV31SpecValidator(spec).validate()
print(f\"::notice::meos-openapi.json conforms to OpenAPI 3.1 — \"
f\"{len(spec.get('paths', {}))} paths, \"
f\"{len(spec.get('components', {}).get('schemas', {}))} schemas.\")
"

- name: Upload meos-openapi.json as artefact
uses: actions/upload-artifact@v4
with:
name: meos-openapi
path: output/meos-openapi.json
if-no-files-found: error
Loading