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 option to create GitHub issue on rule violation #247

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Brend-Smits
Copy link
Collaborator

@Brend-Smits Brend-Smits commented Apr 11, 2022

Motivation

At @philips-software, we want to be able to 'fix' a broken rule and be able to configure it per rule what should happen. For some rules, a notification should be sent, others a Github Issue should be created, and some should even create a PR.

Proposed Changes

This Pull Request adds the ability to define a fix that will create a customizable issue on a target repository.

This currently includes:

  • Each rule includes a unique id that allows us to programmatically identify which issue is part of which rule.
  • Checks if there are existing issues that are open to prevent issue spam. If there are open issues, matching the unique rule id, it will do nothing.
  • Checks if there are existing closed issues that match the unique rule id. If there are, it will re-open them, update the issue body/title and comment on it. This makes the repo owner aware that there is some sort of regression.
  • Automatically create and assign labels like: 'Repolinter', 'automated', 'CC: Bypass'
  • Add an ability to bypass future Repolinter checks for a specific ruleset by applying the Bypass Label.
  • Each rule configuration is customizable within the ruleset (https://github.com/Brend-Smits/octokit-test-repo/blob/main/ruleset.json#L37-L46)
  • Environment variables that are available and required: TARGET_REPO (philips-labs/repolinter) GITHUB_TOKEN (Personal Access Token)

Test Plan

  1. Input a PAT via environment variable using export GITHUB_TOKEN=TOKENHERE
  2. Input a target repository via environment variable using export TARGET_REPO=brend-smits/octo-test-repo
  3. Execute ./bin/repolinter.js -g https://github.com/Brend-Smits/octokit-test-repo --rulesetFile rulesets/fixer.json or execute it on your own repository with your own ruleset.
  4. Execute the repolinter with a rule you know will fail/succeed, check if a Github issue is created on the above test repository.
  5. Close the newly created issue and execute repolinter again, it should re-open the old issue if the same rule was triggered.
  6. Apply the Bypass Label to an issue and verify that the repolinter will not create a new issue for the same rule.

In the near future, we plan to extend this feature by also assigning these issues to top committers of a repository. A common problem with these kinds of issues created by bots is that they are simply ignored or forgotten about. Assigning people might help with that as it notifies users.

The other "fix" types like creating a pull request or creating a notification via some webhook, is something that I would also love to add. Will create separate issues for this to track development and discuss it a bit more.

Worked on this feature together with my colleague @JeroenKnoops, Thanks!
Feedback is always appreciated.

Signed-off-by: Brend Smits brend.smits@philips.com

@hyandell
Copy link
Member

hyandell commented May 6, 2022

I'll admit - my immediate instinct is to want this as a separate component. I think that's probably because I'm not a user of the fixes feature and so that part of repolinter is not something I think about as much when I think of repolinter.

Stepping way from that instinct; and thinking within the current scope of the fixes, it feels like the objection would be that the GitHub interaction is a much larger scope than the current default actions. It also brings in the GitHub API as a dependency (I've not dug to see how large an inclusion that is).

I also wonder if it would encourage changes to the GitHub Action? https://github.com/todogroup/repolinter-action

[I apologize for wondering/questioning rather than having specific feedback, I have lots of catching up to do on repolinter]

@Brend-Smits Brend-Smits removed the request for review from trevmex March 27, 2023 08:09
@Brend-Smits
Copy link
Collaborator Author

I'll admit - my immediate instinct is to want this as a separate component. I think that's probably because I'm not a user of the fixes feature and so that part of repolinter is not something I think about as much when I think of repolinter.

Stepping way from that instinct; and thinking within the current scope of the fixes, it feels like the objection would be that the GitHub interaction is a much larger scope than the current default actions. It also brings in the GitHub API as a dependency (I've not dug to see how large an inclusion that is).

I also wonder if it would encourage changes to the GitHub Action? todogroup/repolinter-action

[I apologize for wondering/questioning rather than having specific feedback, I have lots of catching up to do on repolinter]

Fair points. Before spending more effort and pushing more code, let's discuss this feature request and pr feedback in our weekly call on how/if we want to move forward with this pull request.

Copy link

@XoL1507 XoL1507 left a comment

Choose a reason for hiding this comment

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

Please help me

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.

None yet

3 participants