Skip to content

Commit c635ab1

Browse files
committed
Add OpenAPI spec drift check to CI
Runs the test suite with OPENAPI=1 and fails if docs/openapi.yml has uncommitted changes, ensuring the checked-in spec stays in sync with the actual API responses. https://claude.ai/code/session_01F4qY2LA6JYqsvdLi4xkLVA
1 parent 28c50fb commit c635ab1

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,40 @@ jobs:
4545
DB_USER: user
4646
DB_PASSWORD: password
4747
run: bundle exec rake
48+
OpenAPI:
49+
runs-on: ubuntu-22.04
50+
env:
51+
ALCHEMY_BRANCH: main
52+
steps:
53+
- uses: actions/checkout@v4
54+
- name: Set up Ruby
55+
uses: ruby/setup-ruby@v1
56+
with:
57+
ruby-version: "3.4"
58+
bundler-cache: true
59+
- name: Restore apt cache
60+
id: apt-cache
61+
uses: actions/cache@v4
62+
with:
63+
path: /home/runner/apt/cache
64+
key: apt-sqlite-
65+
- name: Install SQLite headers
66+
run: |
67+
sudo mkdir -p /home/runner/apt/cache
68+
sudo apt-get update -qq
69+
sudo apt-get install -qq --fix-missing libsqlite3-dev -o dir::cache::archives="/home/runner/apt/cache"
70+
sudo chown -R runner /home/runner/apt/cache
71+
- name: Regenerate OpenAPI spec
72+
env:
73+
RAILS_ENV: test
74+
OPENAPI: "1"
75+
run: bundle exec rake
76+
- name: Check for OpenAPI spec drift
77+
run: |
78+
if ! git diff --exit-code docs/openapi.yml; then
79+
echo "::error::docs/openapi.yml is out of date. Run 'OPENAPI=1 bundle exec rspec' locally and commit the result."
80+
exit 1
81+
fi
4882
Vitest:
4983
runs-on: ubuntu-24.04
5084
env:

0 commit comments

Comments
 (0)