Unverified Commit df6a9a73 authored by Wolfgang Walther's avatar Wolfgang Walther
Browse files

ci/github-script/bot: disregard bot and ghost approvals

We technically counted bot approvals and approvals by deleted users for
the approval labels as well. The former don't exist, yet, but if they
were, I don't think we'd count them. The latter should arguably *not* be
counted, because we can't tell anymore *who* approved, so we can't put
any weight on it as reviewers.

This simplifies the logic, too.
parent 61c44034
Loading
Loading
Loading
Loading
+11 −12
Original line number Diff line number Diff line
@@ -209,10 +209,16 @@ module.exports = async ({ github, context, core, dry }) => {
      }
    }

    const reviews = await github.paginate(github.rest.pulls.listReviews, {
    // Check for any human reviews other than GitHub actions and other GitHub apps.
    // Accounts could be deleted as well, so don't count them.
    const reviews = (
      await github.paginate(github.rest.pulls.listReviews, {
        ...context.repo,
        pull_number,
      })
    ).filter(
      (r) => r.user && !r.user.login.endsWith('[bot]') && r.user.type !== 'Bot',
    )

    const approvals = new Set(
      reviews
@@ -282,13 +288,6 @@ module.exports = async ({ github, context, core, dry }) => {
    log('Last eval run', run_id ?? '<n/a>')

    if (conclusion === 'success') {
      // Check for any human reviews other than GitHub actions and other GitHub apps.
      // Accounts could be deleted as well, so don't count them.
      const humanReviews = reviews.filter(
        (r) =>
          r.user && !r.user.login.endsWith('[bot]') && r.user.type !== 'Bot',
      )

      Object.assign(prLabels, {
        // We only set this label if the latest eval run was successful, because if it was not, it
        // *could* have requested reviewers. We will let the PR author fix CI first, before "escalating"
@@ -301,7 +300,7 @@ module.exports = async ({ github, context, core, dry }) => {
        '9.needs: reviewer':
          !pull_request.draft &&
          pull_request.requested_reviewers.length === 0 &&
          humanReviews.length === 0,
          reviews.length === 0,
      })
    }