Skip to content

ci: add self-hosted PR workflow for same-repo pull requests #748

ci: add self-hosted PR workflow for same-repo pull requests

ci: add self-hosted PR workflow for same-repo pull requests #748

Workflow file for this run

name: CI_rs
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
jobs:
lint:
name: Lint
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Install HDF5
run: sudo apt-get update && sudo apt-get install -y libhdf5-dev
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo fmt --all -- --check
- name: Run clippy
run: cargo clippy --workspace --all-targets -- -D warnings
test:
name: Test
runs-on: ubuntu-22.04
env:
# CI release tests don't need DWARF debug info, and disabling it keeps
# target artifacts small enough to avoid runner disk exhaustion on cache misses.
CARGO_PROFILE_RELEASE_DEBUG: 0
steps:
- uses: actions/checkout@v4
- name: Install HDF5
run: sudo apt-get update && sudo apt-get install -y libhdf5-dev
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@nextest
- uses: Swatinem/rust-cache@v2
# tensor4all-hdf5 is kept out of nextest because its dlopen-based tests
# fail under nextest's per-process execution model.
- name: Run tests (non-HDF5)
run: cargo nextest run --release --workspace --exclude tensor4all-hdf5
- name: Run HDF5 tests
run: cargo test --release -p tensor4all-hdf5
coverage:
name: Coverage
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- uses: taiki-e/install-action@cargo-llvm-cov
- uses: Swatinem/rust-cache@v2
- name: Generate coverage JSON
run: cargo llvm-cov --workspace --exclude tensor4all-hdf5 --json --output-path coverage.json
- name: Check per-file thresholds
run: python3 scripts/check-coverage.py coverage.json
rollup-rs:
runs-on: ubuntu-latest
needs:
- lint
- test
- coverage
if: always()
steps:
- name: All Rust checks passed
if: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
run: exit 0
- name: Some Rust checks failed or cancelled
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
run: exit 1