From 002f3279040b8c25ed6ec13a3dd7571568cb080f 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 Co-Authored-By: Roman Zavarnitsyn --- .../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 61ee69334a7..53ece642dce 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 f2cf39cbc81c28310c37c78e7ba1f99587a42f8d 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. Co-Authored-By: Roman Zavarnitsyn --- .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 53ece642dce..1a74b4780c0 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 fea29c55e62e655686b5e781f33b9940fe123b95 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. Co-Authored-By: Roman Zavarnitsyn --- .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 1a74b4780c0..8260994da3e 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 6b51703d37273b08b3656843f299ab2f5710f6f1 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. Co-Authored-By: Roman Zavarnitsyn --- .../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 8260994da3e..36389d5bc29 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 f34bce7f650c7f8e163d82946cf4a20caacb3c45 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. Co-Authored-By: Roman Zavarnitsyn --- .../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 36389d5bc29..35546695653 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 3e15390ee6cc0d39df694ff4c0788e6118456f16 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. Co-Authored-By: Roman Zavarnitsyn --- .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 35546695653..a800284fd0a 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;