From aabf2341b50f7ec28a6bd8a3a5053a4aab77290c Mon Sep 17 00:00:00 2001 From: psavidis <69160690+psavidis@users.noreply.github.com> Date: Fri, 13 Dec 2024 15:21:38 +0200 Subject: [PATCH] chore(common): Exclude optimize issues from set-version-labels (#31) Related-to: https://github.com/camunda/team-automation-platform/issues/189 --- common/dist/index.js | 26 ++++++++++++++++++++++++++ common/src/set-version-labels.js | 26 ++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/common/dist/index.js b/common/dist/index.js index e9b43f9..759636e 100644 --- a/common/dist/index.js +++ b/common/dist/index.js @@ -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); @@ -164023,6 +164029,21 @@ module.exports = async function () { return potentialLabels.length > 0 } + const isUnsupportedIssue = async (ticketMetadata) => { + // Insert here cases that should be excluded by the action + + if (await isIssueRelatedToOptimize(ticketMetadata)) { + console.log(`Issue is related to Optimize.`); + return true; + } + + return false; + } + + const isIssueRelatedToOptimize = async (ticketMetadata) => { + return await haScopeOptimizeLabel(ticketMetadata); + } + // setup const issueNumber = core.getInput('issue-number'); @@ -164036,6 +164057,11 @@ module.exports = async function () { issue_number: issueNumber }; + if (await isUnsupportedIssue(ticketMetadata)) { + console.log(`Issue ${issueNumber} is not supported. Exiting.`); + return; + } + const potentialLabels = await getPotentialLabels(ticketMetadata); // validate diff --git a/common/src/set-version-labels.js b/common/src/set-version-labels.js index ed6cdf8..f304355 100644 --- a/common/src/set-version-labels.js +++ b/common/src/set-version-labels.js @@ -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); @@ -251,6 +257,21 @@ module.exports = async function () { return potentialLabels.length > 0 } + const isUnsupportedIssue = async (ticketMetadata) => { + // Insert here cases that should be excluded by the action + + if (await isIssueRelatedToOptimize(ticketMetadata)) { + console.log(`Issue is related to Optimize.`); + return true; + } + + return false; + } + + const isIssueRelatedToOptimize = async (ticketMetadata) => { + return await haScopeOptimizeLabel(ticketMetadata); + } + // setup const issueNumber = core.getInput('issue-number'); @@ -264,6 +285,11 @@ module.exports = async function () { issue_number: issueNumber }; + if (await isUnsupportedIssue(ticketMetadata)) { + console.log(`Issue ${issueNumber} is not supported. Exiting.`); + return; + } + const potentialLabels = await getPotentialLabels(ticketMetadata); // validate