name: Rust
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
jobs:
format:
name: cargo fmt --check
runs-on: ${{ github.repository_owner == 'grafana' && 'ubuntu-x64-small' || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9
with:
toolchain: stable
components: rustfmt
- name: Run formatting check
run: make rust/fmt/check
clippy:
name: cargo clippy
runs-on: ${{ github.repository_owner == 'grafana' && 'ubuntu-x64-small' || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9
with:
toolchain: stable
components: clippy
- name: Run clippy
run: cargo clippy --locked --workspace --all-targets --all-features -- --deny warnings
doc-tests:
name: cargo test --doc
runs-on: ${{ github.repository_owner == 'grafana' && 'ubuntu-x64-small' || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9
with:
toolchain: stable
- name: Run doc tests
run: cargo test --doc --locked --all-features
test:
name: cargo test (${{ matrix.arch.name }}, ${{ matrix.libc.name }})
runs-on: ${{ matrix.arch.runner }}
strategy:
fail-fast: false
matrix:
arch:
- name: x64
runner: ${{ github.repository_owner == 'grafana' && 'ubuntu-x64-small' || 'ubuntu-latest' }}
- name: arm64
runner: ${{ github.repository_owner == 'grafana' && 'ubuntu-arm64-large' || 'ubuntu-24.04-arm' }}
libc:
- name: glibc
base_image: "rust:trixie"
- name: musl
base_image: "rust:alpine"
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with:
persist-credentials: false
- name: Run tests
run: docker build --progress=plain --build-arg BASE_IMAGE=${{ matrix.libc.base_image }} -f ci/test.Dockerfile .