From fff707e56dc31b47ef6d8cfdb0284c1f87c39284 Mon Sep 17 00:00:00 2001 From: Scott Mabin Date: Fri, 19 Jul 2024 14:01:21 +0100 Subject: [PATCH] split up clippy --- .github/workflows/ci.yml | 45 ++++++++++++++-------------------------- xtask/src/main.rs | 15 +++++++++++--- 2 files changed, 27 insertions(+), 33 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index de84bdff54a..bb7812c8d86 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,26 +64,22 @@ jobs: steps: - uses: actions/checkout@v4 + # Install the Rust toolchain for Xtensa devices: + - uses: esp-rs/xtensa-toolchain@v1.5 + with: + default: true + ldproxy: false # Install the Rust stable and nightly toolchains for RISC-V devices: - - if: ${{ !contains(fromJson('["esp32", "esp32s2", "esp32s3"]'), matrix.device.soc) }} - uses: dtolnay/rust-toolchain@v1 + - uses: dtolnay/rust-toolchain@v1 with: target: riscv32imc-unknown-none-elf,riscv32imac-unknown-none-elf toolchain: stable components: rust-src - - if: ${{ !contains(fromJson('["esp32", "esp32s2", "esp32s3"]'), matrix.device.soc) }} - uses: dtolnay/rust-toolchain@v1 + - uses: dtolnay/rust-toolchain@v1 with: target: riscv32imc-unknown-none-elf,riscv32imac-unknown-none-elf toolchain: nightly components: rust-src - # Install the Rust toolchain for Xtensa devices: - - if: contains(fromJson('["esp32", "esp32s2", "esp32s3"]'), matrix.device.soc) - uses: esp-rs/xtensa-toolchain@v1.5 - with: - buildtargets: ${{ matrix.device.soc }} - default: true - ldproxy: false - uses: Swatinem/rust-cache@v2 @@ -109,9 +105,14 @@ jobs: run: cargo xtask build-examples esp-hal ${{ matrix.device.soc }} # Check doc-tests - name: Check doc-tests - run: cargo xtask run-doc-test esp-hal ${{ matrix.device.soc }} + run: cargo +esp xtask run-doc-test esp-hal ${{ matrix.device.soc }} - name: Check documentation run: RUSTDOCFLAGS="-D warnings" cargo xtask build-documentation --packages esp-hal --chips ${{ matrix.device.soc }} + # Run clippy + - name: Clippy + # We use the 'esp' toolchain for *all* targets, in order to get a + # semi-stable and consistent set of lints for all targets: + run: cargo +esp xtask lint-packages --chips ${{ matrix.device.soc }} extras: runs-on: ubuntu-latest @@ -165,7 +166,7 @@ jobs: cargo xtask build-package --features=esp32h2,ci --target=riscv32imac-unknown-none-elf esp-hal # Verify the MSRV for all Xtensa chips: - - name: msrv RISCV (esp-hal) + - name: msrv Xtensa (esp-hal) run: | cargo xtask build-package --toolchain=esp --features=esp32,ci --target=xtensa-esp32-none-elf esp-hal cargo xtask build-package --toolchain=esp --features=esp32s2,ci --target=xtensa-esp32s2-none-elf esp-hal @@ -178,23 +179,7 @@ jobs: cargo xtask build-package --features=esp32s3 --target=riscv32imc-unknown-none-elf esp-lp-hal # -------------------------------------------------------------------------- - # Lint & Format - - clippy: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - # We use the 'esp' toolchain for *all* targets, in order to get a - # semi-stable and consistent set of lints for all targets: - - uses: esp-rs/xtensa-toolchain@v1.5 - with: - default: true - ldproxy: false - - uses: Swatinem/rust-cache@v2 - - # Lint all packages: - - run: cargo xtask lint-packages + # Format rustfmt: runs-on: ubuntu-latest diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 705b10c2854..e5953ea362e 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -130,6 +130,10 @@ struct LintPackagesArgs { /// Package(s) to target. #[arg(value_enum, default_values_t = Package::iter())] packages: Vec, + + /// Lint for a specific chip + #[arg(long, value_enum, default_values_t = Chip::iter())] + chips: Vec, } #[derive(Debug, Args)] @@ -464,7 +468,7 @@ fn lint_packages(workspace: &Path, args: LintPackagesArgs) -> Result<()> { // building, so we need to handle each individually (though there // is *some* overlap) - for chip in Chip::iter() { + for chip in &args.chips { let device = Config::for_chip(&chip); match package { @@ -583,7 +587,6 @@ fn lint_packages(workspace: &Path, args: LintPackagesArgs) -> Result<()> { "-Zbuild-std=core", &format!("--target={}", chip.target()), &format!("--features={chip},storage,nor-flash,low-level"), - "--release", ], )?; } @@ -649,7 +652,13 @@ fn lint_package(path: &Path, args: &[&str]) -> Result<()> { builder = builder.arg(arg.to_string()); } - let cargo_args = builder.arg("--").arg("-D").arg("warnings").build(); + // build in release to reuse example artifacts + let cargo_args = builder + .arg("--release") + .arg("--") + .arg("-D") + .arg("warnings") + .build(); xtask::cargo::run(&cargo_args, &path) }