diff --git a/.github/guidelines/LABELING_GUIDELINES.md b/.github/guidelines/LABELING_GUIDELINES.md index dbdd3b2ed9b8..e718e3f1d38b 100644 --- a/.github/guidelines/LABELING_GUIDELINES.md +++ b/.github/guidelines/LABELING_GUIDELINES.md @@ -13,7 +13,7 @@ It's essential to ensure that PRs have the appropriate labels before they are co - **regression-prod-x.y.z**: This label is automatically added to a bug report issue at the time of its creation. The `x.y.z` in the label represents the version in which the bug first appeared. This label is auto-generated by a [GitHub action](../workflows/check-template-and-add-labels.yml), which determines the `x.y.z` value based on the version information provided in the bug report issue form. Manual intervention is only necessary under certain circumstances. For example, if a user submits a bug report and specifies the version they are currently using, but the bug was actually introduced in a prior version, the label would need to be manually updated to accurately reflect the version where the bug originated. ### Optional labels: -- **regression-develop**: This label can manually be added to a bug report issue at the time of its creation if the bug is present on development branch (i.e. `develop`), but is not yet released in production. +- **regression-develop**: This label can manually be added to a bug report issue at the time of its creation if the bug is present on the development branch, i.e., `develop`, but is not yet released in production. - **needs-qa**: If the PR includes a new features, complex testing steps, or large refactors, this label must be added to indicated PR requires a full manual QA prior being merged and added to a release. ### Labels prohibited when PR needs to be merged: diff --git a/.github/scripts/check-template-and-add-labels.ts b/.github/scripts/check-template-and-add-labels.ts index abcc53a3496b..7551ff607851 100644 --- a/.github/scripts/check-template-and-add-labels.ts +++ b/.github/scripts/check-template-and-add-labels.ts @@ -6,6 +6,7 @@ import { retrieveIssue } from './shared/issue'; import { Labelable, LabelableType, + findLabel, addLabelToLabelable, removeLabelFromLabelable, removeLabelFromLabelableIfPresent, @@ -13,6 +14,7 @@ import { import { Label, externalContributorLabel, + flakyTestsLabel, invalidIssueTemplateLabel, invalidPullRequestTemplateLabel, } from './shared/label'; @@ -90,6 +92,19 @@ async function main(): Promise { } if (labelable.type === LabelableType.Issue) { + + // If labelable is a flaky test report, no template is needed (we just add a link to circle.ci in the description), we skip the template checks + const flakyTestsLabelFound = findLabel(labelable, flakyTestsLabel); + if (flakyTestsLabelFound?.id) { + console.log(`Issue ${labelable?.number} was created to report a flaky test. Issue's description doesn't need to match issue template in that case as the issue's description only includes a link redirecting to circle.ci. Skip template checks.`); + await removeLabelFromLabelableIfPresent( + octokit, + labelable, + invalidIssueTemplateLabel, + ); + process.exit(0); // Stop the process and exit with a success status code + } + if (templateType === TemplateType.GeneralIssue) { console.log("Issue matches 'general-issue.yml' template."); await removeLabelFromLabelableIfPresent( diff --git a/.github/scripts/shared/label.ts b/.github/scripts/shared/label.ts index 32097fda66ee..2a0632a263de 100644 --- a/.github/scripts/shared/label.ts +++ b/.github/scripts/shared/label.ts @@ -14,6 +14,12 @@ export const externalContributorLabel: Label = { description: 'Issue or PR created by user outside org', }; +export const flakyTestsLabel: Label = { + name: 'flaky tests', + color: 'BE564E', + description: 'Flaky test report', +}; + export const invalidIssueTemplateLabel: Label = { name: 'INVALID-ISSUE-TEMPLATE', color: 'EDEDED', diff --git a/.github/scripts/shared/labelable.ts b/.github/scripts/shared/labelable.ts index 56a8675190c0..9726297ea714 100644 --- a/.github/scripts/shared/labelable.ts +++ b/.github/scripts/shared/labelable.ts @@ -23,6 +23,20 @@ export interface Labelable { }[]; } +// This function tries to find a label on a labelable object (i.e. a pull request or an issue) if present +export function findLabel( + labelable: Labelable, + labelToFind: Label, +): { + id: string; + name: string; +} | undefined { + // Check if label is present on labelable + return labelable.labels.find( + (label) => label.name === labelToFind.name, + ); +} + // This function adds label to a labelable object (i.e. a pull request or an issue) export async function addLabelToLabelable( octokit: InstanceType, @@ -77,10 +91,8 @@ export async function removeLabelFromLabelableIfPresent( labelable: Labelable, labelToRemove: Label, ): Promise { - // Check if label is present on issue - const labelFound = labelable?.labels?.find( - (label) => label.name === labelToRemove?.name, - ); + // Check if label is present on labelable + const labelFound = findLabel(labelable, labelToRemove); if (labelFound?.id) { // Remove label from labelable