Add the black formatter GitHub Action
Is your feature request related to a problem? Please describe. There is a need for a uniform coding style across p5py
Describe the solution you'd like Add a GitHub action that checks a PR for coding style using black. The GHA should be able to format the code and commit it to the PR if the PR is not following the coding style.
Hey @tushar5526, I am looking forward to solving this Issue. Would you Please Assign it to me?
@tushar5526 Some things I just want to ask:
- The GHA runs, it finds that the code is not formatted and after formatting it, it should create a new PR with formatted code or it should make changes to the existing PR.
- What about the pre-existing code, does the GHA need to also check the pre-existing code and format it?
Break it into two PRs
- A PR that formats the whole code base using black. Do this after we merge enhancing skia PR, to avoid unnecessary conflicts.
- A PR to make a GHA that runs on incoming PRs formats the code and make a commit to that PR only. Yes you can just run black on the whole project instead of only the files that are changed.
Also, I suppose we have to format our code base first and make a PR for it.
So you can try setting up the GHA (that would run on PRs) on your fork by the time we get the pending changes merged.
Break it into two PRs
- A PR that formats the whole code base using black. Do this after we merge enhancing skia PR, to avoid unnecessary conflicts.
- A PR to make a GHA that runs on incoming PRs formats the code and make a commit to that PR only. Yes you can just run black on the whole project instead of only the files that are changed.
for the formatting of the pre-existing codebase do we need any GHA? In my view I don't think so, We need GHA for the new PRs, for the pre-existing codebase I'll make a PR by formatting it.
Break it into two PRs
- A PR that formats the whole code base using black. Do this after we merge enhancing skia PR, to avoid unnecessary conflicts.
- A PR to make a GHA that runs on incoming PRs formats the code and make a commit to that PR only. Yes you can just run black on the whole project instead of only the files that are changed.
for the formatting of the pre-existing codebase do we need any GHA? In my view I don't think so, We need GHA for the new PRs, for the pre-existing codebase I'll make a PR by formatting it.
Yes
I am not sure if GHA can commit directly to the author's branch. In the case it can't, we can just fail the build and let the PR author format their code locally and update the result in their PR.
I did something once to commit to a PR, but I am not sure if it still works. @Mr-Sunglasses Take a look here
Hey @Mr-Sunglasses I have run the black formatter on the whole project so I could start with my next milestone in the project. Otherwise, if this was done and merged later, there might have been a lot of merge conflicts that I then have to handle manually.
You can directly work on the GHA now.
Sure I'll be working on GHA now, will make a PR this week itself.
No problem, take your time.
Hey @Mr-Sunglasses, have you got the chance to work on this issue ?
@tushar5526 I have created a GH action, Looking Forward for your review.
Works like a charm @Mr-Sunglasses
Thanks!