Skip to content
Open
Show file tree
Hide file tree
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
50 changes: 50 additions & 0 deletions .github/workflows/spec-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Admin API Spec Check
permissions:
contents: read

on:
push:
branches: [ main ]
paths:
- 'src/amp/admin/**'
- 'specs/**'
- 'scripts/fetch_spec.py'
- 'scripts/generate_models.py'
- '.github/workflows/spec-check.yml'
pull_request:
branches: [ main ]
paths:
- 'src/amp/admin/**'
- 'specs/**'
- 'scripts/fetch_spec.py'
- 'scripts/generate_models.py'
- '.github/workflows/spec-check.yml'
schedule:
- cron: '0 9 * * 1' # Monday 9am UTC

jobs:
spec-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v6

- name: Set up Python
run: uv python install 3.12

- name: Install dependencies
run: uv sync --group dev

- name: Check spec matches upstream
run: uv run python scripts/fetch_spec.py --check

- name: Verify models are up to date
run: |
uv run python scripts/generate_models.py
uv run ruff format src/amp/admin/models.py
git diff --exit-code src/amp/admin/models.py || {
echo "::error::Generated models are out of date. Run 'make update-models' and commit the changes."
exit 1
}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ htmlcov/

# UV/pip cache
.uv/
uv.lock

# Data directories (local development)
# Large datasets should be downloaded on-demand or mounted via ConfigMaps
Expand Down
19 changes: 17 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SHELL := /bin/bash
.PHONY: test test-unit test-integration test-all clean setup lint format generate-models
.PHONY: test test-unit test-integration test-all clean setup lint format generate-models fetch-spec update-models check-spec

# Use UV for all commands
PYTHON = uv run --env-file .test.env
Expand Down Expand Up @@ -71,10 +71,22 @@ format:
@echo "✨ Formatting code..."
$(PYTHON) ruff format .

# Generate Pydantic models from OpenAPI spec
# Spec and model generation
fetch-spec:
@echo "📥 Fetching latest Amp Admin API OpenAPI spec..."
$(PYTHON) python scripts/fetch_spec.py

generate-models:
@echo "🏗️ Generating Pydantic models from OpenAPI spec..."
$(PYTHON) python scripts/generate_models.py
@echo "🎨 Formatting generated models..."
$(PYTHON) ruff format src/amp/admin/models.py

update-models: fetch-spec generate-models

check-spec:
@echo "🔍 Checking Amp Admin API spec for drift..."
$(PYTHON) python scripts/fetch_spec.py --check

# Setup development environment
setup:
Expand Down Expand Up @@ -138,6 +150,9 @@ help:
@echo " make test-clickhouse - Run ClickHouse tests"
@echo " make test-snowflake - Run Snowflake tests"
@echo " make test-performance - Run performance tests"
@echo " make fetch-spec - Fetch latest OpenAPI spec"
@echo " make update-models - Fetch spec + regenerate models"
@echo " make check-spec - Check spec for upstream drift"
@echo " make lint - Lint code with ruff"
@echo " make format - Format code with ruff"
@echo " make test-setup - Start test databases"
Expand Down
Loading
Loading