Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor ci.yml to include automatic code formatting and commit changes #957

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }}