diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index afbddc4..893f73e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,3 +72,47 @@ jobs: toolchain: "1.88.0" - uses: Swatinem/rust-cache@v2 - run: cargo test + + api: + name: API Checks + runs-on: ubuntu-latest + services: + postgres: + image: postgres:16-alpine + env: + POSTGRES_USER: reeverb + POSTGRES_PASSWORD: secret + POSTGRES_DB: reeverb_test + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + env: + DATABASE_URL: postgres://reeverb:secret@localhost:5432/reeverb_test + JWT_SECRET: test-secret + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: dtolnay/rust-toolchain@master + with: + toolchain: "1.88.0" + - uses: Swatinem/rust-cache@v2 + - run: cargo install rapina-cli --locked + - run: cargo build --release + - name: Start server + run: | + ./target/release/reeverb & + for i in $(seq 1 30); do + curl -s http://127.0.0.1:3000/health && break + sleep 1 + done + - run: rapina openapi check + - name: Detect breaking changes + if: github.event_name == 'pull_request' + run: | + git fetch origin main + rapina openapi diff --base origin/main diff --git a/prek.toml b/prek.toml new file mode 100644 index 0000000..bb48382 --- /dev/null +++ b/prek.toml @@ -0,0 +1,6 @@ +[[repos]] +repo = "local" +hooks = [ + { id = "fmt", name = "cargo fmt", language = "system", entry = "cargo fmt --all -- --check", pass_filenames = false }, + { id = "clippy", name = "cargo clippy", language = "system", entry = "cargo clippy -- -D warnings", pass_filenames = false, priority = 10 }, +]