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
|
|
|
|
2022-08-22 20:43:18 -07:00
|
|
|
env:
|
2023-04-12 23:56:21 -07:00
|
|
|
CARGO_INCREMENTAL: ${{ vars.CARGO_INCREMENTAL }}
|
|
|
|
RUST_LOG: ${{ vars.RUST_LOG }}
|
|
|
|
RUST_BACKTRACE: ${{ vars.RUST_BACKTRACE }}
|
|
|
|
RUST_LIB_BACKTRACE: ${{ vars.RUST_LIB_BACKTRACE }}
|
|
|
|
COLORBT_SHOW_HIDDEN: ${{ vars.COLORBT_SHOW_HIDDEN }}
|
2022-08-22 20:43:18 -07:00
|
|
|
|
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:
|
2023-06-09 17:59:58 -07:00
|
|
|
- uses: actions/checkout@v3.5.3
|
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
|
2023-07-30 14:10:57 -07:00
|
|
|
uses: tj-actions/changed-files@v37.5.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
|
2023-07-30 14:10:57 -07:00
|
|
|
uses: tj-actions/changed-files@v37.5.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:
|
2023-06-09 17:59:58 -07:00
|
|
|
- uses: actions/checkout@v3.5.3
|
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
|
2023-06-05 19:05:31 -07:00
|
|
|
uses: arduino/setup-protoc@v2.0.0
|
2022-09-06 07:49:18 -07:00
|
|
|
with:
|
2023-01-10 13:22:03 -08:00
|
|
|
# TODO: increase to latest version after https://github.com/arduino/setup-protoc/issues/33 is fixed
|
2023-06-05 19:05:31 -07:00
|
|
|
version: '23.x'
|
2022-09-06 07:49:18 -07:00
|
|
|
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 }}
|
|
|
|
|
2023-05-10 07:25:41 -07:00
|
|
|
# Setup Rust with stable toolchain and default profile
|
|
|
|
- name: Setup Rust
|
|
|
|
run: |
|
|
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain=stable --profile=default
|
|
|
|
|
2023-07-04 19:09:45 -07:00
|
|
|
- uses: Swatinem/rust-cache@v2.5.1
|
2022-09-07 07:32:41 -07:00
|
|
|
with:
|
2023-05-10 07:25:41 -07:00
|
|
|
shared-key: "clippy-cargo-lock"
|
2022-04-20 17:33:08 -07:00
|
|
|
|
2023-05-10 07:25:41 -07:00
|
|
|
# TODO: keep this action until we find a better solution
|
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
|
|
|
- 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:
|
2023-06-09 17:59:58 -07:00
|
|
|
- uses: actions/checkout@v3.5.3
|
2022-01-25 03:58:11 -08:00
|
|
|
with:
|
|
|
|
persist-credentials: false
|
2023-05-18 09:44:39 -07:00
|
|
|
- uses: r7kamura/rust-problem-matchers@v1.3.0
|
2022-01-25 03:58:11 -08:00
|
|
|
|
2022-09-06 07:49:18 -07:00
|
|
|
- name: Install last version of Protoc
|
2023-06-05 19:05:31 -07:00
|
|
|
uses: arduino/setup-protoc@v2.0.0
|
2022-09-06 07:49:18 -07:00
|
|
|
with:
|
2023-01-10 13:22:03 -08:00
|
|
|
# TODO: increase to latest version after https://github.com/arduino/setup-protoc/issues/33 is fixed
|
2023-06-05 19:05:31 -07:00
|
|
|
version: '23.x'
|
2022-09-06 07:49:18 -07:00
|
|
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
2023-05-10 07:25:41 -07:00
|
|
|
# Setup Rust with stable toolchain and default profile
|
|
|
|
- name: Setup Rust
|
|
|
|
run: |
|
|
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain=stable --profile=default
|
2022-01-25 03:58:11 -08:00
|
|
|
|
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.
|
2023-07-04 19:09:45 -07:00
|
|
|
#- uses: Swatinem/rust-cache@v2.5.1
|
2022-01-25 03:58:11 -08:00
|
|
|
|
2023-05-10 07:25:41 -07:00
|
|
|
- run: |
|
|
|
|
cargo fmt --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' }}
|
2022-11-22 16:26:03 -08:00
|
|
|
# cargo doc doesn't support '-- -D warnings', so we have to add it here
|
|
|
|
# https://github.com/rust-lang/cargo/issues/8424#issuecomment-774662296
|
|
|
|
#
|
2023-06-14 12:09:10 -07:00
|
|
|
# The -A and -W settings must be the same as the `rustdocflags` in:
|
|
|
|
# https://github.com/ZcashFoundation/zebra/blob/main/.cargo/config.toml#L87
|
2022-11-22 16:26:03 -08:00
|
|
|
env:
|
|
|
|
RUSTDOCFLAGS: -D warnings -A rustdoc::private_intra_doc_links
|
2022-06-19 19:10:13 -07:00
|
|
|
|
|
|
|
steps:
|
2023-06-09 17:59:58 -07:00
|
|
|
- uses: actions/checkout@v3.5.3
|
2022-06-19 19:10:13 -07:00
|
|
|
with:
|
|
|
|
persist-credentials: false
|
2023-05-18 09:44:39 -07:00
|
|
|
- uses: r7kamura/rust-problem-matchers@v1.3.0
|
2022-06-19 19:10:13 -07:00
|
|
|
|
2022-09-06 07:49:18 -07:00
|
|
|
- name: Install last version of Protoc
|
2023-06-05 19:05:31 -07:00
|
|
|
uses: arduino/setup-protoc@v2.0.0
|
2022-09-06 07:49:18 -07:00
|
|
|
with:
|
2023-01-10 13:22:03 -08:00
|
|
|
# TODO: increase to latest version after https://github.com/arduino/setup-protoc/issues/33 is fixed
|
2023-06-05 19:05:31 -07:00
|
|
|
version: '23.x'
|
2022-09-06 07:49:18 -07:00
|
|
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
2023-05-10 07:25:41 -07:00
|
|
|
# Setup Rust with stable toolchain and default profile
|
|
|
|
- name: Setup Rust
|
|
|
|
run: |
|
|
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain=stable --profile=default
|
2022-06-19 19:10:13 -07:00
|
|
|
|
2023-05-10 07:25:41 -07:00
|
|
|
- run: |
|
|
|
|
cargo doc --no-deps --document-private-items --all-features
|
2022-06-19 19:10:13 -07:00
|
|
|
|
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:
|
2023-06-09 17:59:58 -07:00
|
|
|
- uses: actions/checkout@v3.5.3
|
2023-07-09 18:27:14 -07:00
|
|
|
- name: actionlint
|
|
|
|
uses: reviewdog/action-actionlint@v1.37.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
|
2023-07-09 18:27:14 -07:00
|
|
|
- name: validate-dependabot
|
|
|
|
uses: marocchino/validate-dependabot@v2.1.0
|
2022-05-25 17:27:44 -07:00
|
|
|
|
|
|
|
codespell:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: changed-files
|
|
|
|
steps:
|
2023-06-09 17:59:58 -07:00
|
|
|
- uses: actions/checkout@v3.5.3
|
2022-05-25 17:27:44 -07:00
|
|
|
- uses: plettich/action-codespell@master
|
|
|
|
with:
|
|
|
|
github_token: ${{ secrets.github_token }}
|
|
|
|
level: warning
|