Skip to content

Commit 2eeb917

Browse files
authored
Merge pull request #1908 from fermyon/give-permissions
CI: give permissions to lint job to cancel entire workflow
2 parents d1d8184 + 65eb2f6 commit 2eeb917

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ jobs:
2525
lint-rust:
2626
name: Lint Rust
2727
runs-on: "ubuntu-latest"
28+
permissions:
29+
## Allow this job to potentially cancel the running workflow (on failure)
30+
actions: write
2831
steps:
2932
- uses: actions/checkout@v3
3033

@@ -36,9 +39,7 @@ jobs:
3639
rust-cache: true
3740

3841
- name: Run lints
39-
run: |
40-
BUILD_SPIN_EXAMPLES=0 make lint
41-
git diff --name-status --exit-code . || (echo "Git working tree dirtied by lints. Run 'make update-cargo-locks' and check in changes" && exit 1)
42+
run: BUILD_SPIN_EXAMPLES=0 make lint
4243

4344
- name: Cancel everything if linting fails
4445
if: failure()

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ lint: lint-rust-examples-and-testcases
6060
.PHONY: lint-rust-examples-and-testcases
6161
lint-rust-examples-and-testcases:
6262
for manifest_path in $$(find examples tests/testcases -name Cargo.toml); do \
63-
cargo clippy --manifest-path "$${manifest_path}" -- -D warnings \
63+
echo "Linting $${manifest_path}" \
64+
&& cargo clippy --manifest-path "$${manifest_path}" -- -D warnings \
6465
&& cargo fmt --manifest-path "$${manifest_path}" -- --check \
66+
&& (git diff --name-status --exit-code . || (echo "Git working tree dirtied by lints. Run 'make update-cargo-locks' and check in changes" && false)) \
6567
|| exit 1 ; \
6668
done
6769

0 commit comments

Comments
 (0)