Skip to content

Commit 30904e9

Browse files
authored
feat: commit OpenAPI spec with CI freshness check (#220)
1 parent 67d1901 commit 30904e9

7 files changed

Lines changed: 6162 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,52 @@ jobs:
167167
exit 1
168168
fi
169169
170+
openapi-spec:
171+
name: "Verify OpenAPI spec is up to date"
172+
runs-on: ubuntu-latest
173+
needs: changes
174+
if: needs.changes.outputs.agentex == 'true'
175+
timeout-minutes: 10
176+
177+
steps:
178+
- name: Checkout
179+
uses: actions/checkout@v4
180+
181+
- name: Set up Python
182+
uses: actions/setup-python@v5
183+
with:
184+
python-version: '3.12'
185+
186+
- name: Install uv
187+
uses: astral-sh/setup-uv@v4
188+
with:
189+
version: "0.7.3"
190+
enable-cache: true
191+
192+
- name: Install dependencies
193+
working-directory: ./agentex
194+
run: uv sync
195+
196+
- name: Regenerate OpenAPI spec
197+
working-directory: ./agentex
198+
run: uv run python scripts/generate_openapi_spec.py --output openapi.yaml
199+
200+
- name: Verify committed spec matches generated spec
201+
working-directory: ./agentex
202+
run: |
203+
if ! git diff --exit-code openapi.yaml; then
204+
echo "❌ The committed openapi.yaml is out of date."
205+
echo "Run 'uv run python scripts/generate_openapi_spec.py --output openapi.yaml' from agentex/ and commit the result."
206+
exit 1
207+
fi
208+
echo "✅ openapi.yaml is up to date"
209+
170210
# This job is used as a required status check for branch protection
171211
# It will pass if the conditional jobs either passed or were skipped
172212
ci-status:
173213
name: "CI Status Check"
174214
runs-on: ubuntu-latest
175-
needs: [changes, test, docs]
215+
needs: [changes, test, docs, openapi-spec]
176216
if: always()
177217
steps:
178218
- name: Check CI status
@@ -191,7 +231,12 @@ jobs:
191231
echo "❌ Documentation build failed"
192232
exit 1
193233
fi
194-
234+
235+
if [ "${{ needs.openapi-spec.result }}" != "success" ]; then
236+
echo "❌ OpenAPI spec freshness check failed"
237+
exit 1
238+
fi
239+
195240
echo "✅ All checks passed"
196241
else
197242
echo "No agentex changes detected - skipping tests and docs"

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,10 @@ repos:
1818
files: ^agentex-ui/.*\.(ts|tsx|js|jsx)$
1919
pass_filenames: true
2020

21+
- id: agentex-openapi-spec
22+
name: Regenerate AgentEx OpenAPI spec
23+
entry: bash -c 'cd agentex && make gen-openapi && git add openapi.yaml'
24+
language: system
25+
files: ^agentex/(src/.*|scripts/generate_openapi_spec\.py)$
26+
pass_filenames: false
27+

agentex/Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ migration: ## Create a new migration (usage: make migration NAME="migration_name
6868
apply-migrations: ## Apply database migrations
6969
cd database/migrations && alembic upgrade head
7070

71+
#
72+
# OpenAPI Spec
73+
#
74+
75+
gen-openapi: ## Regenerate openapi.yaml from the FastAPI app
76+
@uv run --frozen python scripts/generate_openapi_spec.py --output openapi.yaml
77+
7178
#
7279
# Documentation
7380
#

0 commit comments

Comments
 (0)