veza/.github/workflows/rust-ci.yml
senke ff1c044965
Some checks failed
Veza CI / Rust (Stream Server) (push) Waiting to run
Veza CI / Notify on failure (push) Blocked by required conditions
Security Scan / Secret Scanning (gitleaks) (push) Waiting to run
Veza CI / Backend (Go) (push) Has been cancelled
Veza CI / Frontend (Web) (push) Has been cancelled
Backend API CI / test-unit (push) Failing after 16m59s
Stream Server CI / test (push) Failing after 27m27s
Rust CI / test-and-lint (push) Failing after 27m29s
Backend API CI / test-integration (push) Failing after 31m21s
ci: cache rustup, go tools and fix go.sum path to shave ~5min per run
Previous runs were burning ~90-120s on rustup download, ~60-90s on
cargo-audit/cargo-tarpaulin source install, and ~60-90s on Go module
download because setup-go couldn't find go.sum at the repo root.

Fixes:
  - setup-go cache-dependency-path: veza-backend-api/go.sum
    (was silently failing with "Dependencies file is not found")
  - New actions/cache step for ~/.rustup + ~/.cargo/bin keyed on
    stable+components — skips rustup install on warm cache
  - New actions/cache step for ~/go/bin keyed on tool set — skips
    go install @latest on warm cache
  - cargo install cargo-audit / cargo-tarpaulin gated on
    `command -v` so they're no-ops when cached
  - Add restore-keys to the Cargo deps cache for partial hits when
    Cargo.lock changes
  - rust-ci.yml now watches its own path in the trigger (was a bug:
    edits to the workflow didn't retrigger it)

Expected impact on a warm run: Go jobs -90s, Rust jobs -3min.
First run after this commit will still be slow (cache warm-up).
2026-04-14 15:39:06 +02:00

85 lines
3.3 KiB
YAML

name: Rust CI
on:
push:
branches: [main]
paths:
- "veza-stream-server/**"
- ".github/workflows/rust-ci.yml"
pull_request:
branches: [main]
paths:
- "veza-stream-server/**"
- ".github/workflows/rust-ci.yml"
env:
GIT_SSL_NO_VERIFY: "true"
NODE_TLS_REJECT_UNAUTHORIZED: "0"
jobs:
test-and-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Cache rustup toolchain
id: rustup-cache
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: |
~/.rustup
~/.cargo/bin
key: ${{ runner.os }}-rustup-stable-clippy-tarpaulin
- name: Set up Rust
if: steps.rustup-cache.outputs.cache-hit != 'true'
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --component clippy
- name: Add ~/.cargo/bin to PATH
run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Cache Cargo deps and target
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: |
~/.cargo/registry
~/.cargo/git
veza-stream-server/target
key: ${{ runner.os }}-cargo-${{ hashFiles('veza-stream-server/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Clippy lint
# NOTE: -D warnings temporarily lifted (see ci.yml Clippy step).
run: cargo clippy
working-directory: veza-stream-server
- name: Run tests
run: cargo test --workspace --timeout 300
working-directory: veza-stream-server
- name: Install cargo-tarpaulin
# Cached via rustup-cache (~/.cargo/bin). Skip rebuild on warm cache.
run: command -v cargo-tarpaulin >/dev/null || cargo install cargo-tarpaulin --locked
- name: Measure coverage
run: cargo tarpaulin --out json --output-dir target/coverage --timeout 300 --skip-clean
working-directory: veza-stream-server
- name: Enforce coverage threshold (>= 50%)
run: |
COVERAGE=$(cat target/coverage/tarpaulin-report.json | python3 -c "import sys,json; print(f'{json.load(sys.stdin).get(\"coverage\", 0):.1f}')")
echo "Rust coverage: ${COVERAGE}%"
COV_INT=$(echo "$COVERAGE" | cut -d. -f1)
if [ "$COV_INT" -lt 50 ]; then
echo "::error::Rust coverage ${COVERAGE}% is below the 50% threshold"
exit 1
fi
echo "::notice::Rust coverage ${COVERAGE}% meets the >= 50% threshold"
working-directory: veza-stream-server
- name: Upload coverage report
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
with:
name: rust-coverage
path: veza-stream-server/target/coverage/tarpaulin-report.json