-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ci] add reformat workflow to automatically do reformat
Signed-off-by: Avimitin <[email protected]>
- Loading branch information
Showing
9 changed files
with
59 additions
and
76 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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: reformat | ||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
- reopened | ||
- ready_for_review | ||
- labeled | ||
|
||
# Cancel the current workflow when new commit pushed | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
run: | ||
name: "Reformat all codes" | ||
# Don't run reformat when: | ||
# - user cancel | ||
# - PR from outside repository ( we don't have permission to push commit into fork repository ) | ||
if: ${{ !cancelled() && github.event.pull_request.head.repo.full_name == github.repository }} | ||
runs-on: [self-hosted, linux, nixos] | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
ref: ${{ github.head_ref }} | ||
- name: "Reformat all T1 module codes" | ||
run: nix develop ".#t1.elaborator.editable" -c mill -i _.reformat | ||
- name: "Reformat all Rust codes" | ||
run: | | ||
cd difftest | ||
nix shell ".#cargo" ".#rustfmt" -c cargo fmt | ||
- name: "Commit formats" | ||
run: | | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
changed_cases=$(git diff --name-only) | ||
if [ -n "$changed_cases" ]; then | ||
echo -e "Reformat codes: $changed_cases" | ||
git add . | ||
git commit -m "[chore] reformat all T1 modules" | ||
git push origin ${{ github.head_ref }} | ||
else | ||
echo "No format error detected" | ||
fi |
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
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
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
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
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
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
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
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