Skip to content

fix(ci): fixes typos and small issues on github scripts #1302

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/scripts/label_pr_based_on_title.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
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 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,
Expand All @@ -22,8 +22,8 @@ module.exports = async ({github, context, core}) => {
try {
for (const label in labels) {
const matcher = new RegExp(labels[label])
const isMatch = matcher.exec(PR_TITLE)
if (isMatch != null) {
const matches = matcher.exec(PR_TITLE)
if (matches != null) {
core.info(`Auto-labeling PR ${PR_NUMBER} with ${label}`)

await github.rest.issues.addLabels({
Expand Down Expand Up @@ -54,7 +54,7 @@ module.exports = async ({github, context, core}) => {
}
} finally {
if (miss == Object.keys(labels).length) {
return core.notice(`PR ${PR_NUMBER} title '${PR_TITLE}' doesn't follow semantic titles; skipping...`)
Copy link
Contributor

Choose a reason for hiding this comment

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

for my own benefit, why not a return?

core.notice(`PR ${PR_NUMBER} title '${PR_TITLE}' doesn't follow semantic titles; skipping...`)
}
}
}
12 changes: 9 additions & 3 deletions .github/scripts/label_related_issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ module.exports = async ({github, context, core}) => {

const RELATED_ISSUE_REGEX = /Issue number:[^\d\r\n]+(?<issue>\d+)/;

const isMatch = RELATED_ISSUE_REGEX.exec(PR_BODY);

try {
const isMatch = RELATED_ISSUE_REGEX.exec(PR_BODY);
if (!isMatch) {
core.setFailed(`Unable to find related issue for PR number ${PR_NUMBER}.\n\n Body details: ${PR_BODY}`);
return await github.rest.issues.createComment({
Expand All @@ -30,11 +31,16 @@ module.exports = async ({github, context, core}) => {
issue_number: PR_NUMBER,
});
}
} catch (error) {
core.setFailed(`Unable to create comment on PR number ${PR_NUMBER}.\n\n Error details: ${error}`);
throw new Error(error);
}
Comment on lines +34 to +37
Copy link
Contributor

Choose a reason for hiding this comment

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

YES!!! thank you


const { groups: {issue} } = isMatch
const { groups: {issue} } = isMatch

try {
core.info(`Auto-labeling related issue ${issue} for release`)
return await github.rest.issues.addLabels({
Copy link
Contributor

Choose a reason for hiding this comment

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

for my own benefit, why not a return?

await github.rest.issues.addLabels({
issue_number: issue,
owner: context.repo.owner,
repo: context.repo.repo,
Expand Down
4 changes: 2 additions & 2 deletions .github/scripts/save_pr_details.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = async ({github, context, core}) => {
module.exports = async ({context, core}) => {
const fs = require('fs');
const filename = "pr.txt";

Expand All @@ -10,4 +10,4 @@ module.exports = async ({github, context, core}) => {
core.setFailed("Failed to save PR details");
console.error(err);
}
}
}