-
Notifications
You must be signed in to change notification settings - Fork 733
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
Allow automatic triggering of autofixing of Pull Request linting errors with a comment #10876
Comments
I've spent too many hours and this script detects the comment but the workflow seems to be skipping the
I feel like pre-commit.ci doesn't work well with comments. It would be simpler to just run a lint check on every pull request as shown in the docs |
The error there seems to be coming from the incorrect version of node being used. If you look at our current pre-commit action: https://github.com/learningequality/kolibri/blob/develop/.github/workflows/pre-commit.yml#L36 the version of node needs to be properly set. The reason that pre-commit-ci/lite-action is not doing anything is because there is nothing to commit. The error is coming from the incorrect node version, not any linting failure. |
Yes thank you @rtibbles, I hadn't been reading the error message properly before. When pre-commit-ci lite is triggered by comments, it says
Instead, should we just run pre-commit-ci lite on every pull request? That would be a very simple fix |
I'm interested in this. Just a couple of clarifications:
Could you please provide some insights on how you'd like me to proceed with these aspects? Thank you! Also, could I be assigned to this issue? |
I will assign you - I would recommend doing tests of this in your own test repository to have full control and permissions over the action (if you add the action via a pull request directly in the Kolibri repo, there will be no way to test it on pull requests). |
Please check this: https://github.com/thesujai/kolibri/blob/release-v0.16.x/.github/workflows/precommit-autofix.yml What I am not sure is about if there will be security compromises with this? if yes: |
The main issue I can see with the action you've got in there, is that it is running on the main branch post-merge - which wouldn't allow for linting to be fixed before merge. As you noted above, there are some linting issues that can't be fixed automatically, so we would want to do the autofixing, but still confirm that everything is fixed before we merge to account for these issues. |
In terms of the permissions we would need, Peter Evans has a lot of documentation for how to achieve this properly, which is definitely worth engaging with to understand how to do this best. |
Thank you for you suggestions. After a day working on this, i got two solutions that will auto fix pre-merge
at the last here This will fix automatically on every other commit in the PR, all we need to do is install pre-commit.ci lite in this REPO. But if we are some how able to override the github.event_name to 'pull_request' even when the event is 'issue_comment', we surely can achieve an autofix on comment. I tried many methods, but all failed.
I have tested both the approach, both works fine only. |
Let's give the first option a go then - it's not the completely ideal solution, but would cover most use cases. If the commit is unwanted and the developer prefers to fix the linting in another way, then they always have the option to update locally and force push to override the commit. |
Expected behavior
A Github action that is triggered by comments on open Pull Requests.
If the pull request comment contains the text "autofixme!" then the workflow should run
pre-commit run --all-files
or equivalent on the code of the pull request. If there are any unstaged changes after this (i.e. autofixes have been generated), then they should be committed and pushed to the pull request branch.This may be most easily accomplished by simply triggering the pre-commit-ci lite action in the case that autofixme! is detected https://pre-commit.ci/lite.html
The text was updated successfully, but these errors were encountered: