From 943a38a0d6dd02dd64aac529dcc2bbc73ab00531 Mon Sep 17 00:00:00 2001 From: Gustavo Valverde Date: Wed, 16 Feb 2022 11:15:19 -0400 Subject: [PATCH] fix(clippy): allow unprivileged runs of clippy (#3558) --- .github/workflows/lint.yml | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 86690305..c7102bb8 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -28,14 +28,33 @@ jobs: with: persist-credentials: false - - name: Run clippy + - name: Check workflow permissions + id: check_permissions + uses: scherermichael-oss/action-has-permission@1.0.6 + with: + required-permission: write + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Run clippy action to produce annotations uses: actions-rs/clippy-check@v1.0.7 + if: ${{ steps.check_permissions.outputs.has-permission }} with: # GitHub displays the clippy job and its results as separate entries name: Clippy (stable) Results token: ${{ secrets.GITHUB_TOKEN }} args: --all-features --all-targets -- -D warnings + - uses: actions-rs/toolchain@v1.0.1 + if: ${{ !steps.check_permissions.outputs.has-permission }} + with: + toolchain: stable + override: true + + - name: Run clippy manually without annotations + if: ${{ !steps.check_permissions.outputs.has-permission }} + run: cargo clippy --all-features --all-targets -- -D warnings + fmt: name: Rustfmt timeout-minutes: 30 @@ -46,7 +65,7 @@ jobs: with: persist-credentials: false - - uses: actions-rs/toolchain@v1 + - uses: actions-rs/toolchain@v1.0.1 with: toolchain: stable components: rustfmt