From 9013d8b4cad8811084f05eee3125e4cf42b9925b Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Sat, 28 Sep 2024 15:12:41 +0100 Subject: [PATCH] build: Move cargo fmt check to nightly toolchain via new workflow Enforcing group_imports="StdExternalCrate" requires using cargo fmt from the nightly toolchain. Create a new workflow that runs on nightly to run cargo fmt. Signed-off-by: Rob Bradford --- .github/workflows/formatting.yaml | 32 +++++++++++++++++++++++++++++++ .github/workflows/quality.yaml | 10 ++-------- 2 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/formatting.yaml diff --git a/.github/workflows/formatting.yaml b/.github/workflows/formatting.yaml new file mode 100644 index 000000000..b6dd6cafc --- /dev/null +++ b/.github/workflows/formatting.yaml @@ -0,0 +1,32 @@ +name: Cloud Hypervisor Code Formatting +on: [pull_request, merge_group] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + name: Code Formatting + runs-on: ubuntu-latest + strategy: + matrix: + rust: + - nightly + target: + - x86_64-unknown-linux-gnu + - aarch64-unknown-linux-musl + env: + RUSTFLAGS: -D warnings + steps: + - name: Code checkout + uses: actions/checkout@v4 + - name: Install Rust toolchain (${{ matrix.rust }}) + uses: dtolnay/rust-toolchain@stable + with: + toolchain: ${{ matrix.rust }} + target: ${{ matrix.target }} + components: rustfmt + - name: Formatting (rustfmt) + run: cargo fmt --all -- --check + - name: Formatting (fuzz) (rustfmt) + run: cargo fmt --all --manifest-path fuzz/Cargo.toml -- --check diff --git a/.github/workflows/quality.yaml b/.github/workflows/quality.yaml index c78d2382d..838e655f9 100644 --- a/.github/workflows/quality.yaml +++ b/.github/workflows/quality.yaml @@ -6,7 +6,7 @@ concurrency: jobs: build: - name: Quality (clippy, rustfmt) + name: Quality (clippy) runs-on: ubuntu-latest continue-on-error: ${{ matrix.experimental }} strategy: @@ -39,7 +39,7 @@ jobs: toolchain: ${{ matrix.rust }} target: ${{ matrix.target }} override: true - components: rustfmt, clippy + components: clippy - name: Bisectability Check (default features) if: ${{ github.event_name == 'pull_request' && matrix.target == 'x86_64-unknown-linux-gnu' }} @@ -49,12 +49,6 @@ jobs: for commit in $commits; do git checkout $commit; cargo check --tests --examples --all --target=${{ matrix.target }}; done git checkout ${{ github.sha }} - - name: Formatting (rustfmt) - run: cargo fmt --all -- --check - - - name: Formatting (fuzz) (rustfmt) - run: cargo fmt --all --manifest-path fuzz/Cargo.toml -- --check - - name: Clippy (kvm) uses: actions-rs/cargo@v1 with: