From 27d87b71cfdaec93a48a2dc00f8735ce83588d27 Mon Sep 17 00:00:00 2001 From: Kenny Kerr Date: Tue, 19 Mar 2024 13:16:52 -0500 Subject: [PATCH] Add diff check after workflow test run (#2940) --- .github/workflows/test.yml | 11 ++++++++--- crates/tools/yml/src/main.rs | 17 +++++++++++++++-- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 01c49cb8af..e63cf341c3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,8 +35,8 @@ jobs: run: rustup update --no-self-update ${{ matrix.version }} && rustup default ${{ matrix.version }}-${{ matrix.target }} - name: Add toolchain target run: rustup target add ${{ matrix.target }} - - name: Install clippy - run: rustup component add clippy + - name: Install fmt + run: rustup component add rustfmt - name: Fix environment uses: ./.github/actions/fix-environment - name: Test @@ -175,4 +175,9 @@ jobs: cargo test -p windows_i686_msvc && cargo test -p windows_x86_64_gnu && cargo test -p windows_x86_64_gnullvm && - cargo test -p windows_x86_64_msvc \ No newline at end of file + cargo test -p windows_x86_64_msvc + - name: Check diff + shell: bash + run: | + git add -N . + git diff --exit-code || (echo 'Tests changed code in the repo.'; exit 1) diff --git a/crates/tools/yml/src/main.rs b/crates/tools/yml/src/main.rs index e2808ada72..9ce637d75f 100644 --- a/crates/tools/yml/src/main.rs +++ b/crates/tools/yml/src/main.rs @@ -43,8 +43,8 @@ jobs: run: rustup update --no-self-update ${{ matrix.version }} && rustup default ${{ matrix.version }}-${{ matrix.target }} - name: Add toolchain target run: rustup target add ${{ matrix.target }} - - name: Install clippy - run: rustup component add clippy + - name: Install fmt + run: rustup component add rustfmt - name: Fix environment uses: ./.github/actions/fix-environment - name: Test @@ -65,6 +65,19 @@ jobs: } yml.truncate(yml.len() - 3); + + write!( + &mut yml, + r" + - name: Check diff + shell: bash + run: | + git add -N . + git diff --exit-code || (echo 'Tests changed code in the repo.'; exit 1) +" + ) + .unwrap(); + std::fs::write(".github/workflows/test.yml", yml.as_bytes()).unwrap(); }