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 with 'fixers' #1

Merged
merged 26 commits into from
Jun 29, 2021

Conversation

Brend-Smits
Copy link
Member

@Brend-Smits Brend-Smits commented Mar 18, 2021

Description

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, some should even create a PR.
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: 'Continuous Compliance', 'automated', 'CC: Bypass'
  • Add an ability to bypass future CC 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)

To-do

  • The Personal Access Token(PAT) is currently hardcoded in the file, retrieve it from environment variables.
  • Write tests to verify functionality.
  • Allow dynamically setting of target repository where the issue will be created (https://github.com/philips-labs/repolinter/blob/feature/github-issue-fix/fixes/github-issue-create.js#L23-L24) Help is appreciated here 😁
    I've temporarily resolved this by allowing you to set a TARGET_REPO environment variable. This is not ideal, but I was unable to retrieve the Git URL from somewhere else.
  • Return proper exit codes, when a fix is applied the application did not fail.

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 ruleset.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. (Why on the test repository? Please refer to the above To-do section.
  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.

Feedback is much appreciated, I'm not very proficient with Javascript and honestly not amused with the lack of types, classes, and interfaces 🙄

@Brend-Smits Brend-Smits changed the title Add option to create Github issue with 'fixers' WIP - Add option to create Github issue with 'fixers' Mar 18, 2021
Setting it via environment variable is slightly counter intuitive, but I was unable to retrieve the target repository in any other way for now.
TARGET_REPO example: Brend-Smits/octokit-test-repo or philips-labs/repolinter
issueCreator is now set according to the PAT that is used.
issueCreator is now set according to the PAT that is used.
Copy link
Member

@JeroenKnoops JeroenKnoops left a comment

Choose a reason for hiding this comment

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

LGTM

@Brend-Smits Brend-Smits changed the title WIP - Add option to create Github issue with 'fixers' Add option to create Github issue with 'fixers' Jun 28, 2021
@Brend-Smits Brend-Smits added the enhancement New feature or request label Jun 28, 2021
Copy link
Member

@JeroenKnoops JeroenKnoops left a comment

Choose a reason for hiding this comment

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

LGTM

@Brend-Smits Brend-Smits merged commit 8418912 into master Jun 29, 2021
@Brend-Smits Brend-Smits deleted the feature/github-issue-fix branch June 29, 2021 10:38
@Brend-Smits Brend-Smits restored the feature/github-issue-fix branch June 29, 2021 10:38
@Brend-Smits Brend-Smits deleted the feature/github-issue-fix branch April 11, 2022 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants