From 81413ae91eabad108c3843b81d33cbb9abcccd39 Mon Sep 17 00:00:00 2001 From: Philipp Eder Date: Mon, 11 Nov 2024 11:05:29 +0100 Subject: [PATCH] Seperates linting/Rust into linting/{Rust, Rust-Typos, Rust-Audit} Given the nature of using NASL to identify vulnerabilities we may cannot get rif of all audit findings. To indicate that the CI fails based on an audit, rather than e.g. a clippy warning, cargo audit is seperated into an own job. Since the same may be true for typos, typos are seperated into an own job as well. With that change we can immediately see if a CI of a PR failed because of audit, typos or Rust linting issues. --- .github/actions/setup-rust/action.yml | 9 ++++++++ .github/workflows/linting.yml | 30 ++++++++++++++++++--------- 2 files changed, 29 insertions(+), 10 deletions(-) create mode 100644 .github/actions/setup-rust/action.yml diff --git a/.github/actions/setup-rust/action.yml b/.github/actions/setup-rust/action.yml new file mode 100644 index 000000000..afe01d1f0 --- /dev/null +++ b/.github/actions/setup-rust/action.yml @@ -0,0 +1,9 @@ +name: "Setup Rust Environment" +description: "Install necessary dependencies and set up Rust stable" +runs: + using: "composite" + steps: + - run: sudo apt update || true + - run: sudo apt-get install -y libpcap-dev + - run: rustup update stable && rustup default stable || rustup default stable + diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 6b4580f66..e882f604a 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -19,15 +19,25 @@ jobs: working-directory: rust steps: - uses: actions/checkout@v4 - - run: sudo apt update || true - - run: sudo apt-get install -y libpcap-dev - - run: rustup update stable && rustup default stable || rustup default stable - - run: cargo install cargo-audit + - uses: ./.github/actions/setup-rust + - run: cargo clippy -- -D warnings + - run: cargo fmt --check + Rust-Typos: + runs-on: ubuntu-latest + defaults: + run: + working-directory: rust + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/setup-rust - run: cargo install typos-cli - - name: Clippy - run: cargo clippy -- -D warnings - - name: Audit - run: cargo audit - run: typos - - name: Formatting - run: cargo fmt --check + Rust-Audit: + runs-on: ubuntu-latest + defaults: + run: + working-directory: rust + steps: + - uses: actions/checkout@v4 + - run: cargo install cargo-audit + - run: cargo audit