ci/github-script/merge: support OR conditions
This supports AND on the first and OR on the second level, which is needed for some follow up work like backports, approval based merges or trusted maintainers.
This commit is contained in:
@@ -44,7 +44,9 @@ To ensure security and a focused utility, the bot adheres to specific limitation
|
|||||||
|
|
||||||
- The PR targets `master`, `staging`, or `staging-next`.
|
- The PR targets `master`, `staging`, or `staging-next`.
|
||||||
- The PR only touches packages located under `pkgs/by-name/*`.
|
- The PR only touches packages located under `pkgs/by-name/*`.
|
||||||
- The PR is authored by [@r-ryantm](https://nix-community.github.io/nixpkgs-update/r-ryantm/) or a [committer][@NixOS/nixpkgs-committers].
|
- The PR is either:
|
||||||
|
- authored by a [committer][@NixOS/nixpkgs-committers], or
|
||||||
|
- created by [@r-ryantm](https://nix-community.github.io/nixpkgs-update/r-ryantm/).
|
||||||
- The user attempting to merge is a member of [@NixOS/nixpkgs-maintainers].
|
- The user attempting to merge is a member of [@NixOS/nixpkgs-maintainers].
|
||||||
- The user attempting to merge is a maintainer of all packages touched by the PR.
|
- The user attempting to merge is a maintainer of all packages touched by the PR.
|
||||||
|
|
||||||
|
|||||||
@@ -28,9 +28,10 @@ function runChecklist({
|
|||||||
'staging-next',
|
'staging-next',
|
||||||
].includes(pull_request.base.ref),
|
].includes(pull_request.base.ref),
|
||||||
'PR touches only packages in `pkgs/by-name/`.': allByName,
|
'PR touches only packages in `pkgs/by-name/`.': allByName,
|
||||||
'PR authored by r-ryantm or committer.':
|
'PR is at least one of:': {
|
||||||
pull_request.user.login === 'r-ryantm' ||
|
'Authored by a committer.': committers.has(pull_request.user.id),
|
||||||
committers.has(pull_request.user.id),
|
'Created by r-ryantm.': pull_request.user.login === 'r-ryantm',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user) {
|
if (user) {
|
||||||
@@ -48,7 +49,9 @@ function runChecklist({
|
|||||||
checklist['PR has maintainers eligible to merge.'] = eligible.size > 0
|
checklist['PR has maintainers eligible to merge.'] = eligible.size > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = Object.values(checklist).every(Boolean)
|
const result = Object.values(checklist).every((v) =>
|
||||||
|
typeof v === 'boolean' ? v : Object.values(v).some(Boolean),
|
||||||
|
)
|
||||||
|
|
||||||
log('checklist', JSON.stringify(checklist))
|
log('checklist', JSON.stringify(checklist))
|
||||||
log('eligible', JSON.stringify(Array.from(eligible)))
|
log('eligible', JSON.stringify(Array.from(eligible)))
|
||||||
@@ -255,8 +258,16 @@ async function handleMerge({
|
|||||||
`@${comment.user.login} wants to merge this PR.`,
|
`@${comment.user.login} wants to merge this PR.`,
|
||||||
'',
|
'',
|
||||||
'Requirements to merge this PR with `@NixOS/nixpkgs-merge-bot merge`:',
|
'Requirements to merge this PR with `@NixOS/nixpkgs-merge-bot merge`:',
|
||||||
...Object.entries(checklist).map(
|
...Object.entries(checklist).flatMap(([msg, res]) =>
|
||||||
([msg, res]) => `- :${res ? 'white_check_mark' : 'x'}: ${msg}`,
|
typeof res === 'boolean'
|
||||||
|
? `- :${res ? 'white_check_mark' : 'x'}: ${msg}`
|
||||||
|
: [
|
||||||
|
`- :${Object.values(res).some(Boolean) ? 'white_check_mark' : 'x'}: ${msg}`,
|
||||||
|
...Object.entries(res).map(
|
||||||
|
([msg, res]) =>
|
||||||
|
` - ${res ? ':white_check_mark:' : ':white_large_square:'} ${msg}`,
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
'',
|
'',
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user