From 3fc7fefc67aadbbb379d54054dfd1a841feef204 Mon Sep 17 00:00:00 2001 From: Simon Hellmayr Date: Thu, 8 Oct 2026 13:40:36 +0200 Subject: [PATCH 1/2] ci(changelog): Require a Python changelog entry for interface changes A PR that touches py/ or relay-cabi/ changes what the Python package sees, but the check accepted an entry in either changelog. Such a PR now needs an entry in py/CHANGELOG.md. Other PRs keep the old rule, and the skip-changelog label still opts out. Co-Authored-By: Claude Fable 5.1 --- .github/actions/changelog/index.js | 61 ++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 15 deletions(-) diff --git a/.github/actions/changelog/index.js b/.github/actions/changelog/index.js index 36b706f30d8..8b91fb5f003 100644 --- a/.github/actions/changelog/index.js +++ b/.github/actions/changelog/index.js @@ -1,6 +1,9 @@ module.exports = async ({ github, context, core }) => { const PR_LINK = `[#${context.payload.pull_request.number}](${context.payload.pull_request.html_url})`; + // Files that change what the Python package sees: the package itself and the C ABI it binds. + const PYTHON_INTERFACE_RE = /^(py\/(?!CHANGELOG\.md$)|relay-cabi\/)/; + function getCleanTitle(title) { // remove fix(component): prefix title = title.split(': ').slice(-1)[0].trim(); @@ -20,6 +23,7 @@ module.exports = async ({ github, context, core }) => { function getChangelogDetails(title) { return ` For changes exposed to the _Python package_, please add an entry to \`py/CHANGELOG.md\`. This includes, but is not limited to event normalization, PII scrubbing, and the protocol. + Changes under \`py/\` or \`relay-cabi/\` always require an entry in \`py/CHANGELOG.md\`. For changes to the _Relay server_, please add an entry to \`CHANGELOG.md\` under the following heading: 1. **Features**: For new user-visible functionality. 2. **Bug Fixes**: For user-visible bug fixes. @@ -55,6 +59,31 @@ module.exports = async ({ github, context, core }) => { return fileContent.match(/## Unreleased(.*?)##/ms)?.[1]?.includes(PR_LINK) || false; } + async function touchesPythonInterface() { + const files = await github.paginate(github.rest.pulls.listFiles, { + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number, + per_page: 100, + }); + return files.some(file => PYTHON_INTERFACE_RE.test(file.filename)); + } + + function failMissingChangelog(pr, file, message) { + core.error(message, { + title: 'Missing changelog entry.', + file, + startLine: 3, + }); + const title = getCleanTitle(pr.title); + core.summary + .addHeading('Instructions and example for changelog') + .addRaw(getChangelogDetails(title)) + .write(); + core.setFailed(`${file} entry is missing.`); + logOutputError(title); + } + async function checkChangelog(pr) { const hasSkipLabel = (pr.labels || []).some(label => label.name === 'skip-changelog'); if (hasSkipLabel) { @@ -65,23 +94,25 @@ module.exports = async ({ github, context, core }) => { return; } - const hasChangelog = - (await containsChangelog('CHANGELOG.md')) || - (await containsChangelog('py/CHANGELOG.md')); + const hasPyChangelog = await containsChangelog('py/CHANGELOG.md'); + + if (!hasPyChangelog && (await touchesPythonInterface())) { + failMissingChangelog( + pr, + 'py/CHANGELOG.md', + 'This PR changes the Python package or the C ABI. Please add an entry to py/CHANGELOG.md.' + ); + return; + } + + const hasChangelog = hasPyChangelog || (await containsChangelog('CHANGELOG.md')); if (!hasChangelog) { - core.error('Please consider adding a changelog entry for the next release.', { - title: 'Missing changelog entry.', - file: 'CHANGELOG.md', - startLine: 3, - }); - const title = getCleanTitle(pr.title); - core.summary - .addHeading('Instructions and example for changelog') - .addRaw(getChangelogDetails(title)) - .write(); - core.setFailed('CHANGELOG entry is missing.'); - logOutputError(title); + failMissingChangelog( + pr, + 'CHANGELOG.md', + 'Please consider adding a changelog entry for the next release.' + ); return; } From 66f526ef832b720e4c6d79294a09c54a10f7a88f Mon Sep 17 00:00:00 2001 From: Simon Hellmayr Date: Thu, 8 Oct 2026 13:50:41 +0200 Subject: [PATCH 2/2] ci(changelog): Cover every crate the C ABI depends on A change can reach the Python package through an existing C ABI function without touching py/ or relay-cabi/, as the release condition in relay-protocol did. Resolve the workspace crates relay-cabi depends on with cargo metadata and require a Python changelog entry for changes to any of them. Infrastructure crates such as relay-log are excluded. If cargo is unavailable, the check falls back to py/ and relay-cabi/. Co-Authored-By: Claude Fable 5.1 --- .github/actions/changelog/index.js | 60 ++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 4 deletions(-) diff --git a/.github/actions/changelog/index.js b/.github/actions/changelog/index.js index 8b91fb5f003..186999d106c 100644 --- a/.github/actions/changelog/index.js +++ b/.github/actions/changelog/index.js @@ -1,8 +1,17 @@ +const {execFileSync} = require('child_process'); +const path = require('path'); + module.exports = async ({ github, context, core }) => { const PR_LINK = `[#${context.payload.pull_request.number}](${context.payload.pull_request.html_url})`; - // Files that change what the Python package sees: the package itself and the C ABI it binds. - const PYTHON_INTERFACE_RE = /^(py\/(?!CHANGELOG\.md$)|relay-cabi\/)/; + // Crates the C ABI depends on for infrastructure only. Changes to them never reach Python. + const INFRASTRUCTURE_CRATES = new Set([ + 'relay-cogs', + 'relay-log', + 'relay-redis', + 'relay-statsd', + 'relay-system', + ]); function getCleanTitle(title) { // remove fix(component): prefix @@ -23,7 +32,7 @@ module.exports = async ({ github, context, core }) => { function getChangelogDetails(title) { return ` For changes exposed to the _Python package_, please add an entry to \`py/CHANGELOG.md\`. This includes, but is not limited to event normalization, PII scrubbing, and the protocol. - Changes under \`py/\` or \`relay-cabi/\` always require an entry in \`py/CHANGELOG.md\`. + Changes under \`py/\` or to a crate the C ABI depends on always require an entry in \`py/CHANGELOG.md\`. For changes to the _Relay server_, please add an entry to \`CHANGELOG.md\` under the following heading: 1. **Features**: For new user-visible functionality. 2. **Bug Fixes**: For user-visible bug fixes. @@ -59,6 +68,44 @@ module.exports = async ({ github, context, core }) => { return fileContent.match(/## Unreleased(.*?)##/ms)?.[1]?.includes(PR_LINK) || false; } + // Directories whose files change what the Python package sees: the package itself and every + // workspace crate the C ABI depends on. Falls back to the C ABI crate alone if cargo fails. + function pythonInterfaceDirs() { + try { + const metadata = JSON.parse( + execFileSync('cargo', ['metadata', '--no-deps', '--format-version', '1'], { + encoding: 'utf8', + }) + ); + const packages = new Map(metadata.packages.map(pkg => [pkg.name, pkg])); + + const closure = new Set(); + const todo = ['relay-cabi']; + while (todo.length > 0) { + const name = todo.pop(); + const pkg = packages.get(name); + if (!pkg || closure.has(name)) { + continue; + } + closure.add(name); + for (const dep of pkg.dependencies) { + if (dep.kind === null && packages.has(dep.name)) { + todo.push(dep.name); + } + } + } + + const dirs = [...closure] + .filter(name => !INFRASTRUCTURE_CRATES.has(name)) + .map(name => path.dirname(packages.get(name).manifest_path)) + .map(dir => path.relative(metadata.workspace_root, dir)); + return ['py', ...dirs]; + } catch (error) { + core.warning(`Cannot resolve the C ABI dependencies, checking relay-cabi only: ${error}`); + return ['py', 'relay-cabi']; + } + } + async function touchesPythonInterface() { const files = await github.paginate(github.rest.pulls.listFiles, { owner: context.repo.owner, @@ -66,7 +113,12 @@ module.exports = async ({ github, context, core }) => { pull_number: context.payload.pull_request.number, per_page: 100, }); - return files.some(file => PYTHON_INTERFACE_RE.test(file.filename)); + const dirs = pythonInterfaceDirs(); + return files.some( + file => + file.filename !== 'py/CHANGELOG.md' && + dirs.some(dir => file.filename.startsWith(`${dir}/`)) + ); } function failMissingChangelog(pr, file, message) {