From c6c6be328fb8ce3cc9bec9a8f55cd60dd774691e Mon Sep 17 00:00:00 2001 From: David Sherret Date: Sat, 24 May 2025 13:32:11 -0400 Subject: [PATCH] ci: error when `cargo test` makes git status dirty (#29429) --- .github/workflows/ci.generate.ts | 16 ++++++++++++++++ .github/workflows/ci.yml | 3 +++ .gitignore | 1 + 3 files changed, 20 insertions(+) diff --git a/.github/workflows/ci.generate.ts b/.github/workflows/ci.generate.ts index 0aa42b188c..6548e8a2cb 100755 --- a/.github/workflows/ci.generate.ts +++ b/.github/workflows/ci.generate.ts @@ -998,6 +998,22 @@ const ci = { ].join("\n"), run: "cargo test --release --locked --features=panic-trace", }, + { + name: "Ensure no git changes", + if: "matrix.job == 'test'", + run: [ + 'if [[ -n "$(git status --porcelain)" ]]; then', + 'echo "๐Ÿงพ Diff:"', + "git diff", + 'echo "โŒ Git working directory is dirty. Ensure `cargo test` is not modifying git tracked files."', + 'echo ""', + 'echo "๐Ÿ“‹ Status:"', + "git status", + 'echo ""', + "exit 1", + "fi", + ].join("\n"), + }, { name: "Configure hosts file for WPT", if: "matrix.wpt", diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3e17e9a624..a1bca4c27b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -614,6 +614,9 @@ jobs: github.repository == 'denoland/deno' && !startsWith(github.ref, 'refs/tags/')))) run: cargo test --release --locked --features=panic-trace + - name: Ensure no git changes + if: '!(matrix.skip) && (matrix.job == ''test'')' + run: "if [[ -n \"$(git status --porcelain)\" ]]; then\necho \"\U0001F9FE Diff:\"\ngit diff\necho \"โŒ Git working directory is dirty. Ensure `cargo test` is not modifying git tracked files.\"\necho \"\"\necho \"\U0001F4CB Status:\"\ngit status\necho \"\"\nexit 1\nfi" - name: Configure hosts file for WPT if: '!(matrix.skip) && (matrix.wpt)' run: ./wpt make-hosts-file | sudo tee -a /etc/hosts diff --git a/.gitignore b/.gitignore index f283b07756..ae49382be0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.orig *.pyc *.swp +*.symcache .env /.cargo_home/