Skip to content

fix(ndk): Keep the interrupt when SentryNdk waits for native libraries (JAVA-552) #9885

fix(ndk): Keep the interrupt when SentryNdk waits for native libraries (JAVA-552)

fix(ndk): Keep the interrupt when SentryNdk waits for native libraries (JAVA-552) #9885

name: Changes In High Risk Code
on:
pull_request:
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
files-changed:
name: Detect changed files
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
high_risk_code: ${{ steps.changes.outputs.high_risk_code }}
high_risk_code_files: ${{ steps.changes.outputs.high_risk_code_files }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Get changed files
id: changes
uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
with:
token: ${{ github.token }}
filters: .github/file-filters.yml
# Enable listing of files matching each filter.
# Paths to files will be available in `${FILTER_NAME}_files` output variable.
list-files: csv
validate-high-risk-code:
if: needs.files-changed.outputs.high_risk_code == 'true'
needs: files-changed
runs-on: ubuntu-latest
steps:
- name: Comment on PR to notify of changes in high risk files
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
env:
high_risk_code: ${{ needs.files-changed.outputs.high_risk_code_files }}
with:
script: |
const highRiskFiles = process.env.high_risk_code
.split(',')
.map(file => file.trim())
.filter(Boolean);
const marker = '🚨 Detected changes in high risk code 🚨';
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(/^[ \t]*- \[x\] (.+)$/gim)) {
checked.add(match[1].trim());
}
return checked;
};
const parseListedFiles = (commentBody = '') => {
const listed = [];
for (const match of commentBody.matchAll(/^[ \t]*- \[[ 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, {
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
per_page: 100
});
const existingComment = comments.find(comment =>
comment.body?.includes(marker)
);
// Keep one warning comment. Only rewrite when the file set changes,
// and preserve reviewer checkbox state for files that remain.
if (existingComment) {
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: buildBody(highRiskFiles)
});
}