From 29ed26a3ae9cb2c50a1f6438ce3ad5d9e2cca6ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o?= Date: Mon, 5 May 2025 12:18:44 +0100 Subject: [PATCH 1/6] feat(INFRA-2510): add team and regression labels --- .github/workflows/post-gh-rca.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/post-gh-rca.yml b/.github/workflows/post-gh-rca.yml index 96283513..bd321b00 100644 --- a/.github/workflows/post-gh-rca.yml +++ b/.github/workflows/post-gh-rca.yml @@ -57,14 +57,22 @@ jobs: issue_number: issue_number, }); - const hasAllowedLabel = issue.labels.some(label => - allowedLabels.includes(label.name) - ); + const prefixes = ['team-', 'regression-']; + + const wildcardLabels = issue.labels + .map(({ name }) => name) + .filter(name => prefixes.some(pref => name.startsWith(pref))); + + // checks if it has a label that matches exactly OR has any wildcard labels + const hasAllowedLabel = issue.labels + .some(({ name }) => allowedLabels.includes(name)) || wildcardLabels.length > 0; if (!hasAllowedLabel) { console.log(`❌ Issue #${issue_number} skipped — no matching label.`); return; } + + // TODO add wildcard labels to the form url const assignees = issue.assignees.map(user => `@${user.login}`).join(', '); const formUrl = `${googleFormBaseUrl}${issue_number}`; From 1a8e58d3a28f21f1037281734057c622fc3340fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o?= Date: Mon, 5 May 2025 17:01:10 +0100 Subject: [PATCH 2/6] feat(INFRA-2510): make it able to pass tem and regression on the URLs --- .github/workflows/post-gh-rca.yml | 103 +++++++++++++++++++----------- 1 file changed, 67 insertions(+), 36 deletions(-) diff --git a/.github/workflows/post-gh-rca.yml b/.github/workflows/post-gh-rca.yml index bd321b00..051fb9f5 100644 --- a/.github/workflows/post-gh-rca.yml +++ b/.github/workflows/post-gh-rca.yml @@ -23,31 +23,56 @@ on: description: The number of the closed issue required: true type: string - issue-labels: + labels: + description: JSON-stringified array of labels that should trigger the RCA prompt required: true - type: string # JSON stringified array + type: string + entry-issue: + description: The entry ID for the issue field in the Google Form + required: true + type: string + default: entry.340898780 + entry-regression: + description: The entry ID for the regression field in the Google Form + required: true + type: string + default: entry.1698032149 + entry-team: + description: The entry ID for the team field in the Google Form + required: true + type: string + default: entry.1228565618 jobs: post-rca-form: + name: Post Google Form link and log results on issue close runs-on: ubuntu-latest - steps: - - name: Post Google Form link and log results on issue close + - name: Post RCA Form Link uses: actions/github-script@v7 env: GOOGLE_FORM_BASE_URL: ${{ inputs.google-form-base-url }} - ISSUE_LABELS: ${{ inputs.issue-labels }} - OWNER_NAME: ${{ inputs.repo-owner }} - REPO_NAME: ${{ inputs.repo-name }} - ISSUE_NUMBER: ${{ inputs.issue-number }} + ISSUE_LABELS: ${{ inputs.labels }} + OWNER_NAME: ${{ inputs.repo-owner }} + REPO_NAME: ${{ inputs.repo-name }} + ISSUE_NUMBER: ${{ inputs.issue-number }} + ENTRY_ISSUE: ${{ inputs.entry-issue }} + ENTRY_REGRESSION: ${{ inputs.entry-regression }} + ENTRY_TEAM: ${{ inputs.entry-team }} with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - const googleFormBaseUrl = process.env.GOOGLE_FORM_BASE_URL; - const owner_name = process.env.OWNER_NAME; - const repo_name = process.env.REPO_NAME; - const issue_number = parseInt(process.env.ISSUE_NUMBER); + const { + GOOGLE_FORM_BASE_URL: baseUrl, + ENTRY_ISSUE, + ENTRY_REGRESSION, + ENTRY_TEAM, + OWNER_NAME: owner, + REPO_NAME: repo, + ISSUE_NUMBER: issueNumStr, + } = process.env; + const issue_number = parseInt(issueNumStr, 10); const allowedLabels = JSON.parse(process.env.ISSUE_LABELS); // Fetch issue details to get the assignees @@ -57,39 +82,45 @@ jobs: issue_number: issue_number, }); - const prefixes = ['team-', 'regression-']; - - const wildcardLabels = issue.labels - .map(({ name }) => name) - .filter(name => prefixes.some(pref => name.startsWith(pref))); - - // checks if it has a label that matches exactly OR has any wildcard labels - const hasAllowedLabel = issue.labels - .some(({ name }) => allowedLabels.includes(name)) || wildcardLabels.length > 0; + const hasAllowedLabel = issue.labels.some(label => + allowedLabels.includes(label.name) + ); if (!hasAllowedLabel) { console.log(`❌ Issue #${issue_number} skipped — no matching label.`); return; } - - // TODO add wildcard labels to the form url - const assignees = issue.assignees.map(user => `@${user.login}`).join(', '); - const formUrl = `${googleFormBaseUrl}${issue_number}`; - const message = ` - Hi ${assignees}, + // if it's a sev1-high or sev0-high, lets grab team and regression labels, if there's any + // if there's none, an empty value will be sent, which is what we want + const teamLabels = issue.labels + .map(l => l.name) + .filter(n => n.startsWith('team-')); + + const regressionLabels = issue.labels + .map(l => l.name) + .filter(n => n.startsWith('regression-')); + + const formUrl = new URL(baseUrl); + formUrl.searchParams.set(ENTRY_ISSUE, issue_number); + formUrl.searchParams.set( + ENTRY_REGRESSION, + regressionLabels.length ? regressionLabels.join(',') : '' + ); + formUrl.searchParams.set( + ENTRY_TEAM, + teamLabels.length ? teamLabels.join(',') : '' + ); + + const assignees = issue.assignees.map(u=>`@${u.login}`).join(', '); + const body = `Hi ${assignees}, - This issue has been closed. Please complete this RCA form: - ${formUrl} + This issue has been closed. Please complete this RCA form: + ${formUrl.toString()} - - `; + `; - // Post the comment on the closed issue await github.rest.issues.createComment({ - owner: owner_name, - repo: repo_name, - issue_number: issue_number, - body: message, + owner, repo, issue_number, body }); console.log(`✅ Comment posted on issue #${issue_number}`); From 20ef1398a41b5a776bfccf629b93d060d72830ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o?= Date: Tue, 6 May 2025 10:47:15 +0100 Subject: [PATCH 3/6] feat(INFRA-2510): fix --- .github/workflows/post-gh-rca.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/post-gh-rca.yml b/.github/workflows/post-gh-rca.yml index 051fb9f5..8fa11d82 100644 --- a/.github/workflows/post-gh-rca.yml +++ b/.github/workflows/post-gh-rca.yml @@ -23,23 +23,23 @@ on: description: The number of the closed issue required: true type: string - labels: + issue-labels: description: JSON-stringified array of labels that should trigger the RCA prompt required: true type: string entry-issue: description: The entry ID for the issue field in the Google Form - required: true + required: false type: string default: entry.340898780 entry-regression: description: The entry ID for the regression field in the Google Form - required: true + required: false type: string default: entry.1698032149 entry-team: description: The entry ID for the team field in the Google Form - required: true + required: false type: string default: entry.1228565618 @@ -52,7 +52,7 @@ jobs: uses: actions/github-script@v7 env: GOOGLE_FORM_BASE_URL: ${{ inputs.google-form-base-url }} - ISSUE_LABELS: ${{ inputs.labels }} + ISSUE_LABELS: ${{ inputs.issue-labels }} OWNER_NAME: ${{ inputs.repo-owner }} REPO_NAME: ${{ inputs.repo-name }} ISSUE_NUMBER: ${{ inputs.issue-number }} @@ -77,8 +77,8 @@ jobs: // Fetch issue details to get the assignees const { data: issue } = await github.rest.issues.get({ - owner: owner_name, - repo: repo_name, + owner, + repo, issue_number: issue_number, }); From f3bd36fbcfa8a70d26fb3ddca28e62d8abe4c6d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o?= Date: Tue, 6 May 2025 14:24:56 +0100 Subject: [PATCH 4/6] feat(INFRA-2510): update entry --- .github/workflows/post-gh-rca.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/post-gh-rca.yml b/.github/workflows/post-gh-rca.yml index 8fa11d82..9b068bb7 100644 --- a/.github/workflows/post-gh-rca.yml +++ b/.github/workflows/post-gh-rca.yml @@ -36,12 +36,12 @@ on: description: The entry ID for the regression field in the Google Form required: false type: string - default: entry.1698032149 + default: entry.1228565618 entry-team: description: The entry ID for the team field in the Google Form required: false type: string - default: entry.1228565618 + default: entry.1698032149 jobs: post-rca-form: From 5af472e7ea8f92967a2696fd05c0fdbb055d1d81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o?= Date: Tue, 6 May 2025 14:46:18 +0100 Subject: [PATCH 5/6] feat(INFRA-2510): make entries required --- .github/workflows/post-gh-rca.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/post-gh-rca.yml b/.github/workflows/post-gh-rca.yml index 9b068bb7..092e071e 100644 --- a/.github/workflows/post-gh-rca.yml +++ b/.github/workflows/post-gh-rca.yml @@ -29,19 +29,16 @@ on: type: string entry-issue: description: The entry ID for the issue field in the Google Form - required: false + required: true type: string - default: entry.340898780 entry-regression: description: The entry ID for the regression field in the Google Form - required: false + required: true type: string - default: entry.1228565618 entry-team: description: The entry ID for the team field in the Google Form - required: false + required: true type: string - default: entry.1698032149 jobs: post-rca-form: From 8808521154de3652f40c22f109849085806aad48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o?= Date: Tue, 6 May 2025 14:59:59 +0100 Subject: [PATCH 6/6] feat(INFRA-2510): linting --- .github/workflows/post-gh-rca.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/post-gh-rca.yml b/.github/workflows/post-gh-rca.yml index 092e071e..1cfeb750 100644 --- a/.github/workflows/post-gh-rca.yml +++ b/.github/workflows/post-gh-rca.yml @@ -49,13 +49,13 @@ jobs: uses: actions/github-script@v7 env: GOOGLE_FORM_BASE_URL: ${{ inputs.google-form-base-url }} - ISSUE_LABELS: ${{ inputs.issue-labels }} - OWNER_NAME: ${{ inputs.repo-owner }} - REPO_NAME: ${{ inputs.repo-name }} - ISSUE_NUMBER: ${{ inputs.issue-number }} - ENTRY_ISSUE: ${{ inputs.entry-issue }} - ENTRY_REGRESSION: ${{ inputs.entry-regression }} - ENTRY_TEAM: ${{ inputs.entry-team }} + ISSUE_LABELS: ${{ inputs.issue-labels }} + OWNER_NAME: ${{ inputs.repo-owner }} + REPO_NAME: ${{ inputs.repo-name }} + ISSUE_NUMBER: ${{ inputs.issue-number }} + ENTRY_ISSUE: ${{ inputs.entry-issue }} + ENTRY_REGRESSION: ${{ inputs.entry-regression }} + ENTRY_TEAM: ${{ inputs.entry-team }} with: github-token: ${{ secrets.GITHUB_TOKEN }} script: |