-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CI: add slash dispatch workflow to trigger pre-commit checks with comment #38444
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
Conversation
Cool, thanks! |
Thanks @jorisvandenbossche ! I didn't know you could do that, that indeed does look simpler, I'll see if I can update this to do it that way |
@jorisvandenbossche OK, done If the comment-bot is now largely taken from |
I don't think that that is necesaarily needed in this case. I mean, I contribute to several projects, and I am constantly applying what I tried / learned how to set up github actions in one project to other projects. Also, if you include the license, you would need to clearly state what has changed. And in the end, the main thing you copied is the line |
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.
Thanks for the update!
.github/workflows/comment_bot.yml
Outdated
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.8 | ||
- name: install-pre-commit |
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.
- name: install-pre-commit | |
- name: Install pre-commit |
(to be consistent with other names)
.github/workflows/comment_bot.yml
Outdated
jobs: | ||
autotune: | ||
name: "Fixup pre-commit formatting" | ||
if: startsWith(github.event.comment.body, '@github-actions autotune') |
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 would maybe keep a "pre-commit" specific command
(we can always later have other bot actions, and name something combined "autotune", but for now it's just pre-commit)
- name: Commit results | ||
run: | | ||
git config user.name "$(git log -1 --pretty=format:%an)" | ||
git config user.email "$(git log -1 --pretty=format:%ae)" |
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.
Does this use the author of the last commit on the PR as commiter here?
Maybe your original "github actions" user is more transparent in who commited it?
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -m "Run pre-commit" -a
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.
Actually, using the PR author / last commiter as commit author here is maybe good. That avoids that github wants to add the bot to the "Co-authored-by", which is not needed.
A "[automated commit]" in the commit message should be clear enough about the origin of the change.
.github/workflows/comment_bot.yml
Outdated
run: | | ||
git config user.name "$(git log -1 --pretty=format:%an)" | ||
git config user.email "$(git log -1 --pretty=format:%ae)" | ||
git commit -a -m 'Autoformat/render all the things [automated commit]' || echo "No changes to commit" |
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 would also keep your original message here, something more specific to pre-commit
What are your thoughts on #38444 (comment) ? |
Hey Joris - sorry, I missed that comment, somehow my brain only registered the review comments - I've removed the license header as I think your assessment makes perfect sense (as someone with far less experience, I was trying to tread carefully) |
this looks fine to me. let's give it a try. |
@MarcoGorelli can you add somewhere the various actions that are availabel (take is in the user docs, but this one plus the backport ones could go somewhere) |
Thanks! |
This would be an on-demand bot to run pre-commit checks on a PR, which can be triggered by commenting
on a pull request (see here for a demo).
Use case: if a PR is submitted and is good-to-go except for some linting error, we can just comment
/pre-commit-run
and have the bot fixup the errors.