From 921b3fb9b0c9431e92e34bdc42dc82be7c194f36 Mon Sep 17 00:00:00 2001 From: Jason Q <81179619+beqqrry-aws@users.noreply.github.com> Date: Wed, 21 Feb 2024 11:35:35 -0700 Subject: [PATCH] GitHub: Changes the Rust linting workflow to allow it to be required. (#6154) --- .github/workflows/rust.yml | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index ded1a5df737..108f0f5c216 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,13 +1,6 @@ name: Rust on: - push: - paths: - - "rustv1/**" - branches: - - main pull_request: - paths: - - "rustv1/**" workflow_dispatch: permissions: contents: read @@ -16,31 +9,46 @@ jobs: name: Lint Rust runs-on: aws-doc-sdk-examples_ubuntu-latest_16-core steps: + - name: Checkout files + uses: actions/checkout@v4 + with: + sparse-checkout: | + .github + rustv1 + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v41 + with: + files: "rustv1/**/*.{rs,toml}" - name: setup + if: steps.changed-files.outputs.any_changed == 'true' run: sudo apt-get update && sudo apt-get install -y libclang-dev - uses: dtolnay/rust-toolchain@stable + if: steps.changed-files.outputs.any_changed == 'true' with: toolchain: "1.70.0" components: clippy, rustfmt - - uses: actions/checkout@v3 - name: Set Environment + if: steps.changed-files.outputs.any_changed == 'true' run: > export RUSTFLAGS="-D warnings" ; export APP_ENVIRONMENT="test" - name: Rust format + if: steps.changed-files.outputs.any_changed == 'true' run: > "$HOME/.cargo/bin/cargo" fmt --manifest-path rustv1/cross_service/Cargo.toml --all --check && "$HOME/.cargo/bin/cargo" fmt --manifest-path rustv1/examples/Cargo.toml --all --check && "$HOME/.cargo/bin/cargo" fmt --manifest-path rustv1/lambda/Cargo.toml --all --check && "$HOME/.cargo/bin/cargo" fmt --manifest-path rustv1/webassembly/Cargo.toml --all --check - name: Rust lint - if: success() || failure() + if: steps.changed-files.outputs.any_changed == 'true' && (success() || failure()) run: > "$HOME/.cargo/bin/cargo" clippy --manifest-path rustv1/cross_service/Cargo.toml --all && "$HOME/.cargo/bin/cargo" clippy --manifest-path rustv1/examples/Cargo.toml --all && "$HOME/.cargo/bin/cargo" clippy --manifest-path rustv1/lambda/Cargo.toml --all && "$HOME/.cargo/bin/cargo" clippy --manifest-path rustv1/webassembly/Cargo.toml --all - name: Rust test + if: steps.changed-files.outputs.any_changed == 'true' run: > "$HOME/.cargo/bin/cargo" test --manifest-path rustv1/cross_service/Cargo.toml --all && "$HOME/.cargo/bin/cargo" test --manifest-path rustv1/examples/Cargo.toml --all &&