Skip to content
Merged
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
37 changes: 25 additions & 12 deletions scripts/dangerfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ const { labels } = danger.github.issue;
const prLogConfig = pkg['pr-log'];

const branchVersion = Versions.MINOR;
const targetBranch = danger.github.pr.base.ref;
const isReleasePr = ['latest-release', 'next-release'].includes(targetBranch);

/** @param {string[]} labels */
const checkRequiredLabels = (labels) => {
Expand All @@ -66,18 +68,29 @@ const checkRequiredLabels = (labels) => {
);
}

const foundRequiredLabels = intersection(requiredLabels, labels);
if (foundRequiredLabels.length === 0) {
fail(`PR is not labeled with one of: ${JSON.stringify(requiredLabels)}`);
} else if (foundRequiredLabels.length > 1) {
fail(`Please choose only one of these labels: ${JSON.stringify(foundRequiredLabels)}`);
}

const foundCILabels = intersection(ciLabels, labels);
if (foundCILabels.length === 0) {
fail(`PR is not labeled with one of: ${JSON.stringify(ciLabels)}`);
} else if (foundCILabels.length > 1) {
fail(`Please choose only one of these labels: ${JSON.stringify(foundCILabels)}`);
if (isReleasePr) {
// Release PRs only need `ci:daily`.
if (!labels.includes('ci:daily')) {
fail(
'Release PRs targeting latest-release or next-release must include the "ci:daily" label.'
);
}
return;
} else {
// All other PRs to `next` to a qualifying change type and one of several applicable CI labels.
const foundRequiredLabels = intersection(requiredLabels, labels);
if (foundRequiredLabels.length === 0) {
fail(`PR is not labeled with one of: ${JSON.stringify(requiredLabels)}`);
} else if (foundRequiredLabels.length > 1) {
fail(`Please choose only one of these labels: ${JSON.stringify(foundRequiredLabels)}`);
}

const foundCILabels = intersection(ciLabels, labels);
if (foundCILabels.length === 0) {
fail(`PR is not labeled with one of: ${JSON.stringify(ciLabels)}`);
} else if (foundCILabels.length > 1) {
fail(`Please choose only one of these labels: ${JSON.stringify(foundCILabels)}`);
}
}
};

Expand Down
Loading