zebra/.github/workflows/ci-lint.yml

174 lines
6.0 KiB
YAML
Raw Normal View History

# This workflow conducts various linting checks for a Rust-based project.
# 1. Determines if Rust or workflow files have been modified.
# 2. Runs the Clippy linter on Rust files, producing annotations and failing on warnings.
# 3. Ensures Rust code formatting complies with 'rustfmt' standards.
# 4. Lints GitHub Actions workflow files for common issues.
# 5. Checks for common spelling errors in the codebase.
# The workflow is designed to maintain code quality and consistency, running checks conditionally based on the changed files.
name: Lint
# 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
on:
# 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
pull_request:
env:
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 }}
jobs:
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:
- uses: actions/checkout@v4.1.1
with:
persist-credentials: false
fetch-depth: 0
- name: Rust files
id: changed-files-rust
build(deps): bump the devops group with 5 updates (#8334) Bumps the devops group with 5 updates: | Package | From | To | | --- | --- | --- | | [google-github-actions/auth](https://github.com/google-github-actions/auth) | `2.1.1` | `2.1.2` | | [actions/add-to-project](https://github.com/actions/add-to-project) | `0.5.0` | `0.6.0` | | [codecov/codecov-action](https://github.com/codecov/codecov-action) | `4.0.1` | `4.1.0` | | [tj-actions/changed-files](https://github.com/tj-actions/changed-files) | `42.0.4` | `42.0.5` | | [reviewdog/action-actionlint](https://github.com/reviewdog/action-actionlint) | `1.41.0` | `1.42.0` | Updates `google-github-actions/auth` from 2.1.1 to 2.1.2 - [Release notes](https://github.com/google-github-actions/auth/releases) - [Changelog](https://github.com/google-github-actions/auth/blob/main/CHANGELOG.md) - [Commits](https://github.com/google-github-actions/auth/compare/v2.1.1...v2.1.2) Updates `actions/add-to-project` from 0.5.0 to 0.6.0 - [Release notes](https://github.com/actions/add-to-project/releases) - [Commits](https://github.com/actions/add-to-project/compare/v0.5.0...v0.6.0) Updates `codecov/codecov-action` from 4.0.1 to 4.1.0 - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v4.0.1...v4.1.0) Updates `tj-actions/changed-files` from 42.0.4 to 42.0.5 - [Release notes](https://github.com/tj-actions/changed-files/releases) - [Changelog](https://github.com/tj-actions/changed-files/blob/main/HISTORY.md) - [Commits](https://github.com/tj-actions/changed-files/compare/v42.0.4...v42.0.5) Updates `reviewdog/action-actionlint` from 1.41.0 to 1.42.0 - [Release notes](https://github.com/reviewdog/action-actionlint/releases) - [Commits](https://github.com/reviewdog/action-actionlint/compare/v1.41.0...v1.42.0) --- updated-dependencies: - dependency-name: google-github-actions/auth dependency-type: direct:production update-type: version-update:semver-patch dependency-group: devops - dependency-name: actions/add-to-project dependency-type: direct:production update-type: version-update:semver-minor dependency-group: devops - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-minor dependency-group: devops - dependency-name: tj-actions/changed-files dependency-type: direct:production update-type: version-update:semver-patch dependency-group: devops - dependency-name: reviewdog/action-actionlint dependency-type: direct:production update-type: version-update:semver-minor dependency-group: devops ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-01 16:49:43 -08:00
uses: tj-actions/changed-files@v42.0.5
with:
files: |
**/*.rs
**/Cargo.toml
**/Cargo.lock
clippy.toml
.cargo/config.toml
ref(workflows): consolidate workflows based on their purpose (#7616) * ref(workflows): consolidate workflows based on their purpose This also renames the workflows to make their naming more consistent and adding a naming convention Fixes: #6166 Fixes: #6167 * fix(workflows): use correct name for patch * fix(workflow): docker unit tests * fix(release): validation error Error: ``` Validation Failed: {"resource":"Release","code":"invalid","field":"target_commitish"} ``` Fixes: https://github.com/release-drafter/release-drafter/issues/1125 * fix(workflows): reference correct name * fix: remove extra workflow * fix(workflows): use larger runners * fix(workflow): remove code already in docker unit-test * fix(unit-tests): start zebra the right way * fix: typo in patch name * chore: move job to logical order * imp(workflows): use better name for gcp tests * add: missing merge changes * chore: use better name for find-disks * fix(ci): use the `entrypoint.sh` to change the Network * fix(ci): add missing `ZEBRA_CONF_PATH` variable * fix(ci): allow to build the entrypoint file with testnet * fix(entrypoint): allow to create a dir and file with a single variable * refactor: test config file in CI and CD with a reusable workflow * fix(ci): wrong name used * fix(ci): use checkout * fix(ci): improve docker config tests * fix(ci): use better name for protection rules * Fix changed workflow file name in docs patch file * Apply suggestions from code review Co-authored-by: teor <teor@riseup.net> Co-authored-by: Arya <aryasolhi@gmail.com> * fix(cd): depend on file tests * fix(docs): adapt to new workflow name * fix: revert test coverage on CD * chore: reduce diff * fix(ci): allow using variable images for reusable workflows * fix(dockerfile): use variables or default for config path and file * fix(entrypoint): if `$ZEBRA_CONF_PATH` is set, do not override it * Fix patch job names and remove failure job testnet dependencies --------- Co-authored-by: teor <teor@riseup.net> Co-authored-by: Arya <aryasolhi@gmail.com>
2023-10-17 23:16:02 -07:00
.github/workflows/ci-lint.yml
- name: Workflow files
id: changed-files-workflows
build(deps): bump the devops group with 5 updates (#8334) Bumps the devops group with 5 updates: | Package | From | To | | --- | --- | --- | | [google-github-actions/auth](https://github.com/google-github-actions/auth) | `2.1.1` | `2.1.2` | | [actions/add-to-project](https://github.com/actions/add-to-project) | `0.5.0` | `0.6.0` | | [codecov/codecov-action](https://github.com/codecov/codecov-action) | `4.0.1` | `4.1.0` | | [tj-actions/changed-files](https://github.com/tj-actions/changed-files) | `42.0.4` | `42.0.5` | | [reviewdog/action-actionlint](https://github.com/reviewdog/action-actionlint) | `1.41.0` | `1.42.0` | Updates `google-github-actions/auth` from 2.1.1 to 2.1.2 - [Release notes](https://github.com/google-github-actions/auth/releases) - [Changelog](https://github.com/google-github-actions/auth/blob/main/CHANGELOG.md) - [Commits](https://github.com/google-github-actions/auth/compare/v2.1.1...v2.1.2) Updates `actions/add-to-project` from 0.5.0 to 0.6.0 - [Release notes](https://github.com/actions/add-to-project/releases) - [Commits](https://github.com/actions/add-to-project/compare/v0.5.0...v0.6.0) Updates `codecov/codecov-action` from 4.0.1 to 4.1.0 - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v4.0.1...v4.1.0) Updates `tj-actions/changed-files` from 42.0.4 to 42.0.5 - [Release notes](https://github.com/tj-actions/changed-files/releases) - [Changelog](https://github.com/tj-actions/changed-files/blob/main/HISTORY.md) - [Commits](https://github.com/tj-actions/changed-files/compare/v42.0.4...v42.0.5) Updates `reviewdog/action-actionlint` from 1.41.0 to 1.42.0 - [Release notes](https://github.com/reviewdog/action-actionlint/releases) - [Commits](https://github.com/reviewdog/action-actionlint/compare/v1.41.0...v1.42.0) --- updated-dependencies: - dependency-name: google-github-actions/auth dependency-type: direct:production update-type: version-update:semver-patch dependency-group: devops - dependency-name: actions/add-to-project dependency-type: direct:production update-type: version-update:semver-minor dependency-group: devops - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-minor dependency-group: devops - dependency-name: tj-actions/changed-files dependency-type: direct:production update-type: version-update:semver-patch dependency-group: devops - dependency-name: reviewdog/action-actionlint dependency-type: direct:production update-type: version-update:semver-minor dependency-group: devops ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-01 16:49:43 -08:00
uses: tj-actions/changed-files@v42.0.5
with:
files: |
.github/workflows/*.yml
clippy:
name: Clippy
2022-05-24 02:03:56 -07:00
timeout-minutes: 45
runs-on: ubuntu-latest
needs: changed-files
if: ${{ needs.changed-files.outputs.rust == 'true' }}
steps:
- uses: actions/checkout@v4.1.1
with:
persist-credentials: false
- name: Install last version of Protoc
build(deps): bump the devops group with 5 updates (#8218) Bumps the devops group with 5 updates: | Package | From | To | | --- | --- | --- | | [arduino/setup-protoc](https://github.com/arduino/setup-protoc) | `2.1.0` | `3.0.0` | | [codecov/codecov-action](https://github.com/codecov/codecov-action) | `3.1.4` | `3.1.6` | | [tj-actions/changed-files](https://github.com/tj-actions/changed-files) | `42.0.0` | `42.0.2` | | [peter-evans/dockerhub-description](https://github.com/peter-evans/dockerhub-description) | `3.4.2` | `4.0.0` | | [docker/metadata-action](https://github.com/docker/metadata-action) | `5.5.0` | `5.5.1` | Updates `arduino/setup-protoc` from 2.1.0 to 3.0.0 - [Release notes](https://github.com/arduino/setup-protoc/releases) - [Commits](https://github.com/arduino/setup-protoc/compare/v2.1.0...v3.0.0) Updates `codecov/codecov-action` from 3.1.4 to 3.1.6 - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v3.1.4...v3.1.6) Updates `tj-actions/changed-files` from 42.0.0 to 42.0.2 - [Release notes](https://github.com/tj-actions/changed-files/releases) - [Changelog](https://github.com/tj-actions/changed-files/blob/main/HISTORY.md) - [Commits](https://github.com/tj-actions/changed-files/compare/v42.0.0...v42.0.2) Updates `peter-evans/dockerhub-description` from 3.4.2 to 4.0.0 - [Release notes](https://github.com/peter-evans/dockerhub-description/releases) - [Commits](https://github.com/peter-evans/dockerhub-description/compare/v3.4.2...v4.0.0) Updates `docker/metadata-action` from 5.5.0 to 5.5.1 - [Release notes](https://github.com/docker/metadata-action/releases) - [Commits](https://github.com/docker/metadata-action/compare/v5.5.0...v5.5.1) --- updated-dependencies: - dependency-name: arduino/setup-protoc dependency-type: direct:production update-type: version-update:semver-major dependency-group: devops - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-patch dependency-group: devops - dependency-name: tj-actions/changed-files dependency-type: direct:production update-type: version-update:semver-patch dependency-group: devops - dependency-name: peter-evans/dockerhub-description dependency-type: direct:production update-type: version-update:semver-major dependency-group: devops - dependency-name: docker/metadata-action dependency-type: direct:production update-type: version-update:semver-patch dependency-group: devops ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-06 05:19:46 -08:00
uses: arduino/setup-protoc@v3.0.0
with:
# TODO: increase to latest version after https://github.com/arduino/setup-protoc/issues/33 is fixed
version: '23.x'
repo-token: ${{ secrets.GITHUB_TOKEN }}
- 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 }}
# 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
- uses: Swatinem/rust-cache@v2.7.3
with:
shared-key: "clippy-cargo-lock"
# TODO: keep this action until we find a better solution
- 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: --workspace --all-features --all-targets -- -D warnings
- name: Run clippy manually without annotations
if: ${{ !steps.check_permissions.outputs.has-permission }}
run: cargo clippy --workspace --all-features --all-targets -- -D warnings
fmt:
name: Rustfmt
timeout-minutes: 30
runs-on: ubuntu-latest
needs: changed-files
if: ${{ needs.changed-files.outputs.rust == 'true' }}
steps:
- uses: actions/checkout@v4.1.1
with:
persist-credentials: false
- uses: r7kamura/rust-problem-matchers@v1.4.0
- name: Install last version of Protoc
build(deps): bump the devops group with 5 updates (#8218) Bumps the devops group with 5 updates: | Package | From | To | | --- | --- | --- | | [arduino/setup-protoc](https://github.com/arduino/setup-protoc) | `2.1.0` | `3.0.0` | | [codecov/codecov-action](https://github.com/codecov/codecov-action) | `3.1.4` | `3.1.6` | | [tj-actions/changed-files](https://github.com/tj-actions/changed-files) | `42.0.0` | `42.0.2` | | [peter-evans/dockerhub-description](https://github.com/peter-evans/dockerhub-description) | `3.4.2` | `4.0.0` | | [docker/metadata-action](https://github.com/docker/metadata-action) | `5.5.0` | `5.5.1` | Updates `arduino/setup-protoc` from 2.1.0 to 3.0.0 - [Release notes](https://github.com/arduino/setup-protoc/releases) - [Commits](https://github.com/arduino/setup-protoc/compare/v2.1.0...v3.0.0) Updates `codecov/codecov-action` from 3.1.4 to 3.1.6 - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v3.1.4...v3.1.6) Updates `tj-actions/changed-files` from 42.0.0 to 42.0.2 - [Release notes](https://github.com/tj-actions/changed-files/releases) - [Changelog](https://github.com/tj-actions/changed-files/blob/main/HISTORY.md) - [Commits](https://github.com/tj-actions/changed-files/compare/v42.0.0...v42.0.2) Updates `peter-evans/dockerhub-description` from 3.4.2 to 4.0.0 - [Release notes](https://github.com/peter-evans/dockerhub-description/releases) - [Commits](https://github.com/peter-evans/dockerhub-description/compare/v3.4.2...v4.0.0) Updates `docker/metadata-action` from 5.5.0 to 5.5.1 - [Release notes](https://github.com/docker/metadata-action/releases) - [Commits](https://github.com/docker/metadata-action/compare/v5.5.0...v5.5.1) --- updated-dependencies: - dependency-name: arduino/setup-protoc dependency-type: direct:production update-type: version-update:semver-major dependency-group: devops - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-patch dependency-group: devops - dependency-name: tj-actions/changed-files dependency-type: direct:production update-type: version-update:semver-patch dependency-group: devops - dependency-name: peter-evans/dockerhub-description dependency-type: direct:production update-type: version-update:semver-major dependency-group: devops - dependency-name: docker/metadata-action dependency-type: direct:production update-type: version-update:semver-patch dependency-group: devops ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-06 05:19:46 -08:00
uses: arduino/setup-protoc@v3.0.0
with:
# TODO: increase to latest version after https://github.com/arduino/setup-protoc/issues/33 is fixed
version: '23.x'
repo-token: ${{ secrets.GITHUB_TOKEN }}
# 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
# 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@v2.7.3
- run: |
cargo fmt --all -- --check
actionlint:
runs-on: ubuntu-latest
continue-on-error: true
needs: changed-files
if: ${{ needs.changed-files.outputs.workflows == 'true' }}
steps:
- uses: actions/checkout@v4.1.1
- name: actionlint
build(deps): bump the devops group with 5 updates (#8334) Bumps the devops group with 5 updates: | Package | From | To | | --- | --- | --- | | [google-github-actions/auth](https://github.com/google-github-actions/auth) | `2.1.1` | `2.1.2` | | [actions/add-to-project](https://github.com/actions/add-to-project) | `0.5.0` | `0.6.0` | | [codecov/codecov-action](https://github.com/codecov/codecov-action) | `4.0.1` | `4.1.0` | | [tj-actions/changed-files](https://github.com/tj-actions/changed-files) | `42.0.4` | `42.0.5` | | [reviewdog/action-actionlint](https://github.com/reviewdog/action-actionlint) | `1.41.0` | `1.42.0` | Updates `google-github-actions/auth` from 2.1.1 to 2.1.2 - [Release notes](https://github.com/google-github-actions/auth/releases) - [Changelog](https://github.com/google-github-actions/auth/blob/main/CHANGELOG.md) - [Commits](https://github.com/google-github-actions/auth/compare/v2.1.1...v2.1.2) Updates `actions/add-to-project` from 0.5.0 to 0.6.0 - [Release notes](https://github.com/actions/add-to-project/releases) - [Commits](https://github.com/actions/add-to-project/compare/v0.5.0...v0.6.0) Updates `codecov/codecov-action` from 4.0.1 to 4.1.0 - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v4.0.1...v4.1.0) Updates `tj-actions/changed-files` from 42.0.4 to 42.0.5 - [Release notes](https://github.com/tj-actions/changed-files/releases) - [Changelog](https://github.com/tj-actions/changed-files/blob/main/HISTORY.md) - [Commits](https://github.com/tj-actions/changed-files/compare/v42.0.4...v42.0.5) Updates `reviewdog/action-actionlint` from 1.41.0 to 1.42.0 - [Release notes](https://github.com/reviewdog/action-actionlint/releases) - [Commits](https://github.com/reviewdog/action-actionlint/compare/v1.41.0...v1.42.0) --- updated-dependencies: - dependency-name: google-github-actions/auth dependency-type: direct:production update-type: version-update:semver-patch dependency-group: devops - dependency-name: actions/add-to-project dependency-type: direct:production update-type: version-update:semver-minor dependency-group: devops - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-minor dependency-group: devops - dependency-name: tj-actions/changed-files dependency-type: direct:production update-type: version-update:semver-patch dependency-group: devops - dependency-name: reviewdog/action-actionlint dependency-type: direct:production update-type: version-update:semver-minor dependency-group: devops ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-01 16:49:43 -08:00
uses: reviewdog/action-actionlint@v1.42.0
with:
level: warning
fail_on_error: false
# This is failing with a JSON schema error, see #8028 for details.
#- name: validate-dependabot
# # This gives an error when run on PRs from external repositories, so we skip it.
# # If this is a PR, check that the PR source is a local branch. Always runs on non-PRs.
# if: ${{ !startsWith(github.event_name, 'pull') || !github.event.pull_request.head.repo.fork }}
# uses: marocchino/validate-dependabot@v2.1.0
codespell:
runs-on: ubuntu-latest
needs: changed-files
steps:
- uses: actions/checkout@v4.1.1
- uses: codespell-project/actions-codespell@v2.0
with:
only_warn: 1