-
Notifications
You must be signed in to change notification settings - Fork 1
86 lines (75 loc) · 3.13 KB
/
Copy pathopenapi-validate.yml
File metadata and controls
86 lines (75 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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