Skip to content

ci: run cargo clippy #19

ci: run cargo clippy

ci: run cargo clippy #19

Workflow file for this run

name: CI
on:
push:
branches: ["main"]
tags-ignore: ["v*"]
paths:
- "api/**"
- "clients/rust/**"
- Cargo.toml
- Cargo.lock
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
env:
RUST_VERSION: "1.94"
RUSTFLAGS: "-Dwarnings"
API_PKG: tinistream-api
CLIENT_PKG: tinistream-client
jobs:
api:
name: Build & test API
runs-on: ubuntu-latest
services:
valkey:
image: valkey/valkey:8-alpine
ports:
- 6379:6379
options: >-
--health-cmd "valkey-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v6
- name: Install Rust toolchain
run: rustup toolchain install ${{ env.RUST_VERSION }} --no-self-update && rustup default ${{ env.RUST_VERSION }}
- name: Setup rust-cache
uses: Swatinem/rust-cache@v2
- name: Install nextest
uses: taiki-e/install-action@v2
with:
tool: nextest@0.9
- name: Run cargo check
run: cargo check --workspace
- name: Run cargo build for API
run: cargo build -p ${{ env.API_PKG }}
- name: Run cargo build for Rust client
run: cargo build -p ${{ env.CLIENT_PKG }}
- name: Run cargo clippy for API
run: cargo clippy -p ${{ env.API_PKG }}
- name: Build tests for API
run: cargo build --tests -p ${{ env.API_PKG }}
- name: Run tests for API
run: cargo nextest run -p ${{ env.API_PKG }}
env:
STREAMER_API_KEY: ${{ secrets.STREAMER_API_KEY }}
STREAMER_SECRET_KEY: ${{ secrets.STREAMER_SECRET_KEY }}
- name: Run API server
run: |
cargo run -p tinistream & SERVER_PID=$!
echo "SERVER_PID=$SERVER_PID" >> $GITHUB_ENV
env:
STREAMER_API_KEY: ${{ secrets.STREAMER_API_KEY }}
STREAMER_SECRET_KEY: ${{ secrets.STREAMER_SECRET_KEY }}
- name: Wait for server to be ready
run: |
timeout 30 bash -c 'until curl -f http://localhost:8000/api/health; do sleep 2; done'
- name: Check if OpenAPI spec matches server
run: |
curl -f -o spec/openapi.json.current http://localhost:8000/api/docs/openapi.json
if ! cmp -s spec/openapi.json spec/openapi.json.current; then
echo "::error::OpenAPI spec in repo doesn't match running server. Please update spec/openapi.json"
echo "Differences:"
diff spec/openapi.json spec/openapi.json.current || true
exit 1
else
echo "::notice::OpenAPI spec in repo matches running server."
fi
rm spec/openapi.json.current
- name: Stop API server
if: always()
run: |
if [ ! -z "$SERVER_PID" ]; then
kill $SERVER_PID || true
fi