Unverified Commit e05e9846 authored by Michael Daniels's avatar Michael Daniels
Browse files

ci/github-script/reviews: rework dismissal/non-posting logic

Dismissals are done automatically by commits.js, even for reviews from
check-target-branches.js. This is not desirable.

The solution is
(1) do not decline to post a review because it was already dismissed
    (because it may have not been dismissed by a human, and circumstances may
    have changed), and
(2) reword the auto-dismissal message to not imply that whatever
    problems were present are fixed.
parent 82d83c56
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -19,13 +19,13 @@ async function dismissReviews({ github, context, dry }) {
            ...context.repo,
            pull_number,
            review_id: review.id,
            message: 'All good now, thank you!',
            message: 'Review dismissed automatically',
          })
        }
        await github.graphql(
          `mutation($node_id:ID!) {
            minimizeComment(input: {
              classifier: RESOLVED,
              classifier: OUTDATED,
              subjectId: $node_id
            })
            { clientMutationId }
@@ -49,10 +49,7 @@ async function postReview({ github, context, core, dry, body }) {
      review.user?.login === 'github-actions[bot]' &&
      // If a review is still pending, we can just update this instead
      // of posting a new one.
      (review.state === 'CHANGES_REQUESTED' ||
        // No need to post a new review, if an older one with the exact
        // same content had already been dismissed.
        review.body === body),
      review.state === 'CHANGES_REQUESTED',
  )

  if (dry) {