From dfb3dc3c1e097cab19fb5fa55cd9acdd4458c728 Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Wed, 26 Aug 2026 15:37:25 +0000 Subject: [PATCH 1/6] ci: skip duplicate high-risk code PR comments Only post the high-risk code warning once per PR, matching sentry-dart. Co-Authored-By: Gino Buenaflor --- .../workflows/changes-in-high-risk-code.yml | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/.github/workflows/changes-in-high-risk-code.yml b/.github/workflows/changes-in-high-risk-code.yml index 61ee69334a..53ece642dc 100644 --- a/.github/workflows/changes-in-high-risk-code.yml +++ b/.github/workflows/changes-in-high-risk-code.yml @@ -41,9 +41,25 @@ jobs: script: | const highRiskFiles = process.env.high_risk_code; const fileList = highRiskFiles.split(',').map(file => `- [ ] ${file}`).join('\n'); - github.rest.issues.createComment({ + + // Get existing comments + const comments = await github.rest.issues.listComments({ issue_number: context.issue.number, owner: context.repo.owner, - repo: context.repo.repo, - body: `### 🚨 Detected changes in high risk code 🚨 \n High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:\n ${fileList}` - }) + repo: context.repo.repo + }); + + // Check if we already have a high risk code comment + const hasExistingComment = comments.data.some(comment => + comment.body.includes('🚨 Detected changes in high risk code 🚨') + ); + + // Only create comment if we don't already have one + if (!hasExistingComment) { + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `### 🚨 Detected changes in high risk code 🚨 \n High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:\n ${fileList}` + }); + } From f6b1bfd39904f917989863031643109614595f8e Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Wed, 26 Aug 2026 15:42:27 +0000 Subject: [PATCH 2/6] ci: paginate high-risk comment lookup Avoid missing an existing warning when a PR has more than 30 comments. --- .github/workflows/changes-in-high-risk-code.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/changes-in-high-risk-code.yml b/.github/workflows/changes-in-high-risk-code.yml index 53ece642dc..1a74b4780c 100644 --- a/.github/workflows/changes-in-high-risk-code.yml +++ b/.github/workflows/changes-in-high-risk-code.yml @@ -42,15 +42,16 @@ jobs: const highRiskFiles = process.env.high_risk_code; const fileList = highRiskFiles.split(',').map(file => `- [ ] ${file}`).join('\n'); - // Get existing comments - const comments = await github.rest.issues.listComments({ + // Get existing comments (paginate so older comments are not missed) + const comments = await github.paginate(github.rest.issues.listComments, { issue_number: context.issue.number, owner: context.repo.owner, - repo: context.repo.repo + repo: context.repo.repo, + per_page: 100 }); // Check if we already have a high risk code comment - const hasExistingComment = comments.data.some(comment => + const hasExistingComment = comments.some(comment => comment.body.includes('🚨 Detected changes in high risk code 🚨') ); From 0744f28da7796a143cbb48db28cc56777a69b463 Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Wed, 26 Aug 2026 15:46:25 +0000 Subject: [PATCH 3/6] ci: null-safe high-risk comment body check Avoid TypeError if a PR comment has a null body. --- .github/workflows/changes-in-high-risk-code.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/changes-in-high-risk-code.yml b/.github/workflows/changes-in-high-risk-code.yml index 1a74b4780c..8260994da3 100644 --- a/.github/workflows/changes-in-high-risk-code.yml +++ b/.github/workflows/changes-in-high-risk-code.yml @@ -52,7 +52,7 @@ jobs: // Check if we already have a high risk code comment const hasExistingComment = comments.some(comment => - comment.body.includes('🚨 Detected changes in high risk code 🚨') + comment.body?.includes('🚨 Detected changes in high risk code 🚨') ); // Only create comment if we don't already have one From 6f876ae2c490f7eedfa8d4ca7e712502250516e8 Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Wed, 26 Aug 2026 15:49:32 +0000 Subject: [PATCH 4/6] ci: update high-risk comment when file list changes Keep a single warning comment and refresh its body so reviewers do not see a stale high-risk file list after later pushes. --- .../workflows/changes-in-high-risk-code.yml | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/changes-in-high-risk-code.yml b/.github/workflows/changes-in-high-risk-code.yml index 8260994da3..36389d5bc2 100644 --- a/.github/workflows/changes-in-high-risk-code.yml +++ b/.github/workflows/changes-in-high-risk-code.yml @@ -42,6 +42,9 @@ jobs: const highRiskFiles = process.env.high_risk_code; const fileList = highRiskFiles.split(',').map(file => `- [ ] ${file}`).join('\n'); + const marker = '🚨 Detected changes in high risk code 🚨'; + const body = `### ${marker} \n High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:\n ${fileList}`; + // Get existing comments (paginate so older comments are not missed) const comments = await github.paginate(github.rest.issues.listComments, { issue_number: context.issue.number, @@ -50,17 +53,25 @@ jobs: per_page: 100 }); - // Check if we already have a high risk code comment - const hasExistingComment = comments.some(comment => - comment.body?.includes('🚨 Detected changes in high risk code 🚨') + const existingComment = comments.find(comment => + comment.body?.includes(marker) ); - // Only create comment if we don't already have one - if (!hasExistingComment) { + // Update the existing warning so the file list stays current, else create once + if (existingComment) { + if (existingComment.body !== body) { + await github.rest.issues.updateComment({ + comment_id: existingComment.id, + owner: context.repo.owner, + repo: context.repo.repo, + body + }); + } + } else { await github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: `### 🚨 Detected changes in high risk code 🚨 \n High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:\n ${fileList}` + body }); } From 8af0c7b82514059035814cc1c8f0074d1803813b Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Wed, 26 Aug 2026 15:52:47 +0000 Subject: [PATCH 5/6] ci: preserve high-risk comment checkboxes on update Only rewrite the warning when the high-risk file set changes, and keep reviewer checkbox state for files that remain. --- .../workflows/changes-in-high-risk-code.yml | 64 +++++++++++++++---- 1 file changed, 52 insertions(+), 12 deletions(-) diff --git a/.github/workflows/changes-in-high-risk-code.yml b/.github/workflows/changes-in-high-risk-code.yml index 36389d5bc2..3554669565 100644 --- a/.github/workflows/changes-in-high-risk-code.yml +++ b/.github/workflows/changes-in-high-risk-code.yml @@ -39,11 +39,43 @@ jobs: high_risk_code: ${{ needs.files-changed.outputs.high_risk_code_files }} with: script: | - const highRiskFiles = process.env.high_risk_code; - const fileList = highRiskFiles.split(',').map(file => `- [ ] ${file}`).join('\n'); + const highRiskFiles = process.env.high_risk_code + .split(',') + .map(file => file.trim()) + .filter(Boolean); const marker = '🚨 Detected changes in high risk code 🚨'; - const body = `### ${marker} \n High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:\n ${fileList}`; + const intro = `### ${marker} \n High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:`; + + const buildBody = (files, checkedFiles = new Set()) => { + const fileList = files + .map(file => `- [${checkedFiles.has(file) ? 'x' : ' '}] ${file}`) + .join('\n'); + return `${intro}\n ${fileList}`; + }; + + const parseCheckedFiles = (commentBody = '') => { + const checked = new Set(); + for (const match of commentBody.matchAll(/^- \[x\] (.+)$/gim)) { + checked.add(match[1].trim()); + } + return checked; + }; + + const parseListedFiles = (commentBody = '') => { + const listed = []; + for (const match of commentBody.matchAll(/^- \[[ xX]\] (.+)$/gim)) { + listed.push(match[1].trim()); + } + return listed; + }; + + const sameFileSet = (a, b) => { + if (a.length !== b.length) return false; + const left = [...a].sort().join('\n'); + const right = [...b].sort().join('\n'); + return left === right; + }; // Get existing comments (paginate so older comments are not missed) const comments = await github.paginate(github.rest.issues.listComments, { @@ -57,21 +89,29 @@ jobs: comment.body?.includes(marker) ); - // Update the existing warning so the file list stays current, else create once + // Keep one warning comment. Only rewrite when the file set changes, + // and preserve reviewer checkbox state for files that remain. if (existingComment) { - if (existingComment.body !== body) { - await github.rest.issues.updateComment({ - comment_id: existingComment.id, - owner: context.repo.owner, - repo: context.repo.repo, - body - }); + const previousFiles = parseListedFiles(existingComment.body); + if (sameFileSet(previousFiles, highRiskFiles)) { + return; } + + const body = buildBody( + highRiskFiles, + parseCheckedFiles(existingComment.body) + ); + await github.rest.issues.updateComment({ + comment_id: existingComment.id, + owner: context.repo.owner, + repo: context.repo.repo, + body + }); } else { await github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body + body: buildBody(highRiskFiles) }); } From 61ef7a067c55be71f7b3f145fb9aedbb3945b17f Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Wed, 26 Aug 2026 15:56:57 +0000 Subject: [PATCH 6/6] ci: fix high-risk comment checklist parsing Drop the leading space before the file list and allow optional indent so the first checklist item is not skipped on parse. --- .github/workflows/changes-in-high-risk-code.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/changes-in-high-risk-code.yml b/.github/workflows/changes-in-high-risk-code.yml index 3554669565..a800284fd0 100644 --- a/.github/workflows/changes-in-high-risk-code.yml +++ b/.github/workflows/changes-in-high-risk-code.yml @@ -51,12 +51,12 @@ jobs: const fileList = files .map(file => `- [${checkedFiles.has(file) ? 'x' : ' '}] ${file}`) .join('\n'); - return `${intro}\n ${fileList}`; + return `${intro}\n${fileList}`; }; const parseCheckedFiles = (commentBody = '') => { const checked = new Set(); - for (const match of commentBody.matchAll(/^- \[x\] (.+)$/gim)) { + for (const match of commentBody.matchAll(/^[ \t]*- \[x\] (.+)$/gim)) { checked.add(match[1].trim()); } return checked; @@ -64,7 +64,7 @@ jobs: const parseListedFiles = (commentBody = '') => { const listed = []; - for (const match of commentBody.matchAll(/^- \[[ xX]\] (.+)$/gim)) { + for (const match of commentBody.matchAll(/^[ \t]*- \[[ xX]\] (.+)$/gim)) { listed.push(match[1].trim()); } return listed;