name: Rust
on:
push:
branches:
- main
pull_request:
release:
types: [published]
workflow_dispatch:
concurrency:
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
LIB_PACKAGE_NAME: builder_derive_more
jobs:
rustfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: cargo fmt
run: cargo fmt --all --check --verbose
cargo:
needs: rustfmt
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
toolchain:
- "1.64" - stable
- beta
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.event_name == 'push'}}
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
components: clippy
- name: cargo check
run: cargo check --workspace --all-targets --verbose
- name: cargo check --no-default-features
run: cargo check --workspace --all-targets --no-default-features --verbose
- name: cargo check --all-features
run: cargo check --workspace --all-targets --all-features --verbose
- name: cargo test (default features)
run: cargo test --workspace --all-targets --verbose
- name: cargo test --no-default-features
run: cargo test --workspace --all-targets --no-default-features --verbose
- name: cargo test --all-features
run: cargo test --workspace --all-targets --all-features --verbose
- name: cargo test --doc (default features)
run: cargo test --workspace --doc --verbose
- name: cargo test --doc --no-default-features
run: cargo test --workspace --doc --no-default-features --verbose
- name: cargo test --doc --all-features
run: cargo test --workspace --doc --all-features --verbose
- name: cargo clippy (stable only)
if: ${{ matrix.toolchain == 'stable' }}
run: cargo clippy --workspace --all-targets --all-features --no-deps --verbose -- --deny warnings
- name: doc --document-private-items (stable only)
if: ${{ matrix.toolchain == 'stable' }}
run: cargo doc --workspace --all-features --no-deps --document-private-items --verbose
cross:
needs: cargo
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
toolchain:
- stable
- beta
target:
- aarch64-unknown-linux-gnu
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.event_name == 'push'}}
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
targets: ${{ matrix.target }}
- name: Install cross
run: cargo install cross --locked
- name: cross check
run: cross check --workspace --all-targets --target ${{ matrix.target }} --verbose
- name: cross check --no-default-features
run: cross check --workspace --all-targets --no-default-features --target ${{ matrix.target }} --verbose
- name: cross check --all-features
run: cross check --workspace --all-targets --all-features --target ${{ matrix.target }} --verbose
miri:
needs: cargo
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.event_name == 'push'}}
- uses: dtolnay/rust-toolchain@nightly
with:
components: miri, rust-src
- name: cargo miri test (default features)
run: cargo miri test --workspace --verbose
- name: cargo miri test --no-default-features
run: cargo miri test --workspace --no-default-features --verbose
- name: cargo miri test --all-features
run: cargo miri test --workspace --all-features --verbose
deny:
needs: cargo
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: EmbarkStudios/cargo-deny-action@v1
with:
command: check bans licenses sources
publish:
if: ${{ github.event_name == 'release' }}
needs:
- cargo
- cross
- miri
- deny
runs-on: ubuntu-latest
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Publish crate (library)
if: ${{ env.CARGO_REGISTRY_TOKEN != '' }}
run: cargo publish --no-verify --package ${{ env.LIB_PACKAGE_NAME }} --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
codecov:
needs: cargo
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.event_name == 'push'}}
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@cargo-llvm-cov
- name: Generate coverage
run: cargo llvm-cov --workspace --all-features --lcov --output-path lcov.info
- name: Upload coverage
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: lcov.info
fail_ci_if_error: true