Skip to content

Commit

Permalink
[ci] add lint CI
Browse files Browse the repository at this point in the history
Signed-off-by: Avimitin <[email protected]>
  • Loading branch information
Avimitin committed Sep 3, 2024
1 parent 0d25d9e commit 4fbc2a5
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Code linting
on:
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
- labeled
env:
USER: runner

# Cancel the current workflow when new commit pushed
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
checkfmt:
name: "Check formats"
strategy:
fail-fast: false
runs-on: [self-hosted, linux, nixos]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.head_ref }}
- name: "Run testcases"
run: |
RET=0
warnOnFileChanged() {
if ! git diff -q --exit-code; then
RET=1
local msg="$1"; shift
echo "$msg"
echo "$msg" >> $GITHUB_STEP_SUMMARY
git reset --hard
fi
}
nix develop '.#t1.elaborator' -c mill -i _.reformat
warnOnFileChanged "* Scala format fail, please run 'nix develop '.#t1.elaborator' -c mill -i _.reformat'"
nix fmt
warnOnFileChanged "* Nix format fail, please run 'nix fmt'"
pushd difftest
nix run '.#cargo' -- format
warnOnFileChanged "* Cargo format fail, please run 'cd difftest; nix run .#cargo -- format'"
popd
pushd t1rocketemu
nix run '.#cargo' -- format
warnOnFileChanged "* Cargo format fail, please run 'cd t1rocketemu; nix run .#cargo -- format'"
popd
if nix run '.#rg' -- '\p{Script=Han}' > zh-hans.txt; then
RET=1
msg="* Found ZH_CN comments"
echo "$msg"
echo "$msg" >> $GITHUB_STEP_SUMMARY
echo "```text" >> $GITHUB_STEP_SUMMARY
cat zh-hans.txt >> $GITHUB_STEP_SUMMARY
echo "```" >> $GITHUB_STEP_SUMMARY
git reset --hard
fi
exit $RET

0 comments on commit 4fbc2a5

Please sign in to comment.