Skip to content

Commit 916d377

Browse files
authored
Add API checks to CI (#3)
## Summary - Adds `rapina openapi check` to CI to verify the committed spec matches the code - Adds `rapina openapi diff --base main` on pull requests to detect breaking API changes Requires rapina-cli v0.5.0 which supports static file-based checks (no running server needed).
1 parent f010216 commit 916d377

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,47 @@ jobs:
7272
toolchain: "1.88.0"
7373
- uses: Swatinem/rust-cache@v2
7474
- run: cargo test
75+
76+
api:
77+
name: API Checks
78+
runs-on: ubuntu-latest
79+
services:
80+
postgres:
81+
image: postgres:16-alpine
82+
env:
83+
POSTGRES_USER: reeverb
84+
POSTGRES_PASSWORD: secret
85+
POSTGRES_DB: reeverb_test
86+
ports:
87+
- 5432:5432
88+
options: >-
89+
--health-cmd pg_isready
90+
--health-interval 10s
91+
--health-timeout 5s
92+
--health-retries 5
93+
env:
94+
DATABASE_URL: postgres://reeverb:secret@localhost:5432/reeverb_test
95+
JWT_SECRET: test-secret
96+
steps:
97+
- uses: actions/checkout@v4
98+
with:
99+
fetch-depth: 0
100+
- uses: dtolnay/rust-toolchain@master
101+
with:
102+
toolchain: "1.88.0"
103+
- uses: Swatinem/rust-cache@v2
104+
- run: cargo install rapina-cli --locked
105+
- run: cargo build --release
106+
- name: Start server
107+
run: |
108+
./target/release/reeverb &
109+
for i in $(seq 1 30); do
110+
curl -s http://127.0.0.1:3000/health && break
111+
sleep 1
112+
done
113+
- run: rapina openapi check
114+
- name: Detect breaking changes
115+
if: github.event_name == 'pull_request'
116+
run: |
117+
git fetch origin main
118+
rapina openapi diff --base origin/main

prek.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[[repos]]
2+
repo = "local"
3+
hooks = [
4+
{ id = "fmt", name = "cargo fmt", language = "system", entry = "cargo fmt --all -- --check", pass_filenames = false },
5+
{ id = "clippy", name = "cargo clippy", language = "system", entry = "cargo clippy -- -D warnings", pass_filenames = false, priority = 10 },
6+
]

0 commit comments

Comments
 (0)