Skip to content

Commit

Permalink
Add diff check after workflow test run (#2940)
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr authored Mar 19, 2024
1 parent 69ffb41 commit 27d87b7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
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)
17 changes: 15 additions & 2 deletions crates/tools/yml/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
}

Expand Down

0 comments on commit 27d87b7

Please sign in to comment.