Skip to content

Change workflow name for consistency #15

Change workflow name for consistency

Change workflow name for consistency #15

Workflow file for this run

name: Check code passes linting
on:
push:
branches:
- release
- ci-test
pull_request:
types: [opened, reopened]
branches:
- release
env:
ENABLE_RUSTFMT: False
jobs:
lint-checks:
name: Rust code checks
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
# Why are we installing two Rust toolchain versions below?
# answer: the rustfmt project is disfunctional, and chooses
# to make many of its useful features only available if you run
# a nightly toolchain (even though those features themselves are
# many years old now). The recommended workaround is to install
# both the toolchain version you want to use, and also the nightly
# toolchain, just to be able to run "cargo +nightly fmt" to get the
# full, very old set of rustfmt functionality.
- name: Install Nightly Rust Toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
components: rustfmt
- name: Install Stable Rust Toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: clippy
- name: Print installed Rust toolchains
run: rustup toolchain list
- name: Install required non-Rust build tools
uses: awalsh128/cache-apt-pkgs-action@latest
with:
# TODO: check if we need all the packages below -- this list comes from the Libra build setup script
packages: build-essential lld pkg-config libssl-dev libgmp-dev clang
version: 1.0 # This is a cache key -- change it when you change the package list above
- name: Run cargo fmt
if: env.ENABLE_RUSTFMT == 'True'
# Note the hacky +nightly below
run: cargo +nightly fmt --all -- --check
- name: Run cargo fmt
if: env.ENABLE_RUSTFMT != 'True'
run: echo "cargo fmt skipped due to project code not complying with current format rules"
- name: Run cargo clippy
run: cargo clippy --workspace --tests -- -D warnings