Skip to content

Commit

Permalink
chore(common): Exclude optimize issues from set-version-labels
Browse files Browse the repository at this point in the history
  • Loading branch information
psavidis committed Dec 13, 2024
1 parent c37521a commit 3b20a5e
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
26 changes: 26 additions & 0 deletions common/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -164001,6 +164001,12 @@ module.exports = async function () {
return (validVersionLabels.length !== 0);
}

const haScopeOptimizeLabel = async (ticketMetadata) => {
const scopeOptimizeLabel = await getLabelsMatchingRegexp(ticketMetadata, `scope:optimize`);

return (scopeOptimizeLabel.length !== 0);
}

const removePotentialAndSetVersionLabels = async (nonNullVersionLabelsEntries) => {
const potentialLabelsToRemove = nonNullVersionLabelsEntries.map(([potentialLabel, _]) => potentialLabel);
const versionLabelsToAssign = nonNullVersionLabelsEntries.map(([_, versionLabel]) => versionLabel);
Expand All @@ -164023,6 +164029,21 @@ module.exports = async function () {
return potentialLabels.length > 0
}

const isUnsupportedIssue = (ticketMetadata) => {
// Insert here cases that should be excluded by the action

if (isIssueRelatedToOptimize(ticketMetadata)) {
console.log(`Issue is related to Optimize.`);
return true;
}

return false;
}

const isIssueRelatedToOptimize = async (ticketMetadata) => {
return haScopeOptimizeLabel(ticketMetadata);
}

// setup

const issueNumber = core.getInput('issue-number');
Expand All @@ -164036,6 +164057,11 @@ module.exports = async function () {
issue_number: issueNumber
};

if (isUnsupportedIssue(ticketMetadata)) {
console.log(`Issue ${issueNumber} is not supported. Exiting.`);
return;
}

const potentialLabels = await getPotentialLabels(ticketMetadata);

// validate
Expand Down
26 changes: 26 additions & 0 deletions common/src/set-version-labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,12 @@ module.exports = async function () {
return (validVersionLabels.length !== 0);
}

const haScopeOptimizeLabel = async (ticketMetadata) => {
const scopeOptimizeLabel = await getLabelsMatchingRegexp(ticketMetadata, `scope:optimize`);

return (scopeOptimizeLabel.length !== 0);
}

const removePotentialAndSetVersionLabels = async (nonNullVersionLabelsEntries) => {
const potentialLabelsToRemove = nonNullVersionLabelsEntries.map(([potentialLabel, _]) => potentialLabel);
const versionLabelsToAssign = nonNullVersionLabelsEntries.map(([_, versionLabel]) => versionLabel);
Expand All @@ -251,6 +257,21 @@ module.exports = async function () {
return potentialLabels.length > 0
}

const isUnsupportedIssue = (ticketMetadata) => {
// Insert here cases that should be excluded by the action

if (isIssueRelatedToOptimize(ticketMetadata)) {
console.log(`Issue is related to Optimize.`);
return true;
}

return false;
}

const isIssueRelatedToOptimize = async (ticketMetadata) => {
return haScopeOptimizeLabel(ticketMetadata);
}

// setup

const issueNumber = core.getInput('issue-number');
Expand All @@ -264,6 +285,11 @@ module.exports = async function () {
issue_number: issueNumber
};

if (isUnsupportedIssue(ticketMetadata)) {
console.log(`Issue ${issueNumber} is not supported. Exiting.`);
return;
}

const potentialLabels = await getPotentialLabels(ticketMetadata);

// validate
Expand Down

0 comments on commit 3b20a5e

Please sign in to comment.