Skip to content

Commit 176d721

Browse files
committed
test: add pipeline test to check clean git tree
1 parent 181c03d commit 176d721

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: "Check Clean Git Working Tree"
2+
description: "Check that the git working tree is clean"
3+
4+
runs:
5+
using: "composite"
6+
steps:
7+
- name: Check clean Git working tree
8+
shell: bash
9+
run: |
10+
status_output=$(git status --porcelain=v1)
11+
if [ -z "$status_output" ]; then
12+
echo "Git working tree is clean."
13+
exit 0
14+
else
15+
echo "dirty Git working tree detected!"
16+
echo "$status_output"
17+
exit 1
18+
fi

.github/workflows/main.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ jobs:
196196
- run: cargo update
197197
- uses: Swatinem/rust-cache@v2
198198
- run: cargo test ${{ matrix.no_run }} --workspace --target ${{ matrix.target }} ${{ matrix.cargo_flags }}
199+
# check that there are no uncommitted changes to prevent bugs like https://github.com/rust-lang/cc-rs/issues/1411
200+
- name: check clean Git workting tree
201+
uses: ./.github/actions/check-clean-git-working-tree
199202

200203
# This is separate from the matrix above because there is no prebuilt rust-std component for these targets.
201204
check-build-std:
@@ -234,6 +237,9 @@ jobs:
234237
- run: cargo test -Z build-std=std --no-run --workspace --target ${{ matrix.target }}
235238
- run: cargo test -Z build-std=std --no-run --workspace --target ${{ matrix.target }} --release
236239
- run: cargo test -Z build-std=std --no-run --workspace --target ${{ matrix.target }} --features parallel
240+
# check that there are no uncommitted changes to prevent bugs like https://github.com/rust-lang/cc-rs/issues/1411
241+
- name: check clean Git workting tree
242+
uses: ./.github/actions/check-clean-git-working-tree
237243

238244
check-wasm:
239245
name: Test wasm
@@ -252,6 +258,9 @@ jobs:
252258
- run: cargo test --no-run --target ${{ matrix.target }}
253259
- run: cargo test --no-run --target ${{ matrix.target }} --release
254260
- run: cargo test --no-run --target ${{ matrix.target }} --features parallel
261+
# check that there are no uncommitted changes to prevent bugs like https://github.com/rust-lang/cc-rs/issues/1411
262+
- name: check clean Git workting tree
263+
uses: ./.github/actions/check-clean-git-working-tree
255264

256265
test-wasm32-wasip1-thread:
257266
name: Test wasm32-wasip1-thread
@@ -297,6 +306,10 @@ jobs:
297306
- name: Run tests
298307
run: cargo +nightly build -p $TARGET-test --target $TARGET
299308

309+
# check that there are no uncommitted changes to prevent bugs like https://github.com/rust-lang/cc-rs/issues/1411
310+
- name: check clean Git workting tree
311+
uses: ./.github/actions/check-clean-git-working-tree
312+
300313
cuda:
301314
name: Test CUDA support
302315
runs-on: ubuntu-22.04
@@ -317,6 +330,9 @@ jobs:
317330
run: |
318331
PATH="/usr/local/cuda/bin:$PATH" cargo test --manifest-path dev-tools/cc-test/Cargo.toml --features test_cuda
319332
PATH="/usr/local/cuda/bin:$PATH" CXX=clang++ cargo test --manifest-path dev-tools/cc-test/Cargo.toml --features test_cuda
333+
# check that there are no uncommitted changes to prevent bugs like https://github.com/rust-lang/cc-rs/issues/1411
334+
- name: check clean Git workting tree
335+
uses: ./.github/actions/check-clean-git-working-tree
320336

321337
msrv:
322338
name: MSRV
@@ -353,6 +369,9 @@ jobs:
353369
shell: bash
354370
- uses: Swatinem/rust-cache@v2
355371
- run: cargo clippy --no-deps
372+
# check that there are no uncommitted changes to prevent bugs like https://github.com/rust-lang/cc-rs/issues/1411
373+
- name: check clean Git workting tree
374+
uses: ./.github/actions/check-clean-git-working-tree
356375

357376
rustfmt:
358377
name: Rustfmt

0 commit comments

Comments
 (0)