Skip to content

Commit

Permalink
wip: try early exit
Browse files Browse the repository at this point in the history
Signed-off-by: Kenji Miyake <[email protected]>
  • Loading branch information
Kenji Miyake committed Apr 12, 2022
1 parent 6763b3e commit 67c0d96
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ module.exports = async function run() {
pull_number: contextPullRequest.number
});

// Ignore errors if specified labels are added.
if (ignoreLabels) {
const labelNames = pullRequest.labels.map((label) => label.name);
for (const labelName of labelNames) {
if (ignoreLabels.includes(labelName)) {
core.info(
`Validation was skipped because the PR label "${labelName}" was found.`
);
return;
}
}
}

// Pull requests that start with "[WIP] " are excluded from the check.
const isWip = wip && /^\[WIP\]\s/.test(pullRequest.title);

Expand Down Expand Up @@ -116,20 +129,6 @@ module.exports = async function run() {
}
}

// Ignore errors if specified labels are added.
if (ignoreLabels && validationError) {
const labelNames = pullRequest.labels.map((label) => label.name);
for (const labelName of labelNames) {
if (ignoreLabels.includes(labelName)) {
core.info(
`Validation was skipped because the PR label "${labelName}" was found.`
);
validationError = null;
break;
}
}
}

if (wip) {
const newStatus =
isWip || validationError != null ? 'pending' : 'success';
Expand Down

0 comments on commit 67c0d96

Please sign in to comment.