Skip to content
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

Add a reminder when contributor is new to ping all contributor bot #2484

Merged
merged 47 commits into from Apr 11, 2024

Conversation

KevinEyo1
Copy link
Contributor

@KevinEyo1 KevinEyo1 commented Mar 29, 2024

What is the purpose of this pull request?

  • Documentation update
  • Bug fix
  • Feature addition or enhancement
  • Code maintenance
  • DevOps
  • Improve developer experience
  • Others, please explain:

Overview of changes:
Fixes #2457
Added workflow to check on merge whether pr author is new to the repo, and ping a reminder to add them to contributors list

Anything you'd like to highlight/discuss:

Testing instructions:
test repo

  1. Fork this repo and make any change and push it.
  2. Create a PR
  3. I can merge it and new contributor message pops up
  4. Repeat steps 1 and 2
  5. I can merge it and no more new contributor message pops up

Proposed commit message: (wrap lines at 72 characters)
GitHub Actions: ping new contributor

It is easy to forget to add new contributors.

Adding a workflow to automate reminders to add will help.

Let's on merge, check whether PR author has a prior merged PR,
pinging them if not since they are a new contributor.

This approach allows the user to remember to ask to be added to
the contributor list, if they want to.


Checklist: ☑️

  • Updated the documentation for feature additions and enhancements
  • Added tests for bug fixes or features
  • Linked all related issues
  • No unrelated changes

Reviewer checklist:

Indicate the SEMVER impact of the PR:

  • Major (when you make incompatible API changes)
  • Minor (when you add functionality in a backward compatible manner)
  • Patch (when you make backward compatible bug fixes)

At the end of the review, please label the PR with the appropriate label: r.Major, r.Minor, r.Patch.

Breaking change release note preparation (if applicable):

  • To be included in the release note for any feature that is made obsolete/breaking

Give a brief explanation note about:

  • what was the old feature that was made obsolete
  • any replacement feature (if any), and
  • how the author should modify his website to migrate from the old feature to the replacement feature (if possible).

Copy link

codecov bot commented Mar 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 51.00%. Comparing base (362f761) to head (7c00b6e).

❗ Current head 7c00b6e differs from pull request most recent head 03bde6f. Consider uploading reports for the commit 03bde6f to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2484   +/-   ##
=======================================
  Coverage   51.00%   51.00%           
=======================================
  Files         124      124           
  Lines        5384     5384           
  Branches     1162     1162           
=======================================
  Hits         2746     2746           
  Misses       2348     2348           
  Partials      290      290           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 20 to 35
const opts = github.rest.issues.listForRepo.endpoint.merge({
...context.issue,
creator,
state: 'all'
})
const issues = await github.paginate(opts)

for (const issue of issues) {
if (issue.number === context.issue.number) {
continue
}

if (issue.pull_request) {
return // Creator is already a contributor.
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part lgtm but I am thinking of an alternative

Instead of checking all prs and see if there is any previous prs by the pr creator, I am thinking if we could utilise Github's built-in function to get the current list of contributors and check if the person is inside

https://docs.github.com/en/rest/repos/repos?apiVersion=2022-11-28#list-repository-contributors

Not sure if this approach would speed up the process since we do not have to go through every closed pr

Copy link
Contributor Author

@KevinEyo1 KevinEyo1 Mar 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @LamJiuFong, thanks for the suggestion, I think it will be more efficient.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes @KevinEyo1 ! LGTM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @LamJiuFong after testing, I realised that since we are running the job on merge, the author is already part of the list by the time the action is run, so it fails to detect the author as a new contributor. I will revert to the original implementation, and I will try to figure out if there can be performance enhancements.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see, sorry for missing that out

What about checking if the author has only one pr merged (which is the newly merged one), would that be possible?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LamJiuFong I am trying to think of a more efficient solution as well but I think to check if the author has only one PR merged we would have to fetch all the PRs anyway (which is what is done in the current implementation) leading to a similar time taken

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spoke to Kevin about this previously and he did this check: Test run to check time which wasn't very long. So I don't think there is a need to overoptimize in this case.

@yucheng11122017
Copy link
Contributor

Hi @KevinEyo1 thanks for the work! Could you also include some test workflows for us to check if its ok?

@KevinEyo1
Copy link
Contributor Author

Hi @yucheng11122017 I'm still working on the testing and fixing bugs, I will add the test workflows when I set this PR to ready for review.

Copy link
Contributor

@yucheng11122017 yucheng11122017 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@KevinEyo1
Copy link
Contributor Author

Test run to check time

Copy link
Contributor

@kaixin-hc kaixin-hc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No comments on implementation, which I think looks good now!

However, I don't love the look of the commit message. Is there a reason why we're pinging the contributor and asking them to ask to be recognised? It feels less friendly. I'm OK with it if we also amend the readme/expectations as well.

Also, I was thinking that this is essentially a "welcome" message to the repository of sorts. It might be nice to also use this to recognise and welcome the contributor even more, the same way some other OSSes have decided to work. Something like what scribeOS does? see this reflection

what do @MarkBind/active-devs think?

Edit: I realise this might be confusing bc of my previous comment on the issue, but I'd like to clarify my issue isn't with asking contributors to add themselves, but that the only place where recognition is talked about is asking contributor to add themselves. I personally would find it scary and wonder if a mistake was made, and people might be scared to ask for recognition or feel like their work is not recognised. Other repos which adopt asking contributors to add themselves make it part of the PR checklist and devdocs / readme so that it's clear its part of regular expectations. Otherwise, I think a reminder nudge to the person who merged the PR / active devs is the way to go!

@KevinEyo1
Copy link
Contributor Author

Hi @kaixin-hc, those are some good points. Can I just clarify what you mean by welcoming them more?

@kaixin-hc
Copy link
Contributor

It's an open-ended thought - looking for ideas. I think more encouragement early on can be good for newer contributors? But I'm also not certain on implementation

per_page: 100
},
(response) => response.data.filter(pr => pr.merged_at != null && pr.user.login === prAuthor && pr.number !== currentPR)
);
Copy link
Contributor

@itsyme itsyme Apr 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do correct me if I am wrong, from my understanding this gets the last 100 pull requests and checks if the user has a merged PR within the last 100 PRs, would this mean that the comment will be sent for a user that hasn't had any merged PRs in the last 100 PRs?

Copy link
Contributor Author

@KevinEyo1 KevinEyo1 Apr 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @itsyme, thanks for the review, it actually collects all the PRs, its just that it collects them 100 at a time for the pagination. You can refer to here. github-scripts uses octokit

@KevinEyo1
Copy link
Contributor Author

Copy link
Contributor

@itsyme itsyme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Definitely a useful GitHub action for MarkBind's maintainers! Thanks for the work!

@yucheng11122017 yucheng11122017 merged commit 889836c into MarkBind:master Apr 11, 2024
7 checks passed
Copy link

@yucheng11122017 Each PR must have a SEMVER impact label, please remember to label the PR properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a reminder when contributor is new to ping all contributor bot
6 participants