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

pull-request-labeler misbehaving and therefore disabled again #19088

Closed
rgommers opened this issue Aug 18, 2023 · 5 comments · Fixed by #19728
Closed

pull-request-labeler misbehaving and therefore disabled again #19088

rgommers opened this issue Aug 18, 2023 · 5 comments · Fixed by #19728
Labels
CI Items related to the CI tools such as CircleCI, GitHub Actions or Azure github Items related to the code repository
Milestone

Comments

@rgommers
Copy link
Member

I cannot find back the previous discussion on this, but this bot is misbehaving again (see screenshot below). I believe the deal was that we'd remove it if it did this again, since it is not okay for it to override maintainer actions. I disabled it manually for now; if someone wants to tweak it once more I'm okay with that, but I'd personally prefer if we just got rid of it.

image
@rgommers rgommers added the CI Items related to the CI tools such as CircleCI, GitHub Actions or Azure label Aug 18, 2023
@j-bowhay j-bowhay added the good first issue Good topic for first contributor pull requests, with a relatively straightforward solution label Aug 20, 2023
@agriyakhetarpal
Copy link
Contributor

agriyakhetarpal commented Aug 20, 2023

Happy to take this! It doesn't look like there is a configuration input for disabling the labelling process after a maintainer or someone with the right permissions has removed specific labels on an issue or a PR. Should I remove them or try @j-bowhay's suggestion in #17116 (comment)? There is also a sync-labels option that might be relevant for automatically removing labels based on reverted file changes. Could I get some further direction?

@ilayn
Copy link
Member

ilayn commented Aug 20, 2023

Hi @agriyakhetarpal thanks for helping us. Currently, it is not providing too much of value for us since labeling is rather the easier part of our work and has no consequence if we forget it. Also it is typically not doing what we hoped that it would do occasionally going rogue as above.

If you know how to tame it and make it less aggressive we would all appreciate it. Especially if reverted changes can be reflected that would be really nice.

If it is a lost cause, I think we are also OK to remove it completely.

@agriyakhetarpal
Copy link
Contributor

I will try a few things on a fork of SciPy and link those items here if I can get to something—otherwise I shall remove the implementation in a PR. Thanks, @ilayn!

@rgommers rgommers removed the good first issue Good topic for first contributor pull requests, with a relatively straightforward solution label Nov 15, 2023
@agriyakhetarpal
Copy link
Contributor

agriyakhetarpal commented Nov 20, 2023

Hi, @rgommers and @ilayn: based on the discussion in #17116 and now that the syncing issue actions/labeler#112 has been fixed in the new v4 release of actions/labeler, I would suggest getting back to using that instead of thomasjpfan/labeler@v2.5.1.

  1. To mitigate the misbehaviour caused, a good idea could be to run the workflow only when a pull request is opened, or, in rare cases, reopened without having been merged – instead of on every synchronise event.
  pull_request_target:
    types: [opened, reopened]

This would ensure that the bot adds the labels based on the commit at the time of opening a PR and would not run at all after that regardless of whether the sync-labels input is marked as true or as false.

  1. I tested the workflow in a pull_request event on my fork (since pull_request_target does not usually run on forks) in Trying to debug pull-request-labeler agriyakhetarpal/scipy#2 and it has worked without any problems. I manually removed an automatically added label following which the workflow did not execute. Some more information is available on the PR thread with steps as to how I proceeded with debugging the workflow(s).

  2. Another method of achieving the same thing is to add a label to the pull request and use that to decide12 whether to execute or skip the job (tested on the above PR in my fork)

${{ !contains( github.event.pull_request.labels.*.name, 'reviewed') }}

and use this condition to check for a particular label, say, "reviewed" in this case, and skip the job if the label is found. One more way of doing the same thing, perhaps cleaner, would be via

  pull_request_target:
    types: [unlabeled]

which would make the labeler run on unlabeled PRs and make it not run upon further activity since the PR would already have been labeled by itself, in some parasitic sort of fashion. However, this would mean that at least one label should remain on the PR. The "reviewed" label is just an example, it could as well be one of these "scipy.*" labels if a new label is not to be added to the repository

  1. The last recommendation is to move the permissions currently associated with the workflow level to the job level for security reasons, given that this workflow runs on a pull_request_target event rather than a standard pull_request event and it would always contain just a singleton job.

Thanks for the patience for letting me get back on this and apologies for the delay caused. I have presented multiple potential solutions wherein some of them should provide a failsafe even if pull-request-labeler does not work as expected again (they can be combined too!), please let me know if adding the sync-labels option set to false should be fine or if there is anything specific or more to be desired with the functionality that I can work on and contribute by writing a PR for.

Footnotes

  1. https://github.com/orgs/community/discussions/26712

  2. https://stackoverflow.com/questions/59588605/how-to-check-for-a-label-in-a-github-action-condition

@lucascolley lucascolley added the github Items related to the code repository label Nov 20, 2023
@lucascolley
Copy link
Member

Hi @agriyakhetarpal! IMO, it would be great if you could open a PR for this with the types: [opened] method (no need for reopened IMO). I don't think there is any need to consider which labels are already on the PR - we just want this to run once when the PR is opened.

The last recommendation is to move the permissions currently associated with the workflow level to the job level for security reasons

Sounds good.

please let me know if adding the sync-labels option set to false should be fine

It looks like the default is false, so just leave it out. I don't think it would make a difference anyway when we only run on [opened] events.


Feel free to ping me on the PR once it is open!

agriyakhetarpal added a commit to agriyakhetarpal/scipy that referenced this issue Dec 21, 2023
 See scipy#19088. These permissions are moved from the level of the workflow to that of the job for security reasons, since this workflow uses the `pull_request_target` event.

[skip cirrus] [skip circle]
agriyakhetarpal added a commit to agriyakhetarpal/scipy that referenced this issue Dec 21, 2023
As per the discussion in scipy#19088

[skip circle] [skip cirrus]
agriyakhetarpal added a commit to agriyakhetarpal/scipy that referenced this issue Dec 21, 2023
See scipy#19088

[skip cirrus] [skip circle]
agriyakhetarpal added a commit to agriyakhetarpal/scipy that referenced this issue Dec 21, 2023
See scipy#19088

[skip cirrus] [skip circle]

Co-authored-by: Jake Bowhay <60778417+j-bowhay@users.noreply.github.com>
j-bowhay added a commit that referenced this issue Dec 22, 2023
…low (#19728)

* MAINT, ENH: move labeler permissions to the level of the job

 See #19088. These permissions are moved from the level of the workflow to that of the job for security reasons, since this workflow uses the `pull_request_target` event.

---------

Co-authored-by: Jake Bowhay <60778417+j-bowhay@users.noreply.github.com>
@j-bowhay j-bowhay added this to the 1.13.0 milestone Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI Items related to the CI tools such as CircleCI, GitHub Actions or Azure github Items related to the code repository
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants