workflows/bot: allow maintainer merges after committer approval
This allows committers to approve PRs with additional, optional nits that the author-maintainer can either address or merge immediately without these changes. It also allows committers to approve a PR for merge, while still waiting for other maintainers to give their feedback - they can then merge the PR directly instead of passing it back to the committer.
This commit is contained in:
@@ -2,6 +2,7 @@ const { classify } = require('../supportedBranches.js')
|
||||
|
||||
function runChecklist({
|
||||
committers,
|
||||
events,
|
||||
files,
|
||||
pull_request,
|
||||
log,
|
||||
@@ -23,11 +24,25 @@ function runChecklist({
|
||||
.map((pkg) => new Set(maintainers[pkg]))
|
||||
.reduce((acc, cur) => acc?.intersection(cur) ?? cur)
|
||||
|
||||
const approvals = new Set(
|
||||
events
|
||||
.filter(
|
||||
({ event, state, commit_id }) =>
|
||||
event === 'reviewed' &&
|
||||
state === 'approved' &&
|
||||
// Only approvals for the current head SHA count, otherwise authors could push
|
||||
// bad code between the approval and the merge.
|
||||
commit_id === pull_request.head.sha,
|
||||
)
|
||||
.map(({ user }) => user.id),
|
||||
)
|
||||
|
||||
const checklist = {
|
||||
'PR targets a [development branch](https://github.com/NixOS/nixpkgs/blob/-/ci/README.md#branch-classification).':
|
||||
classify(pull_request.base.ref).type.includes('development'),
|
||||
'PR touches only packages in `pkgs/by-name/`.': allByName,
|
||||
'PR is at least one of:': {
|
||||
'Approved by a committer.': committers.intersection(approvals).size > 0,
|
||||
'Authored by a committer.': committers.has(pull_request.user.id),
|
||||
'Backported via label.':
|
||||
pull_request.user.login === 'nixpkgs-ci[bot]' &&
|
||||
@@ -246,6 +261,7 @@ async function handleMerge({
|
||||
|
||||
const { result, checklist } = runChecklist({
|
||||
committers,
|
||||
events,
|
||||
files,
|
||||
pull_request,
|
||||
log,
|
||||
@@ -302,6 +318,7 @@ async function handleMerge({
|
||||
|
||||
const { result } = runChecklist({
|
||||
committers,
|
||||
events,
|
||||
files,
|
||||
pull_request,
|
||||
log,
|
||||
|
||||
Reference in New Issue
Block a user