lint: add better rust formatting #156
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
# If new code is pushed to a PR branch, then cancel in progress workflows for | |
# that PR. Ensures that we don't waste CI time, and returns results quicker. | |
# https://github.com/jonhoo/rust-ci-conf/pull/5 | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os: | |
- ubuntu-latest | |
- macOS-latest | |
- windows-latest | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v1 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
override: true | |
- uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: --all-targets | |
fmt: | |
runs-on: ubuntu-latest | |
name: nightly / fmt | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Install stable | |
# We run in nightly to make use of some features only available there. | |
# Check out `rustfmt.toml` to see which ones. | |
uses: dtolnay/rust-toolchain@nightly | |
with: | |
components: rustfmt | |
- name: cargo fmt --all --check | |
run: cargo fmt --all --check | |
clippy: | |
runs-on: ubuntu-latest | |
name: ${{ matrix.toolchain }} / clippy | |
permissions: | |
contents: read | |
checks: write | |
strategy: | |
fail-fast: false | |
matrix: | |
# Get early warning of new lints which are regularly introduced in beta | |
# channels. | |
toolchain: [ stable, beta ] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Install ${{ matrix.toolchain }} | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ matrix.toolchain }} | |
components: clippy | |
- name: cargo clippy | |
uses: giraffate/clippy-action@v1 | |
with: | |
reporter: 'github-pr-check' | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
coverage: | |
runs-on: ubuntu-latest | |
name: ubuntu / stable / coverage | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Install stable | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
components: llvm-tools-preview | |
- name: cargo install cargo-llvm-cov | |
uses: taiki-e/install-action@cargo-llvm-cov | |
- name: cargo generate-lockfile | |
if: hashFiles('Cargo.lock') == '' | |
run: cargo generate-lockfile | |
- name: cargo llvm-cov | |
run: cargo llvm-cov --locked --all-features --lcov --output-path lcov.info | |
- name: Record Rust version | |
run: echo "RUST=$(rustc --version)" >> "$GITHUB_ENV" | |
- name: Upload to codecov.io | |
uses: codecov/codecov-action@v4 | |
with: | |
fail_ci_if_error: true | |
token: ${{ secrets.CODECOV_TOKEN }} | |
env_vars: OS,RUST |