Skip to content

Commit

Permalink
dogfood the request_reviews Mergify action
Browse files Browse the repository at this point in the history
  • Loading branch information
bpholt committed Jul 1, 2022
1 parent adfa542 commit 1ae0a5d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
11 changes: 11 additions & 0 deletions .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,14 @@ pull_request_rules:
add:
- versioning
remove: []
- name: assign scala-steward's PRs for review
conditions:
- author=scala-steward
actions:
request_reviews:
users:
- armanbilge
- rossabaker
- ChristopherDavenport
- djspiewak
random_count: 2
6 changes: 6 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ ThisBuild / developers := List(
ThisBuild / mergifyStewardConfig ~= { _.map(_.copy(mergeMinors = true)) }
ThisBuild / mergifySuccessConditions += MergifyCondition.Custom("#approved-reviews-by>=1")
ThisBuild / mergifyLabelPaths += { "docs" -> file("docs") }
ThisBuild / mergifyPrRules += MergifyPrRule("assign scala-steward's PRs for review",
List(MergifyCondition.Custom("author=scala-steward")),
List(
MergifyAction.RequestReviews((ThisBuild / developers).value, randomCount = 2)
)
)

ThisBuild / scalafixDependencies ++= Seq(
"com.github.liancheng" %% "organize-imports" % "0.6.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@

package org.typelevel.sbt.mergify

import cats.data._
import cats.syntax.all._
import io.circe._
import io.circe.syntax._
import cats.data.*
import cats.syntax.all.*
import io.circe.*
import io.circe.syntax.*
import sbt.librarymanagement.Developer

sealed abstract class MergifyAction {
private[mergify] def name = getClass.getSimpleName.toLowerCase
Expand Down Expand Up @@ -84,6 +85,24 @@ object MergifyAction {
Option(randomCount)
)

def apply(developers: List[Developer]) =
new RequestReviews(
developers
.map(_.id)
.toNel
.getOrElse(throw new RuntimeException("developers must be non-empty"))
.asLeft,
None)

def apply(developers: List[Developer], randomCount: Int) =
new RequestReviews(
developers
.map(_.id)
.toNel
.getOrElse(throw new RuntimeException("developers must be non-empty"))
.asLeft,
randomCount.some)

implicit def encoder: Encoder[RequestReviews] =
Encoder.forProduct2("users", "random_count") { requestReviews =>
(requestReviews.users.fold(_.asJson, _.asJson), requestReviews.randomCount)
Expand Down

0 comments on commit 1ae0a5d

Please sign in to comment.