ci: error when cargo test makes git status dirty (#29429)

This commit is contained in:
David Sherret 2025-05-24 13:32:11 -04:00 committed by GitHub
parent ff078dcfab
commit c6c6be328f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 20 additions and 0 deletions

View file

@ -998,6 +998,22 @@ const ci = {
].join("\n"), ].join("\n"),
run: "cargo test --release --locked --features=panic-trace", 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", name: "Configure hosts file for WPT",
if: "matrix.wpt", if: "matrix.wpt",

View file

@ -614,6 +614,9 @@ jobs:
github.repository == 'denoland/deno' && github.repository == 'denoland/deno' &&
!startsWith(github.ref, 'refs/tags/')))) !startsWith(github.ref, 'refs/tags/'))))
run: cargo test --release --locked --features=panic-trace 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 - name: Configure hosts file for WPT
if: '!(matrix.skip) && (matrix.wpt)' if: '!(matrix.skip) && (matrix.wpt)'
run: ./wpt make-hosts-file | sudo tee -a /etc/hosts run: ./wpt make-hosts-file | sudo tee -a /etc/hosts

1
.gitignore vendored
View file

@ -1,6 +1,7 @@
*.orig *.orig
*.pyc *.pyc
*.swp *.swp
*.symcache
.env .env
/.cargo_home/ /.cargo_home/