-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into BCI-3730-remove-minconfirmations-evm-txm
- Loading branch information
Showing
29 changed files
with
518 additions
and
282 deletions.
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"chainlink": patch | ||
--- | ||
|
||
#added Add Astar TerminallyUnderpriced error mapping |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"chainlink": minor | ||
--- | ||
|
||
#bugfix Addresses 2 minor issues with the pruning of LogPoller's db tables: logs not matching any filter will now be pruned, and rows deleted are now properly reported for observability |
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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import * as core from "@actions/core"; | ||
import jira from "jira.js"; | ||
import { createJiraClient, parseIssueNumberFrom } from "./lib"; | ||
|
||
async function doesIssueExist( | ||
client: jira.Version3Client, | ||
issueNumber: string, | ||
dryRun: boolean | ||
) { | ||
const payload = { | ||
issueIdOrKey: issueNumber, | ||
}; | ||
|
||
if (dryRun) { | ||
core.info("Dry run enabled, skipping JIRA issue enforcement"); | ||
return true; | ||
} | ||
|
||
try { | ||
/** | ||
* The issue is identified by its ID or key, however, if the identifier doesn't match an issue, a case-insensitive search and check for moved issues is performed. | ||
* If a matching issue is found its details are returned, a 302 or other redirect is not returned. The issue key returned in the response is the key of the issue found. | ||
*/ | ||
const issue = await client.issues.getIssue(payload); | ||
core.debug( | ||
`JIRA issue id:${issue.id} key: ${issue.key} found while querying for ${issueNumber}` | ||
); | ||
if (issue.key !== issueNumber) { | ||
core.error( | ||
`JIRA issue key ${issueNumber} not found, but found issue key ${issue.key} instead. This can happen if the identifier doesn't match an issue, in which case a case-insensitive search and check for moved issues is performed. Make sure the issue key is correct.` | ||
); | ||
return false; | ||
} | ||
|
||
return true; | ||
} catch (e) { | ||
core.debug(e as any); | ||
return false; | ||
} | ||
} | ||
|
||
async function main() { | ||
const prTitle = process.env.PR_TITLE; | ||
const commitMessage = process.env.COMMIT_MESSAGE; | ||
const branchName = process.env.BRANCH_NAME; | ||
const dryRun = !!process.env.DRY_RUN; | ||
const client = createJiraClient(); | ||
|
||
// Checks for the Jira issue number and exit if it can't find it | ||
const issueNumber = parseIssueNumberFrom(prTitle, commitMessage, branchName); | ||
if (!issueNumber) { | ||
const msg = | ||
"No JIRA issue number found in PR title, commit message, or branch name. This pull request must be associated with a JIRA issue."; | ||
|
||
core.setFailed(msg); | ||
return; | ||
} | ||
|
||
const exists = await doesIssueExist(client, issueNumber, dryRun); | ||
if (!exists) { | ||
core.setFailed(`JIRA issue ${issueNumber} not found, this pull request must be associated with a JIRA issue.`); | ||
return; | ||
} | ||
} | ||
|
||
async function run() { | ||
try { | ||
await main(); | ||
} catch (error) { | ||
if (error instanceof Error) { | ||
return core.setFailed(error.message); | ||
} | ||
core.setFailed(error as any); | ||
} | ||
} | ||
|
||
run(); |
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
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
|
||
import * as core from '@actions/core' | ||
import * as jira from 'jira.js' | ||
|
||
/** | ||
* Given a list of strings, this function will return the first JIRA issue number it finds. | ||
* | ||
* @example parseIssueNumberFrom("CORE-123", "CORE-456", "CORE-789") => "CORE-123" | ||
* @example parseIssueNumberFrom("2f3df5gf", "chore/test-RE-78-branch", "RE-78 Create new test branches") => "RE-78" | ||
*/ | ||
export function parseIssueNumberFrom( | ||
...inputs: (string | undefined)[] | ||
): string | undefined { | ||
function parse(str?: string) { | ||
const jiraIssueRegex = /[A-Z]{2,}-\d+/; | ||
|
||
return str?.toUpperCase().match(jiraIssueRegex)?.[0]; | ||
} | ||
|
||
core.debug(`Parsing issue number from: ${inputs.join(", ")}`); | ||
const parsed: string[] = inputs.map(parse).filter((x) => x !== undefined); | ||
core.debug(`Found issue number: ${parsed[0]}`); | ||
|
||
return parsed[0]; | ||
} | ||
|
||
/** | ||
* Converts an array of tags to an array of labels. | ||
* | ||
* A label is a string that is formatted as `core-release/{tag}`, with the leading `v` removed from the tag. | ||
* | ||
* @example tagsToLabels(["v1.0.0", "v1.1.0"]) => [{ add: "core-release/1.0.0" }, { add: "core-release/1.1.0" }] | ||
*/ | ||
export function tagsToLabels(tags: string[]) { | ||
const labelPrefix = "core-release"; | ||
|
||
return tags.map((t) => ({ | ||
add: `${labelPrefix}/${t.substring(1)}`, | ||
})); | ||
} | ||
|
||
export function createJiraClient() { | ||
const jiraHost = process.env.JIRA_HOST; | ||
const jiraUserName = process.env.JIRA_USERNAME; | ||
const jiraApiToken = process.env.JIRA_API_TOKEN; | ||
|
||
if (!jiraHost || !jiraUserName || !jiraApiToken) { | ||
core.setFailed( | ||
"Error: Missing required environment variables: JIRA_HOST and JIRA_USERNAME and JIRA_API_TOKEN." | ||
); | ||
process.exit(1); | ||
} | ||
|
||
return new jira.Version3Client({ | ||
host: jiraHost, | ||
authentication: { | ||
basic: { | ||
email: jiraUserName, | ||
apiToken: jiraApiToken, | ||
}, | ||
}, | ||
}); | ||
} |
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
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
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
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
Oops, something went wrong.