Skip to content

Commit

Permalink
auto lint code with cargo fmt (#381)
Browse files Browse the repository at this point in the history
  • Loading branch information
v9n committed Jul 7, 2023
1 parent 7b3d4e4 commit 6946450
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Lint

on: [push]

jobs:
build:
runs-on: self-hosted
steps:
- uses: actions/checkout@v3
# on self-hosted runner, we already pre-installed the rust toolchain
- name: Format the code with rust fmt
id: cargo_fmt
run: |
cargo fmt
if [ -z "$(git diff .)" ]; then
echo code format ok
echo "need_format=false" >> "$GITHUB_OUTPUT"
else
echo "need_format=true" >> "$GITHUB_OUTPUT"
fi
- name: Format the code
if: steps.cargo_fmt.outputs.need_format == 'true'
run: |
git config --global user.name 'oak-code-formatter'
git config --global user.email '[email protected]'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
git checkout $GITHUB_HEAD_REF
git commit -am "fixup: auto format Rust code"
git push

0 comments on commit 6946450

Please sign in to comment.