repolinter
repolinter copied to clipboard
Add option to create GitHub issue on rule violation
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
- Input a PAT via environment variable using export GITHUB_TOKEN=TOKENHERE
- Input a target repository via environment variable using export TARGET_REPO=brend-smits/octo-test-repo
- 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.
- Execute the repolinter with a rule you know will fail/succeed, check if a Github issue is created on the above test repository.
- Close the newly created issue and execute repolinter again, it should re-open the old issue if the same rule was triggered.
- 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 [email protected]
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]