-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor ci.yml to include automatic code formatting and commit changes
- Loading branch information
Showing
1 changed file
with
16 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,18 +11,32 @@ env: | |
CARGO_NET_RETRY: 3 | ||
|
||
jobs: | ||
|
||
fmt: | ||
name: Rustfmt | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # Needed to fetch the full commit history | ||
|
||
- name: Run cargo fmt | ||
env: | ||
TERM: xterm-256color | ||
run: | | ||
cargo fmt --all -- --check | ||
cargo fmt --all | ||
- name: Check for changes | ||
id: git_diff | ||
run: | | ||
git diff --quiet HEAD || echo "::set-output name=changed::true" | ||
- name: Commit and push changes | ||
if: steps.git_diff.outputs.changed == 'true' | ||
run: | | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
git commit -am "Automatically format code with cargo fmt" | ||
git push | ||
main: | ||
needs: fmt | ||
|
@@ -84,4 +98,4 @@ jobs: | |
- name: Run cargo test | ||
# ONLY run test with cargo | ||
if: matrix.use_cross == false | ||
run: cargo test --locked --target ${{ matrix.target }} | ||
run: cargo test --locked --target ${{ matrix.target }} |