-
Notifications
You must be signed in to change notification settings - Fork 3
Update CLA checker workflow #44
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
james-bruten-mo
left a 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.
I think the logic around removing comments looks ok.
I'm not sure the check of cla removed is correct though. This will always fail when an author is relying on their name being on base and branching from before that. This will be both annoying for developers who do multiple PRs per release, and also make conflicts and duplications more likely.
I also think the grep should be more permissive in this workflow - we're checking for the author existing, not correct formatting of the file.
.github/workflows/cla-check.yaml
Outdated
| if [ -f "CONTRIBUTORS" ]; then | ||
| if grep -q "^$AUTHOR" CONTRIBUTORS; then | ||
| if [ -f "CONTRIBUTORS.md" ]; then | ||
| if grep -q "| $AUTHOR |" CONTRIBUTORS.md || grep -q "| $AUTHOR " CONTRIBUTORS.md; then |
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.
Formatting this as a markdown table is sensible, but I think this check shouldn't be reliant on correct formatting, particularly with whitespace.
So keep as grep -q "$AUTHOR"
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 we should keep the check for the username to be in between | and |. Perhaps we can relax with the spaces around the username. Imagine a substring collision in another column for a different entry...
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.
Yeah fair enough, something like grep -qE "|\s*$AUTHOR\s*|" CONTRIBUTORS.md (not tested!)
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.
That should work, I think we probably ned to escape the pipes?
grep -qE "\|\s*$AUTHOR\s*\|" CONTRIBUTORS.md
.github/workflows/cla-check.yaml
Outdated
| echo "signed=true" >> $GITHUB_OUTPUT | ||
| echo "✅ $AUTHOR has updated their CLA signature in CONTRIBUTORS file." | ||
| if [ -f "CONTRIBUTORS.md" ]; then | ||
| if grep -q "| $AUTHOR |" CONTRIBUTORS.md || grep -q "| $AUTHOR " CONTRIBUTORS.md; then |
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.
Same as above
.github/workflows/cla-check.yaml
Outdated
| const author = context.payload.pull_request.user.login; | ||
| // Check if contributor was on base but removed themselves from PR | ||
| const removedFromPr = signedOnBase && !signedOnPr; |
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.
Is this complex enough? Once the first PR is on they'll have signed on base. But I would imagine they don't need to add themselves to the CONTRIBUTORS.md in subsequent PRs as it's already on base. This logic will fail in that scenario. I think it should be checking the diff of the CONTRIBUTORS file and looking for their username being removed.
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.
hmmm.. my brain was frozen at 1am. Agree, we should test different scenarios.
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.
Good point and as discussed I've updated the workflow to handle the scenario where a contributor has already signed the CLA in the base branch. Here's what changed:
- a new step to check if CONTRIBUTORS.md was modified in the PR by comparing changed files between base and PR branch.
removedFromPrnow only triggers if the contributor was on base, not on PR, and they modified the CONTRIBUTORS.md file (intentionally removed themselves)cla_metnow passes if either contributor is signed on both base and PR branches, OR
contributor is signed on base branch AND didn't touch the CONTRIBUTORS.md file in their PR.
|
Tagging @jennyhickson in this in case she has thoughts on the removal process |
james-bruten-mo
left a 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.
Thanks for adding the git diff logic, that looks like it should do what we want it to!
Adding some changes to existing cla-checker workflow: