ci/github-script/commits: conditionally show comments

This only shows *some* of the additional hints, depending on what the
checks resulted in. Should hopefully reduce confusion a bit.
This commit is contained in:
Wolfgang Walther 2025-08-13 21:00:42 +02:00
parent 2f8ed18c97
commit 91fd9b10ac
No known key found for this signature in database
GPG Key ID: B39893FA5F65CAE1
2 changed files with 26 additions and 19 deletions

View File

@ -1,15 +0,0 @@
This report is automatically generated by the `PR / Check / cherry-pick` CI workflow.
Some of the commits in this PR require the author's and reviewer's attention.
Please follow the [backporting guidelines](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#how-to-backport-pull-requests) and cherry-pick with the `-x` flag.
This requires changes to the unstable `master` and `staging` branches first, before backporting them.
Occasionally, commits are not cherry-picked at all, for example when updating minor versions of packages which have already advanced to the next major on unstable.
These commits can optionally be marked with a `Not-cherry-picked-because: <reason>` footer.
Sometimes it is not possible to cherry-pick exactly the same patch.
This most frequently happens when resolving merge conflicts.
The range-diff will help to review the resolution of conflicts.
If you need to merge this PR despite the warnings, please [dismiss](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/dismissing-a-pull-request-review) this review shortly before merging.

View File

@ -33,6 +33,7 @@ module.exports = async function ({ github, context, core, dry }) {
commit, commit,
severity: 'important', severity: 'important',
message: `${sha} is not a cherry-pick, because: ${noCherryPick[1]}. Please review this commit manually.`, message: `${sha} is not a cherry-pick, because: ${noCherryPick[1]}. Please review this commit manually.`,
type: 'no-cherry-pick',
} }
// Using the last line with "cherry" + hash, because a chained backport // Using the last line with "cherry" + hash, because a chained backport
@ -47,6 +48,7 @@ module.exports = async function ({ github, context, core, dry }) {
commit, commit,
severity: 'warning', severity: 'warning',
message: `Couldn't locate original commit hash in message of ${sha}.`, message: `Couldn't locate original commit hash in message of ${sha}.`,
type: 'no-commit-hash',
} }
const original_sha = cherry[1] const original_sha = cherry[1]
@ -133,6 +135,7 @@ module.exports = async function ({ github, context, core, dry }) {
colored_diff, colored_diff,
severity: 'warning', severity: 'warning',
message: `Difference between ${sha} and original ${original_sha} may warrant inspection.`, message: `Difference between ${sha} and original ${original_sha} may warrant inspection.`,
type: 'diff',
} }
} }
@ -214,10 +217,29 @@ module.exports = async function ({ github, context, core, dry }) {
if (results.some(({ severity }) => severity == 'error')) if (results.some(({ severity }) => severity == 'error'))
process.exitCode = 1 process.exitCode = 1
core.summary.addRaw( core.summary.addRaw('This report is automatically generated by the `PR / Check / cherry-pick` CI workflow.', true)
await readFile(join(__dirname, 'check-cherry-picks.md'), 'utf-8'), core.summary.addEOL()
true, core.summary.addRaw("Some of the commits in this PR require the author's and reviewer's attention.", true)
) core.summary.addEOL()
if (results.some(({ type }) => type === 'no-commit-hash')) {
core.summary.addRaw('Please follow the [backporting guidelines](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#how-to-backport-pull-requests) and cherry-pick with the `-x` flag.', true)
core.summary.addRaw('This requires changes to the unstable `master` and `staging` branches first, before backporting them.', true)
core.summary.addEOL()
core.summary.addRaw('Occasionally, commits are not cherry-picked at all, for example when updating minor versions of packages which have already advanced to the next major on unstable.', true)
core.summary.addRaw('These commits can optionally be marked with a `Not-cherry-picked-because: <reason>` footer.', true)
core.summary.addEOL()
}
if (results.some(({ type }) => type === 'diff')) {
core.summary.addRaw('Sometimes it is not possible to cherry-pick exactly the same patch.', true)
core.summary.addRaw('This most frequently happens when resolving merge conflicts.', true)
core.summary.addRaw('The range-diff will help to review the resolution of conflicts.', true)
core.summary.addEOL()
}
core.summary.addRaw('If you need to merge this PR despite the warnings, please [dismiss](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/dismissing-a-pull-request-review) this review shortly before merging.', true)
results.forEach(({ severity, message, diff }) => { results.forEach(({ severity, message, diff }) => {
if (severity == 'info') return if (severity == 'info') return