-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add plugin for generating .mergify.yml
config
#190
Changes from 11 commits
992638b
0e2d219
17bd11e
5b86e38
4a18377
12d2216
0e09de5
74bc703
6e3b473
9e14a2b
a8cbe69
640d0ce
9c9c3ee
1810bd7
b39ea12
fd160ed
aca1d33
34df1ac
41340e2
95e8e68
969a2e2
8ad0015
7a22bba
9843119
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# This file was automatically generated by sbt-typelevel-mergify using the | ||
# mergifyGenerate task. You should add and commit this file to | ||
# your git repository. It goes without saying that you shouldn't edit | ||
# this file by hand! Instead, if you wish to make changes, you should | ||
# change your sbt build configuration to revise the mergify configuration | ||
# to meet your needs, then regenerate this file. | ||
|
||
pull_request_rules: | ||
- name: merge scala-steward's PRs | ||
conditions: | ||
- author=scala-steward | ||
- or: | ||
- body~=labels:.*early-semver-patch | ||
- body~=labels:.*early-semver-minor | ||
- status-success=Build and Test (ubuntu-latest, 2.12.15, temurin@8, rootJVM) | ||
- '#approved-reviews-by>=1' | ||
actions: | ||
- merge: {} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,12 +11,16 @@ ThisBuild / developers := List( | |
tlGitHubDev("djspiewak", "Daniel Spiewak") | ||
) | ||
|
||
ThisBuild / mergifyStewardConfig ~= { _.map(_.copy(mergeMinors = true)) } | ||
ThisBuild / mergifySuccessConditions += MergifyCondition.Custom("#approved-reviews-by>=1") | ||
Comment on lines
+14
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
lazy val root = tlCrossRootProject.aggregate( | ||
kernel, | ||
noPublish, | ||
settings, | ||
github, | ||
githubActions, | ||
mergify, | ||
versioning, | ||
mima, | ||
sonatype, | ||
|
@@ -66,6 +70,14 @@ lazy val githubActions = project | |
name := "sbt-typelevel-github-actions" | ||
) | ||
|
||
lazy val mergify = project | ||
.in(file("mergify")) | ||
.enablePlugins(SbtPlugin) | ||
.settings( | ||
name := "sbt-typelevel-mergify" | ||
) | ||
.dependsOn(githubActions) | ||
|
||
lazy val versioning = project | ||
.in(file("versioning")) | ||
.enablePlugins(SbtPlugin) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
libraryDependencies += "io.circe" %% "circe-yaml" % "0.14.1" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright 2022 Typelevel | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.typelevel.sbt.mergify | ||
|
||
import io.circe.Encoder | ||
import io.circe.Json | ||
import io.circe.syntax._ | ||
|
||
sealed abstract class MergifyAction | ||
|
||
object MergifyAction { | ||
|
||
implicit def encoder: Encoder[MergifyAction] = Encoder.instance { | ||
case merge: Merge => merge.asJson | ||
case label: Label => label.asJson | ||
case _ => sys.error("should not happen") | ||
} | ||
|
||
final case class Merge( | ||
method: Option[String] = None, | ||
rebaseFallback: Option[String] = None, | ||
commitMessageTemplate: Option[String] = None | ||
) extends MergifyAction | ||
|
||
object Merge { | ||
implicit def encoder: Encoder[Merge] = | ||
Encoder | ||
.forProduct3("method", "rebase_fallback", "commit_message_template") { (m: Merge) => | ||
(m.method, m.rebaseFallback, m.commitMessageTemplate) | ||
} | ||
.mapJson(m => Json.obj("merge" -> m)) | ||
} | ||
|
||
final case class Label( | ||
add: List[String] = Nil, | ||
remove: List[String] = Nil, | ||
removeAll: Option[Boolean] = None | ||
) extends MergifyAction | ||
|
||
object Label { | ||
implicit def encoder: Encoder[Label] = | ||
Encoder | ||
.forProduct3("add", "remove", "remove_all") { (l: Label) => | ||
(l.add, l.remove, l.removeAll) | ||
} | ||
.mapJson(l => Json.obj("label" -> l)) | ||
} | ||
|
||
private[this] object Dummy extends MergifyAction | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This trick lets us keep |
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright 2022 Typelevel | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.typelevel.sbt.mergify | ||
|
||
import io.circe.Encoder | ||
import io.circe.syntax._ | ||
|
||
sealed abstract class MergifyCondition | ||
|
||
object MergifyCondition { | ||
implicit def encoder: Encoder[MergifyCondition] = Encoder.instance { | ||
case custom: Custom => custom.asJson | ||
case and: And => and.asJson | ||
case or: Or => or.asJson | ||
case _ => sys.error("shouldn't happen") | ||
} | ||
|
||
final case class Custom(condition: String) extends MergifyCondition | ||
object Custom { | ||
implicit def encoder: Encoder[Custom] = Encoder.encodeString.contramap(_.condition) | ||
} | ||
|
||
final case class And(conditions: List[MergifyCondition]) extends MergifyCondition | ||
object And { | ||
implicit def encoder: Encoder[And] = Encoder.forProduct1("and")(_.conditions) | ||
} | ||
|
||
final case class Or(conditions: List[MergifyCondition]) extends MergifyCondition | ||
object Or { | ||
implicit def encoder: Encoder[Or] = Encoder.forProduct1("or")(_.conditions) | ||
} | ||
|
||
private[this] final object Dummy extends MergifyCondition // break exhaustivity checking | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fthomas if you have a chance, would appreciate your eyes on this. Are these labels the right configuration for checking steward PRs? Thanks! :)