Skip to content

Commit

Permalink
Refactor ci.yml to include automatic code formatting and commit changes
Browse files Browse the repository at this point in the history
  • Loading branch information
niStee committed Oct 16, 2024
1 parent a5df40e commit c212a1b
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}

0 comments on commit c212a1b

Please sign in to comment.