PM-13335 - Pin Rust toolchains and introduce Renovate #446
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: Lint | |
on: | |
workflow_dispatch: | |
push: | |
branches: ["main"] | |
pull_request: | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
style: | |
name: Check Style | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Set Rust Toolchain | |
id: toolchain | |
shell: bash | |
run: | | |
RUST_TOOLCHAIN="$(grep -oP '^channel.*"(\K.*?)(?=")' rust-toolchain.toml)" | |
echo "RUST_TOOLCHAIN=${RUST_TOOLCHAIN}" | tee -a "${GITHUB_OUTPUT}" | |
- name: Set Rust Nightly Toolchain | |
id: nightly-toolchain | |
shell: bash | |
run: | | |
RUST_NIGHTLY_TOOLCHAIN="$(grep -oP '^nightly-channel.*"(\K.*?)(?=")' rust-toolchain.toml)" | |
echo "RUST_NIGHTLY_TOOLCHAIN=${RUST_NIGHTLY_TOOLCHAIN}" | tee -a "${GITHUB_OUTPUT}" | |
- name: Install rust | |
uses: dtolnay/rust-toolchain@a54c7afa936fefeb4456b2dd8068152669aa8203 # stable | |
with: | |
toolchain: "${{ steps.toolchain.outputs.RUST_TOOLCHAIN }}" | |
components: clippy, rustfmt | |
- name: Install rust nightly | |
run: | | |
rustup toolchain install "${{ steps.nightly-toolchain.outputs.RUST_NIGHTLY_TOOLCHAIN }}" | |
rustup component add rustfmt --toolchain "${{ steps.nightly-toolchain.outputs.RUST_NIGHTLY_TOOLCHAIN }}"-x86_64-unknown-linux-gnu | |
- name: Cache cargo registry | |
uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5 | |
- name: Cargo fmt | |
run: cargo +"${{ steps.nightly-toolchain.outputs.RUST_NIGHTLY_TOOLCHAIN }}" fmt --check | |
- name: Install clippy-sarif and sarif-fmt | |
run: cargo install clippy-sarif sarif-fmt --locked --git https://github.com/psastras/sarif-rs.git --rev 11c33a53f6ffeaed736856b86fb6b7b09fabdfd8 | |
- name: Cargo clippy-sarif | |
run: cargo clippy --all-features --tests --message-format=json | | |
clippy-sarif | tee clippy_result.sarif | sarif-fmt | |
env: | |
RUSTFLAGS: "-D warnings" | |
- name: Upload Clippy results to GitHub | |
uses: github/codeql-action/upload-sarif@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6 | |
with: | |
sarif_file: clippy_result.sarif | |
# Run it again but this time without the sarif output so that the | |
# status code of the command is caught and reported as failed in GitHub. | |
# This should be cached from the previous step and should be fast. | |
- name: Cargo clippy | |
run: cargo clippy --all-features --tests | |
env: | |
RUSTFLAGS: "-D warnings" | |
- name: Install cargo-sort | |
run: cargo install cargo-sort --locked --git https://github.com/DevinR528/cargo-sort.git --rev f5047967021cbb1f822faddc355b3b07674305a1 | |
- name: Cargo sort | |
run: cargo sort --workspace --check | |
- name: Install cargo-udeps | |
run: cargo install cargo-udeps --version 0.1.53 --locked | |
- name: Cargo udeps | |
run: cargo +"${{ steps.nightly-toolchain.outputs.RUST_NIGHTLY_TOOLCHAIN }}" udeps --workspace --all-features | |
- name: Set up Node | |
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 | |
with: | |
cache: "npm" | |
cache-dependency-path: "package-lock.json" | |
node-version: "16" | |
- name: NPM setup | |
run: npm ci | |
- name: Node Lint | |
run: npm run lint | |
- name: Verify rust documentation links | |
run: cargo doc --no-deps --features internal | |
env: | |
RUSTDOCFLAGS: "-D warnings" |