-
Notifications
You must be signed in to change notification settings - Fork 11
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
Add an option to apply pre-commit and clang-tidy fixes #238
Open
greole
wants to merge
18
commits into
main
Choose a base branch
from
enh/formating_workflow
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 13 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
53a00c0
make it always succeed
greole eaeaabd
change workflow names
greole bf7cfc3
change trigger
greole af25b67
use label instead of comment
greole 7b34dec
trigger if labeled
greole 9319924
move to end
greole 58703be
add format error for test
greole 2869910
change bot message
greole 7b8b030
check if clang-tidy auto-fix works
greole 0d109f0
add label to documentation
greole 43e7ac6
check if clang-tidy auto-fix works
greole 70c191c
dont commit workflow files
greole 72b183e
check for specific failure
greole d437b4d
try to create if not existing comment
greole 0907ce6
fix format
invalid-email-address a999de0
comment only if no previous comment exists
greole cd0a762
empty trigger ci
greole 09aa35b
refere to benchmark data repo
greole File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
@@ -1,12 +1,45 @@ | ||
name: Static checks | ||
run-name: Static checks | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize] | ||
types: [opened,synchronize,labeled] | ||
env: | ||
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | ||
permissions: | ||
contents: write | ||
jobs: | ||
pre-commit-run: | ||
name: Pre-commit run | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{env.BRANCH_NAME}} | ||
- name: Install dependencies | ||
run: | | ||
sudo apt update | ||
sudo apt install \ | ||
pre-commit | ||
pip install identify --upgrade | ||
pre-commit install | ||
- name: Run pre-commit on all files | ||
id: pre-commit | ||
run: pre-commit run --all --color always --verbose | ||
- name: Commit pre-commit fixes | ||
if: ${{contains(github.event.pull_request.labels.*.name, 'auto-fix') && failure() && steps.pre-commit.conclusion == 'failure'}} | ||
run: | | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
git add . | ||
git commit -m 'fix format' | ||
git push origin ${{env.BRANCH_NAME}} | ||
- name: check for todo fixme note | ||
run: | | ||
NTODOS="$(grep -r 'TODO DONT MERGE' --exclude-dir=.github | wc -l)" | ||
echo "Found $NTODOS TODO DONT MERGE notes" | ||
! grep -q -r "TODO DONT MERGE" --exclude-dir=.github | ||
build-compilation-db: | ||
if: ${{!contains(github.event.pull_request.labels.*.name, 'Skip-build')}} | ||
if: ${{!contains(github.event.pull_request.labels.*.name, 'Skip-build') }} | ||
name: Build with IWYU | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
@@ -55,6 +88,8 @@ jobs: | |
needs: [build-compilation-db] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{env.BRANCH_NAME}} | ||
|
||
- name: Add clang repo | ||
run: | | ||
|
@@ -88,8 +123,8 @@ jobs: | |
| grep -F -f pattern - > files | ||
# run clang-tidy on all specified files | ||
clang-tidy-16 --fix --extra-arg=-w -p build/develop $(cat files) | ||
|
||
- name: Check for fixes | ||
id: tidy-fixes | ||
run: | | ||
if [[ $(git ls-files -m | wc -l) -eq 0 ]]; then | ||
exit 0 | ||
|
@@ -98,25 +133,15 @@ jobs: | |
echo "Please use your local clang-tidy or apply the following patch:" | ||
git diff -p | ||
exit 1 | ||
pre-commit-run: | ||
name: Pre-commit run | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install dependencies | ||
- name: Commit clang-tidy-fixes | ||
if: ${{contains(github.event.pull_request.labels.*.name, 'auto-fix') && failure() && steps.tidy-fixes.conclusion == 'failure'}} | ||
run: | | ||
sudo apt update | ||
sudo apt install \ | ||
pre-commit | ||
pip install identify --upgrade | ||
pre-commit install | ||
- name: Run pre-commit on all files | ||
run: pre-commit run --all --color always --verbose | ||
- name: check for todo fixme note | ||
run: | | ||
NTODOS="$(grep -r 'TODO DONT MERGE' --exclude-dir=.github | wc -l)" | ||
echo "Found $NTODOS TODO DONT MERGE notes" | ||
! grep -q -r "TODO DONT MERGE" --exclude-dir=.github | ||
rm pattern files | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
git add . | ||
git commit -m 'fix format' | ||
git push origin ${{ github.BRANCH_NAME }} | ||
changelog: | ||
if: ${{!contains(github.event.pull_request.labels.*.name, 'Skip-Changelog')}} | ||
name: Changelog check | ||
|
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 |
---|---|---|
|
@@ -73,3 +73,4 @@ NeoFOAM/* | |
_build | ||
|
||
.vs/ | ||
*.key |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bot seems a bit spammy. Is there a way to only post once per PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should actually post it only once. I just deleted the comments of the bot to check how the most recent version renders.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's removing the old comment and adding a new one. I still got multiple emails with the same bot comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this action should use the
pull_request:open
event. That would probably mean to extract it into a new file.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok this should be resolved now with a999de0
i just check if the bot already posted.