-
Notifications
You must be signed in to change notification settings - Fork 25
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
chore(ci): updated github actions and templates #123
Conversation
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.
two suggestions (leftover plus two labels you missed). I'll double check the latest fixes we've made in the labeling workflows and bring a new security hardening workflow over
Co-authored-by: Heitor Lessa <heitor.lessa@hotmail.com>
Co-authored-by: Heitor Lessa <heitor.lessa@hotmail.com>
const { PR_NUMBER, PR_TITLE, AREAS } = require("./constants") | ||
|
||
module.exports = async ({github, context, core}) => { | ||
const FEAT_REGEX = /feat(\((.+)\))?(\:.+)/ | ||
const BUG_REGEX = /(fix|bug)(\((.+)\))?(\:.+)/ | ||
const DOCS_REGEX = /(docs|doc)(\((.+)\))?(\:.+)/ | ||
const CHORE_REGEX = /(chore)(\((.+)\))?(\:.+)/ | ||
const DEPRECATED_REGEX = /(deprecated)(\((.+)\))?(\:.+)/ | ||
const REFACTOR_REGEX = /(refactor)(\((.+)\))?(\:.+)/ | ||
|
||
const labels = { | ||
"feature": FEAT_REGEX, | ||
"bug": BUG_REGEX, | ||
"documentation": DOCS_REGEX, | ||
"internal": CHORE_REGEX, | ||
"enhancement": REFACTOR_REGEX, | ||
"deprecated": DEPRECATED_REGEX, | ||
} | ||
|
||
// Maintenance: We should keep track of modified PRs in case their titles change | ||
let miss = 0; | ||
try { | ||
for (const label in labels) { | ||
const matcher = new RegExp(labels[label]) | ||
const isMatch = matcher.exec(PR_TITLE) | ||
if (isMatch != null) { | ||
core.info(`Auto-labeling PR ${PR_NUMBER} with ${label}`) | ||
|
||
await github.rest.issues.addLabels({ | ||
issue_number: PR_NUMBER, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
labels: [label] | ||
}) | ||
|
||
const area = matches[2]; // second capture group contains the area | ||
if (AREAS.indexOf(area) > -1) { | ||
core.info(`Auto-labeling PR ${PR_NUMBER} with area ${area}`); | ||
await github.rest.issues.addLabels({ | ||
issue_number: PR_NUMBER, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
labels: [`area/${area}`], | ||
}); | ||
} else { | ||
core.debug(`'${PR_TITLE}' didn't match any known area.`); | ||
} | ||
|
||
return; | ||
} else { | ||
core.debug(`'${PR_TITLE}' didn't match '${label}' semantic.`) | ||
miss += 1 | ||
} | ||
} | ||
} finally { | ||
if (miss == Object.keys(labels).length) { | ||
return core.notice(`PR ${PR_NUMBER} title '${PR_TITLE}' doesn't follow semantic titles; skipping...`) | ||
} | ||
} | ||
} |
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.
const { PR_NUMBER, PR_TITLE, AREAS } = require("./constants") | |
module.exports = async ({github, context, core}) => { | |
const FEAT_REGEX = /feat(\((.+)\))?(\:.+)/ | |
const BUG_REGEX = /(fix|bug)(\((.+)\))?(\:.+)/ | |
const DOCS_REGEX = /(docs|doc)(\((.+)\))?(\:.+)/ | |
const CHORE_REGEX = /(chore)(\((.+)\))?(\:.+)/ | |
const DEPRECATED_REGEX = /(deprecated)(\((.+)\))?(\:.+)/ | |
const REFACTOR_REGEX = /(refactor)(\((.+)\))?(\:.+)/ | |
const labels = { | |
"feature": FEAT_REGEX, | |
"bug": BUG_REGEX, | |
"documentation": DOCS_REGEX, | |
"internal": CHORE_REGEX, | |
"enhancement": REFACTOR_REGEX, | |
"deprecated": DEPRECATED_REGEX, | |
} | |
// Maintenance: We should keep track of modified PRs in case their titles change | |
let miss = 0; | |
try { | |
for (const label in labels) { | |
const matcher = new RegExp(labels[label]) | |
const isMatch = matcher.exec(PR_TITLE) | |
if (isMatch != null) { | |
core.info(`Auto-labeling PR ${PR_NUMBER} with ${label}`) | |
await github.rest.issues.addLabels({ | |
issue_number: PR_NUMBER, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
labels: [label] | |
}) | |
const area = matches[2]; // second capture group contains the area | |
if (AREAS.indexOf(area) > -1) { | |
core.info(`Auto-labeling PR ${PR_NUMBER} with area ${area}`); | |
await github.rest.issues.addLabels({ | |
issue_number: PR_NUMBER, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
labels: [`area/${area}`], | |
}); | |
} else { | |
core.debug(`'${PR_TITLE}' didn't match any known area.`); | |
} | |
return; | |
} else { | |
core.debug(`'${PR_TITLE}' didn't match '${label}' semantic.`) | |
miss += 1 | |
} | |
} | |
} finally { | |
if (miss == Object.keys(labels).length) { | |
return core.notice(`PR ${PR_NUMBER} title '${PR_TITLE}' doesn't follow semantic titles; skipping...`) | |
} | |
} | |
} | |
const { PR_NUMBER, PR_TITLE, AREAS } = require("./constants") | |
module.exports = async ({github, context, core}) => { | |
const FEAT_REGEX = /feat(\((.+)\))?(:.+)/ | |
const BUG_REGEX = /(fix|bug)(\((.+)\))?(:.+)/ | |
const DOCS_REGEX = /(docs|doc)(\((.+)\))?(:.+)/ | |
const CHORE_REGEX = /(chore)(\((.+)\))?(:.+)/ | |
const DEPRECATED_REGEX = /(deprecated)(\((.+)\))?(:.+)/ | |
const REFACTOR_REGEX = /(refactor)(\((.+)\))?(:.+)/ | |
const labels = { | |
"feature": FEAT_REGEX, | |
"bug": BUG_REGEX, | |
"documentation": DOCS_REGEX, | |
"internal": CHORE_REGEX, | |
"enhancement": REFACTOR_REGEX, | |
"deprecated": DEPRECATED_REGEX, | |
} | |
// Maintenance: We should keep track of modified PRs in case their titles change | |
let miss = 0; | |
try { | |
for (const label in labels) { | |
const matcher = new RegExp(labels[label]) | |
const matches = matcher.exec(PR_TITLE) | |
if (matches != null) { | |
core.info(`Auto-labeling PR ${PR_NUMBER} with ${label}`) | |
await github.rest.issues.addLabels({ | |
issue_number: PR_NUMBER, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
labels: [label] | |
}) | |
const area = matches[2]; // second capture group contains the area | |
if (AREAS.indexOf(area) > -1) { | |
core.info(`Auto-labeling PR ${PR_NUMBER} with area ${area}`); | |
await github.rest.issues.addLabels({ | |
issue_number: PR_NUMBER, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
labels: [`area/${area}`], | |
}); | |
} else { | |
core.debug(`'${PR_TITLE}' didn't match any known area.`); | |
} | |
return; | |
} else { | |
core.debug(`'${PR_TITLE}' didn't match '${label}' semantic.`) | |
miss += 1 | |
} | |
} | |
} finally { | |
if (miss == Object.keys(labels).length) { | |
core.notice(`PR ${PR_NUMBER} title '${PR_TITLE}' doesn't follow semantic titles; skipping...`) | |
} | |
} | |
} |
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.
sync label JS file w/ Python. There are a few files missing, so I'll try to include them here in the PR, otherwise you can
Signed-off-by: heitorlessa <lessa@amazon.co.uk>
Signed-off-by: heitorlessa <lessa@amazon.co.uk>
Signed-off-by: heitorlessa <lessa@amazon.co.uk>
Signed-off-by: heitorlessa <lessa@amazon.co.uk>
UPDATE: Added all remaining workflows and scripts to be in sync with Python repo - let me know if there's anything else you need. |
Thanks @heitorlessa ! |
Issue #, if available:
Description of changes:
Updated GitHub actions and template. Cleaned up unused actions. Added apps to assists with automation.
Checklist
Breaking change checklist
RFC issue #:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
View rendered SECURITY.md