-
-
Notifications
You must be signed in to change notification settings - Fork 12
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 environment variables and adaptations for more dynamics deployments #19
Open
brightcohen
wants to merge
4
commits into
unicode-org:main
Choose a base branch
from
brightcohen:master
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6906f35
Add Support for on-premise GitHub deployments
brightcohen eec9014
Allow validated issue status to be set in configuration
brightcohen f3067de
Add env vars to enable/disable checks
brightcohen 4a93b7a
Merge branch 'master' into master
brightcohen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,17 @@ JIRA_URL=unicode-org.atlassian.net | |
[email protected] | ||
JIRA_PASSWORD=bar | ||
|
||
# List of issue statuses that would be accepted | ||
JIRA_STATUS_CHECK=TRUE | ||
JIRA_APPROVED_STATUSES="Approved, Progress" | ||
|
||
# Search for the Jira Issue ID in commit message | ||
SEARCH_JIRA_ISSUE_IN_COMMIT=TRUE | ||
|
||
# Optional variable to allow multiple commits in the same PR | ||
ALLOW_MANY_COMMITS=TRUE | ||
|
||
|
||
# URL prefix used for hyperlinks. | ||
URL_PREFIX=http://localhost:3000 | ||
|
||
|
@@ -64,6 +75,10 @@ [email protected] | |
# Secret for the cookie session, used to store the user's GitHub access token in a cookie. | ||
COOKIE_SECRET=xxxxxxxxxx | ||
|
||
|
||
# Hostname of your GitHub instance | ||
GITHUB_URL=https://github.mycompany.com/api/v3 | ||
|
||
# Optional list of repos to disable status updates (only enable force-push checking) | ||
DO_NOT_TOUCH_REPOS=org/repo1,org/repo2 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,11 +74,11 @@ async function getJiraInfo(pullRequest) { | |
const isMaintMerge = (pullRequest.base.ref === "master" | ||
&& pullRequest.head.ref.match(/^maint\//) | ||
&& pullRequest.base.repo.full_name == pullRequest.head.repo.full_name); | ||
let jiraApprovedStatuses = process.env.JIRA_APPROVED_STATUSES || "Accepted, Reviewing, Review Feedback" | ||
const jiraApprovedStatusesArray = jiraApprovedStatuses.split(",").map(status => status.trim()) | ||
|
||
// Check Jira ticket for validity | ||
if (jiraStatus !== "Accepted" && | ||
jiraStatus !== "Reviewing" && | ||
jiraStatus !== "Review Feedback") { | ||
if (!jiraApprovedStatuses.includes(jiraStatus) && process.env.JIRA_STATUS_CHECK === "TRUE") { | ||
return { | ||
issueKey, | ||
jiraStatus, | ||
|
@@ -93,35 +93,38 @@ async function getJiraInfo(pullRequest) { | |
} | ||
|
||
// Check for consistency with the commit messages | ||
for (const commitInfo of commits) { | ||
const commitIssueKey = parseMessage(commitInfo.commit.message); | ||
if (commitIssueKey === null) { | ||
return { | ||
issueKey, | ||
jiraStatus, | ||
numCommits, | ||
isMaintMerge, | ||
prFlags, | ||
pass: false, | ||
description: "Commit message for " + commitInfo.sha.substr(0, 7) + " fails validation", | ||
badCommit: commitInfo | ||
}; | ||
} else if (commitIssueKey !== issueKey && !prFlags["DISABLE_JIRA_ISSUE_MATCH"] && !isMaintMerge) { | ||
return { | ||
issueKey, | ||
jiraStatus, | ||
numCommits, | ||
isMaintMerge, | ||
prFlags, | ||
pass: false, | ||
description: "Commit " + commitInfo.sha.substr(0, 7) + " is for " + commitIssueKey + ", but the PR is for " + issueKey, | ||
extendedDescription: "Please fix your commit message to have the same ticket number as the pull request. If the inconsistency is intentional, you can disable this warning with DISABLE_JIRA_ISSUE_MATCH=true in the PR description.", | ||
badCommit: commitInfo | ||
}; | ||
if(process.env.SEARCH_JIRA_ISSUE_IN_COMMIT === "TRUE") { | ||
for (const commitInfo of commits) { | ||
const commitIssueKey = parseMessage(commitInfo.commit.message); | ||
if (commitIssueKey === null) { | ||
return { | ||
issueKey, | ||
jiraStatus, | ||
numCommits, | ||
isMaintMerge, | ||
prFlags, | ||
pass: false, | ||
description: "Commit message for " + commitInfo.sha.substr(0, 7) + " fails validation", | ||
badCommit: commitInfo | ||
}; | ||
} else if (commitIssueKey !== issueKey && !prFlags["DISABLE_JIRA_ISSUE_MATCH"] && !isMaintMerge) { | ||
return { | ||
issueKey, | ||
jiraStatus, | ||
numCommits, | ||
isMaintMerge, | ||
prFlags, | ||
pass: false, | ||
description: "Commit " + commitInfo.sha.substr(0, 7) + " is for " + commitIssueKey + ", but the PR is for " + issueKey, | ||
extendedDescription: "Please fix your commit message to have the same ticket number as the pull request. If the inconsistency is intentional, you can disable this warning with DISABLE_JIRA_ISSUE_MATCH=true in the PR description.", | ||
badCommit: commitInfo | ||
}; | ||
} | ||
} | ||
} | ||
|
||
// Since we can't easilly check more than 100 commits, reject PRs with more than 100 commits | ||
|
||
// Since we can't easily check more than 100 commits, reject PRs with more than 100 commits | ||
if (commits.length === 100) { | ||
return { | ||
issueKey, | ||
|
@@ -228,8 +231,12 @@ async function touch(pullRequest, jiraInfo) { | |
const multiCommitMessage = (jiraInfo.numCommits === 0) ? "No commits found on PR" : (jiraInfo.numCommits === 1) ? "This PR includes exactly 1 commit!" : "This PR has " + jiraInfo.numCommits + " commits" + (multiCommitPass ? "" : "; consider squashing:"); | ||
const promises = [ | ||
github.createStatus("jira-ticket", pullRequest, jiraInfo.pass, url, jiraInfo.description), | ||
github.createStatus("single-commit", pullRequest, multiCommitPass, url, multiCommitMessage) | ||
]; | ||
|
||
if (!(process.env.ALLOW_MANY_COMMITS === "TRUE")) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd rather if you named this |
||
promises.push(github.createStatus("single-commit", pullRequest, multiCommitPass, undefined, multiCommitMessage)) | ||
} | ||
|
||
if (jiraInfo.isMaintMerge) { | ||
promises.push(github.createStatus("maint-merge", pullRequest, false, undefined, "Reminder: use a MERGE COMMIT and new ticket in the message.")); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather this be opt-out rather than opt-in. There are deployments of this tool that might break if they upgrade the code but don't add the corresponding environment variable.
For example, name it
DISABLE_JIRA_ISSUE_CHECK
(similar toDISABLE_JIRA_ISSUE_MATCH
, but it disables all validation, not just ticket number matching)