FINERACT-2462: Add github action to enforce one commit per user in a PR#5437
FINERACT-2462: Add github action to enforce one commit per user in a PR#5437edk12564 wants to merge 1 commit intoapache:developfrom
Conversation
ee6574f to
65d1cba
Compare
| - name: Comment on PR | ||
| if: failure() | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
There was a problem hiding this comment.
Is token is necessary in this?
There was a problem hiding this comment.
From my understanding that Github token isn't the same one we use to authenticate our accounts. It's a separate token created per workflow for using the Github API calls in your actions. I believe it is required to access .author.id.
More on this here:
https://docs.github.com/en/actions/tutorials/authenticate-with-github_token
There was a problem hiding this comment.
Seems Ok, Can you also check the workflow of stale.yml, i really like the way it checks prs. This will not run without workflow approval and stale is a cron based job.
There was a problem hiding this comment.
I'll take a look now!
There was a problem hiding this comment.
I did a bit of research, and I agree with your view. The Stale workflow has a lot of merits, and I will look into adding to what we have. To summarize though, this is what I found.
1 - The current implementation needs permissions for it to run properly. Stale.yml uses the main repo's context, which allows it to run without manual approval.
On this note, I found something we could use. If we use pull_request_target instead of pull_request, we could run our workflows with base repo permissions. I am reading about it here: https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#pull_request_target.
The main issue for this seems to be that this raises security concerns about running code without prior approval. But I think this might be fine considering we are only looking at the commit repository, PR number, and userIds. We don't actually execute any foreign code. Let me know what you think on this one!
2 - I also see what you mean about running a cronjob. I think this is a good idea as well. However, if we want to run on a cronjob to handle older PRs, the issue is that we probably shouldn't spam comments in case of users abandoning their PR. I think we should implement something like checking the most recent comment, or maybe we won't produce warnings if the no one has committed in the past day or two? I will take a look and let you know what our options are here.
What do you think on those points?
There was a problem hiding this comment.
Hello @Aman-Mittal , Ashar Khan would like to work on this ticket as well. But before that, should we go ahead with the Cron based feature as well? Because I believe otherwise, the work is completed after my next commit. Once I can figure out these GPG keys.
There was a problem hiding this comment.
@edk12564 You are free to colaborate with others. and also mentioned in ticket that dev consensus is currently towards one commit per PR. so please keep track on that.
https://lists.apache.org/thread/f0tx0p7jd9f2nhzpgp75hxk267hrmnd9
There was a problem hiding this comment.
Ahh, I see. I might have misunderstood the direction at first. You're right, let's wait this one out.
There was a problem hiding this comment.
@edk12564 There is another case i found which can affect the ticket and needs discussion, which is signed commit check, while there can be trailers but only one person can sign that commit, if that is not signed properly this can affect either PR check or can cause loosing credit if signer was not careful
There was a problem hiding this comment.
@Aman-Mittal Hey Aman! Thanks for posting that point. It was a direction I hadn't thought of. I agree that if the direction of the project is to sign all our commits to prove contribution, it's a concern that we can only sign one person. I also brought up the point of Github not recognizing contribution unless it's a commit or co-authorship as well. Let's see what everyone says!
65d1cba to
eb3491a
Compare
705c0a9 to
c45fec9
Compare
|
Sorry about that. I'll fix this now! |
c45fec9 to
d101ab7
Compare
- added commit check - accounted for edge case where git and github emails don't match - accounted for edge case where wrong git account hasn't squashed DesignedBy: Edward Kang and Aman Mittal ReviewedBy: Aman Mittal ReportedBy: Aman Mittal
d101ab7 to
9c8fa98
Compare
Description
JIRA: FINERACT-2462
Implemented a Github Action that runs on PR request changes, opens, and closes.
The Github Action checks for:
The action on failure is to comment in the PR thread with the type of error, as well as show in the error’s logs.
The feature allows for multiple users per PR, but only 1 commit per user.
Edge Cases and Behavior
Test Cases I have tried:
Edge Cases covered in code:
Failure Path (misconfigured git email):

Failure Path (multiple commits per user):

Checklist
Please make sure these boxes are checked before submitting your pull request - thanks!
Your assigned reviewer(s) will follow our guidelines for code reviews.