2022-05-03 10:17:58 -07:00
|
|
|
name: Lint
|
2022-01-25 03:58:11 -08:00
|
|
|
|
2022-08-29 17:11:05 -07:00
|
|
|
# Ensures that only one workflow task will run at a time. Previous builds, if
|
|
|
|
# already in process, will get cancelled. Only the latest commit will be allowed
|
|
|
|
# to run, cancelling any workflows in between
|
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
2022-01-25 03:58:11 -08:00
|
|
|
on:
|
2022-04-20 17:33:08 -07:00
|
|
|
# we build Rust caches on main, so they can be shared by all branches:
|
|
|
|
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
2022-04-11 22:06:37 -07:00
|
|
|
pull_request:
|
2022-01-25 03:58:11 -08:00
|
|
|
branches:
|
2022-04-11 22:06:37 -07:00
|
|
|
- 'main'
|
2022-01-25 03:58:11 -08:00
|
|
|
|
2022-08-22 20:43:18 -07:00
|
|
|
env:
|
|
|
|
CARGO_INCREMENTAL: 0
|
|
|
|
RUST_LOG: info
|
|
|
|
RUST_BACKTRACE: full
|
|
|
|
RUST_LIB_BACKTRACE: full
|
|
|
|
COLORBT_SHOW_HIDDEN: '1'
|
|
|
|
|
2022-01-25 03:58:11 -08:00
|
|
|
jobs:
|
2022-05-05 04:09:21 -07:00
|
|
|
changed-files:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
name: Checks changed-files
|
|
|
|
outputs:
|
|
|
|
rust: ${{ steps.changed-files-rust.outputs.any_changed == 'true' }}
|
|
|
|
workflows: ${{ steps.changed-files-workflows.outputs.any_changed == 'true' }}
|
|
|
|
steps:
|
2022-10-05 14:45:06 -07:00
|
|
|
- uses: actions/checkout@v3.1.0
|
2022-05-05 04:09:21 -07:00
|
|
|
with:
|
|
|
|
persist-credentials: false
|
2022-10-10 17:11:49 -07:00
|
|
|
fetch-depth: 0
|
2022-05-05 04:09:21 -07:00
|
|
|
|
|
|
|
- name: Rust files
|
|
|
|
id: changed-files-rust
|
2022-10-26 14:25:55 -07:00
|
|
|
uses: tj-actions/changed-files@v34.0.0
|
2022-05-05 04:09:21 -07:00
|
|
|
with:
|
|
|
|
files: |
|
|
|
|
**/*.rs
|
|
|
|
**/Cargo.toml
|
|
|
|
**/Cargo.lock
|
|
|
|
clippy.toml
|
|
|
|
.cargo/config.toml
|
2022-05-25 17:27:44 -07:00
|
|
|
.github/workflows/lint.yml
|
2022-05-05 04:09:21 -07:00
|
|
|
|
|
|
|
- name: Workflow files
|
|
|
|
id: changed-files-workflows
|
2022-10-26 14:25:55 -07:00
|
|
|
uses: tj-actions/changed-files@v34.0.0
|
2022-05-05 04:09:21 -07:00
|
|
|
with:
|
|
|
|
files: |
|
|
|
|
.github/workflows/*.yml
|
|
|
|
|
2022-01-25 03:58:11 -08:00
|
|
|
clippy:
|
|
|
|
name: Clippy
|
2022-05-24 02:03:56 -07:00
|
|
|
timeout-minutes: 45
|
2022-01-25 03:58:11 -08:00
|
|
|
runs-on: ubuntu-latest
|
2022-05-05 04:09:21 -07:00
|
|
|
needs: changed-files
|
|
|
|
if: ${{ needs.changed-files.outputs.rust == 'true' }}
|
2022-01-25 03:58:11 -08:00
|
|
|
|
|
|
|
steps:
|
2022-10-05 14:45:06 -07:00
|
|
|
- uses: actions/checkout@v3.1.0
|
2022-01-25 03:58:11 -08:00
|
|
|
with:
|
|
|
|
persist-credentials: false
|
|
|
|
|
2022-09-06 07:49:18 -07:00
|
|
|
- name: Install last version of Protoc
|
|
|
|
uses: arduino/setup-protoc@v1
|
|
|
|
with:
|
|
|
|
version: '3.x'
|
|
|
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
2022-02-16 07:15:19 -08:00
|
|
|
- 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 }}
|
|
|
|
|
2022-04-20 17:33:08 -07:00
|
|
|
- uses: Swatinem/rust-cache@v1
|
2022-09-07 07:32:41 -07:00
|
|
|
with:
|
|
|
|
# TODO: change to shared-key when we switch to Swatinem/rust-cache@v2
|
|
|
|
sharedKey: "clippy-cargo-lock"
|
2022-04-20 17:33:08 -07:00
|
|
|
|
2022-02-16 07:15:19 -08:00
|
|
|
- name: Run clippy action to produce annotations
|
2022-01-25 03:58:11 -08:00
|
|
|
uses: actions-rs/clippy-check@v1.0.7
|
2022-02-16 07:15:19 -08:00
|
|
|
if: ${{ steps.check_permissions.outputs.has-permission }}
|
2022-01-25 03:58:11 -08:00
|
|
|
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
|
|
|
|
|
2022-02-16 07:15:19 -08:00
|
|
|
- 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
|
|
|
|
|
2022-01-25 03:58:11 -08:00
|
|
|
fmt:
|
|
|
|
name: Rustfmt
|
|
|
|
timeout-minutes: 30
|
|
|
|
runs-on: ubuntu-latest
|
2022-05-05 04:09:21 -07:00
|
|
|
needs: changed-files
|
|
|
|
if: ${{ needs.changed-files.outputs.rust == 'true' }}
|
2022-01-25 03:58:11 -08:00
|
|
|
|
|
|
|
steps:
|
2022-10-05 14:45:06 -07:00
|
|
|
- uses: actions/checkout@v3.1.0
|
2022-01-25 03:58:11 -08:00
|
|
|
with:
|
|
|
|
persist-credentials: false
|
|
|
|
|
2022-09-06 07:49:18 -07:00
|
|
|
- name: Install last version of Protoc
|
|
|
|
uses: arduino/setup-protoc@v1
|
|
|
|
with:
|
|
|
|
version: '3.x'
|
|
|
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
2022-06-19 19:10:13 -07:00
|
|
|
- uses: actions-rs/toolchain@v1.0.6
|
2022-01-25 03:58:11 -08:00
|
|
|
with:
|
|
|
|
toolchain: stable
|
|
|
|
components: rustfmt
|
|
|
|
override: true
|
|
|
|
|
2022-09-07 07:32:41 -07:00
|
|
|
# We don't cache `fmt` outputs because the job is quick,
|
|
|
|
# and we want to use the limited GitHub actions cache space for slower jobs.
|
|
|
|
#- uses: Swatinem/rust-cache@v1
|
2022-01-25 03:58:11 -08:00
|
|
|
|
|
|
|
- uses: actions-rs/cargo@v1.0.3
|
|
|
|
with:
|
|
|
|
command: fmt
|
|
|
|
args: --all -- --check
|
2022-04-11 22:06:37 -07:00
|
|
|
|
2022-06-19 19:10:13 -07:00
|
|
|
docs:
|
|
|
|
name: Rust doc
|
|
|
|
timeout-minutes: 30
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: changed-files
|
|
|
|
if: ${{ needs.changed-files.outputs.rust == 'true' }}
|
|
|
|
|
|
|
|
steps:
|
2022-10-05 14:45:06 -07:00
|
|
|
- uses: actions/checkout@v3.1.0
|
2022-06-19 19:10:13 -07:00
|
|
|
with:
|
|
|
|
persist-credentials: false
|
|
|
|
|
2022-09-06 07:49:18 -07:00
|
|
|
- name: Install last version of Protoc
|
|
|
|
uses: arduino/setup-protoc@v1
|
|
|
|
with:
|
|
|
|
version: '3.x'
|
|
|
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
2022-06-19 19:10:13 -07:00
|
|
|
- uses: actions-rs/toolchain@v1.0.6
|
|
|
|
with:
|
|
|
|
toolchain: stable
|
|
|
|
profile: minimal
|
|
|
|
override: true
|
|
|
|
|
|
|
|
- uses: actions-rs/cargo@v1.0.3
|
|
|
|
with:
|
|
|
|
command: doc
|
|
|
|
args: --no-deps --document-private-items --all-features
|
|
|
|
|
2022-04-11 22:06:37 -07:00
|
|
|
actionlint:
|
|
|
|
runs-on: ubuntu-latest
|
2022-05-05 04:09:21 -07:00
|
|
|
continue-on-error: true
|
|
|
|
needs: changed-files
|
|
|
|
if: ${{ needs.changed-files.outputs.workflows == 'true' }}
|
2022-04-11 22:06:37 -07:00
|
|
|
steps:
|
2022-10-05 14:45:06 -07:00
|
|
|
- uses: actions/checkout@v3.1.0
|
2022-10-26 15:19:46 -07:00
|
|
|
- uses: reviewdog/action-actionlint@v1.33.1
|
2022-05-04 15:55:02 -07:00
|
|
|
with:
|
2022-05-05 04:18:27 -07:00
|
|
|
level: warning
|
2022-05-04 15:55:02 -07:00
|
|
|
fail_on_error: false
|
2022-05-25 17:27:44 -07:00
|
|
|
|
|
|
|
codespell:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: changed-files
|
|
|
|
steps:
|
2022-10-05 14:45:06 -07:00
|
|
|
- uses: actions/checkout@v3.1.0
|
2022-05-25 17:27:44 -07:00
|
|
|
- uses: plettich/action-codespell@master
|
|
|
|
with:
|
|
|
|
github_token: ${{ secrets.github_token }}
|
|
|
|
level: warning
|