zebra/.github/workflows/lint.yml

91 lines
2.3 KiB
YAML
Raw Normal View History

name: Lint Rust files
on:
pull_request:
branches:
- 'main'
paths:
# code and tests
- '**/*.rs'
# dependencies
- '**/Cargo.toml'
- '**/Cargo.lock'
# workflow definitions
- 'clippy.toml'
- '.cargo/config.toml'
# TODO: we might want to run this in a separate workflow in the future for the `actionlint` job
- '.github/workflows/*.yml'
env:
CARGO_INCREMENTAL: 0
RUST_BACKTRACE: full
RUST_LIB_BACKTRACE: full
COLORBT_SHOW_HIDDEN: '1'
jobs:
clippy:
name: Clippy
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.0.1
with:
persist-credentials: false
- name: Check workflow permissions
id: check_permissions
uses: scherermichael-oss/action-has-permission@1.0.6
with:
required-permission: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run clippy action to produce annotations
uses: actions-rs/clippy-check@v1.0.7
if: ${{ steps.check_permissions.outputs.has-permission }}
with:
# GitHub displays the clippy job and its results as separate entries
name: Clippy (stable) Results
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features --all-targets -- -D warnings
- uses: actions-rs/toolchain@v1.0.1
if: ${{ !steps.check_permissions.outputs.has-permission }}
with:
toolchain: stable
override: true
- name: Run clippy manually without annotations
if: ${{ !steps.check_permissions.outputs.has-permission }}
run: cargo clippy --all-features --all-targets -- -D warnings
fmt:
name: Rustfmt
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.0.1
with:
persist-credentials: false
- uses: actions-rs/toolchain@v1.0.1
with:
toolchain: stable
components: rustfmt
override: true
- uses: Swatinem/rust-cache@v1 # TODO: No cache is being found
- uses: actions-rs/cargo@v1.0.3
with:
command: fmt
args: --all -- --check
actionlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.0.1
- uses: reviewdog/action-actionlint@v1.23.0