feat: add list hero api endpoints and auto generate openapi spec #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Rust | |
| on: | |
| push: | |
| branches: ["main"] | |
| pull_request: | |
| branches: ["main"] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| RUSTFLAGS: -D warnings | |
| jobs: | |
| check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Restore cargo cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Format | |
| run: cargo fmt --all -- --check | |
| - name: Clippy | |
| run: cargo clippy --all-targets --all-features -- -D warnings | |
| - name: Build | |
| run: cargo build --verbose | |
| - name: Unit tests | |
| run: cargo test --lib --bins --verbose | |
| - name: OpenAPI spec is up to date | |
| # The committed openapi.json must match what the code generates. | |
| # If this fails, run `cargo run --bin export_openapi openapi.json` | |
| # locally, commit the result, and push. | |
| run: | | |
| cargo run --quiet --bin export_openapi -- /tmp/generated-openapi.json | |
| if ! diff -q openapi.json /tmp/generated-openapi.json >/dev/null; then | |
| echo "openapi.json is stale relative to the API code." >&2 | |
| diff -u openapi.json /tmp/generated-openapi.json >&2 || true | |
| exit 1 | |
| fi |