Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #430 from polyvariant/updates
Browse files Browse the repository at this point in the history
  • Loading branch information
kubukoz authored May 21, 2022
2 parents f8a49e9 + deb40a3 commit 06c8a6f
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 40 deletions.
6 changes: 4 additions & 2 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
version = "3.0.8"
runner.dialect=scala213

version = "3.5.3"
maxColumn = 140
align.preset = some
align.tokens.add = [
align.tokens."+" = [
{code = "<-", owner = Enumerator.Generator}
]
align.multiline = true
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/src/main/scala/org/polyvariant/Gitlab.scala
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ object Gitlab {
MergeRequest.description ~
MergeRequest.shouldBeRebased ~
MergeRequest.conflicts
).mapN((buildMergeRequest(projectId) _))
).mapN(buildMergeRequest(projectId) _)

private def buildMergeRequest(
projectId: Long
Expand Down
39 changes: 19 additions & 20 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -68,24 +68,24 @@ def crossPlugin(x: sbt.librarymanagement.ModuleID) =

val compilerPlugins = List(
crossPlugin("org.typelevel" % "kind-projector" % "0.13.2"),
crossPlugin("com.github.cb372" % "scala-typed-holes" % "0.1.9"),
crossPlugin("org.polyvariant" % "better-tostring" % "0.3.12"),
crossPlugin("com.github.cb372" % "scala-typed-holes" % "0.1.11"),
crossPlugin("org.polyvariant" % "better-tostring" % "0.3.15"),
compilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1")
)

val commonSettings = List(
scalacOptions --= List("-Xfatal-warnings"),
scalacOptions += "-Ymacro-annotations",
libraryDependencies ++= List(
"org.typelevel" %% "cats-core" % "2.6.1",
"org.typelevel" %% "cats-effect" % "3.2.9",
"org.typelevel" %% "cats-core" % "2.7.0",
"org.typelevel" %% "cats-effect" % "3.3.12",
"org.typelevel" %% "cats-tagless-macros" % "0.14.0",
"co.fs2" %% "fs2-core" % "3.2.7",
"com.github.valskalla" %% "odin-core" % "0.13.0",
"io.circe" %% "circe-core" % "0.14.1",
"dev.optics" %% "monocle-macro" % "3.1.0",
"com.disneystreaming" %% "weaver-cats" % "0.7.7" % Test,
"com.disneystreaming" %% "weaver-scalacheck" % "0.7.7" % Test
"com.disneystreaming" %% "weaver-cats" % "0.7.11" % Test,
"com.disneystreaming" %% "weaver-scalacheck" % "0.7.11" % Test
) ++ compilerPlugins,
testFrameworks += new TestFramework("weaver.framework.CatsEffect"),
publish / skip := true
Expand All @@ -95,7 +95,7 @@ lazy val gitlab = project
.settings(
commonSettings,
libraryDependencies ++= List(
"is.cir" %% "ciris" % "2.1.1",
"is.cir" %% "ciris" % "2.3.2",
"com.kubukoz" %% "caliban-gitlab" % "0.1.0",
"io.circe" %% "circe-generic-extras" % "0.14.1",
"io.circe" %% "circe-parser" % "0.14.1" % Test,
Expand All @@ -111,18 +111,18 @@ lazy val bootstrap = project
.settings(
scalaVersion := "3.0.0",
libraryDependencies ++= List(
"org.typelevel" %% "cats-core" % "2.6.1",
"org.typelevel" %% "cats-effect" % "3.2.9",
"org.typelevel" %% "cats-core" % "2.7.0",
"org.typelevel" %% "cats-effect" % "3.3.12",
"com.kubukoz" %% "caliban-gitlab" % "0.1.0",
"com.softwaremill.sttp.client3" %% "core" % "3.3.15",
"com.softwaremill.sttp.client3" %% "circe" % "3.3.15",
"io.circe" %% "circe-core" % "0.14.1",
crossPlugin("org.polyvariant" % "better-tostring" % "0.3.12")
crossPlugin("org.polyvariant" % "better-tostring" % "0.3.15")
),
publish / skip := true,
// Compile / mainClass := Some("org.polyvariant.Main"),
githubWorkflowArtifactUpload := false,
nativeImageVersion := "21.1.0",
nativeImageVersion := "22.1.0",
nativeImageOptions ++= Seq(
s"-H:ReflectionConfigurationFiles=${(Compile / resourceDirectory).value / "reflect-config.json"}",
"--enable-url-protocols=https",
Expand Down Expand Up @@ -182,23 +182,22 @@ lazy val pitgull =
// "apk update && apk add curl bash"
// ) :: installDhallJson :: Nil,
Docker / packageName := "kubukoz/pitgull",
Docker / mappings += (
file("./example.dhall") -> "/opt/docker/example.dhall"
),
Docker / mappings +=
file("./example.dhall") -> "/opt/docker/example.dhall",
mainClass := Some("io.pg.ProjectConfigReader"),
buildInfoOptions += BuildInfoOption.ConstantValue,
buildInfoPackage := "io.pg",
buildInfoKeys := List(version, scalaVersion),
libraryDependencies ++= List(
"com.softwaremill.sttp.client3" %% "http4s-backend" % "3.3.15",
"org.http4s" %% "http4s-dsl" % "0.23.6",
"org.http4s" %% "http4s-circe" % "0.23.6",
"org.http4s" %% "http4s-blaze-server" % "0.23.6",
"org.http4s" %% "http4s-blaze-client" % "0.23.6",
"is.cir" %% "ciris" % "2.1.1",
"org.http4s" %% "http4s-dsl" % "0.23.11",
"org.http4s" %% "http4s-circe" % "0.23.11",
"org.http4s" %% "http4s-blaze-server" % "0.23.11",
"org.http4s" %% "http4s-blaze-client" % "0.23.11",
"is.cir" %% "ciris" % "2.3.2",
"io.circe" %% "circe-generic-extras" % "0.14.0",
"io.scalaland" %% "chimney" % "0.6.1",
"io.chrisdavenport" %% "cats-time" % "0.3.4",
"io.chrisdavenport" %% "cats-time" % "0.4.0",
"com.github.valskalla" %% "odin-core" % "0.13.0",
"com.github.valskalla" %% "odin-slf4j" % "0.13.0",
"io.github.vigoo" %% "prox-fs2-3" % "0.7.7"
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/io/pg/TextUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ object TextUtils {
else s
}

def inline(s: String): String =
def inline(s: String): String =
s.replaceAll("\n", " ")

}
2 changes: 1 addition & 1 deletion gitlab/src/main/scala/io/pg/gitlab/Gitlab.scala
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ object Gitlab {
MergeRequest.description ~
MergeRequest.shouldBeRebased ~
MergeRequest.conflicts
).mapN((buildMergeRequest(projectId) _))
).mapN(buildMergeRequest(projectId) _)

private def buildMergeRequest(
projectId: Long
Expand Down
8 changes: 4 additions & 4 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.20")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.1")
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.22")
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.9")
addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.13.0")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.1.1")
addSbtPlugin("ch.epfl.scala" % "sbt-missinglink" % "0.3.2")
addSbtPlugin("ch.epfl.scala" % "sbt-missinglink" % "0.3.3")
addSbtPlugin("org.scalameta" % "sbt-native-image" % "0.3.2")
4 changes: 1 addition & 3 deletions src/main/scala/io/pg/Application.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import sttp.capabilities.fs2.Fs2Streams
import sttp.client3.SttpBackend
import sttp.client3.http4s.Http4sBackend

import scala.concurrent.ExecutionContext

sealed trait Event extends Product with Serializable

object Event {
Expand All @@ -48,7 +46,7 @@ object Application {
implicit val webhookChannel: Channel[F, WebhookEvent] =
eventChannel.only[Event.Webhook].imap(_.value)(Event.Webhook)

BlazeClientBuilder[F](ExecutionContext.global)
BlazeClientBuilder[F]
.resource
.map(
org
Expand Down
5 changes: 2 additions & 3 deletions src/main/scala/io/pg/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import org.http4s.HttpApp
import org.http4s.blaze.server.BlazeServerBuilder
import org.http4s.server.middleware

import scala.concurrent.ExecutionContext
import scala.concurrent.duration._
import cats.arrow.FunctionK

Expand Down Expand Up @@ -61,10 +60,10 @@ object Main extends IOApp {
.httpApp(
logHeaders = true,
logBody = true,
logAction = (Logger[F].debug(_: String)).some
logAction = ((msg: String) => Logger[F].debug(msg)).some
)(routes)

BlazeServerBuilder[F](ExecutionContext.global)
BlazeServerBuilder[F]
.withHttpApp(app)
.bindHttp(port = config.http.port, host = "0.0.0.0")
.withBanner(config.meta.banner.linesIterator.toList)
Expand Down
7 changes: 5 additions & 2 deletions src/main/scala/io/pg/actions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package io.pg

import cats.data.EitherNel
import cats.implicits._
import cats.tagless.autoContravariant
import io.pg.ProjectAction.Merge
import io.pg.config.Matcher
import io.pg.config.ProjectConfig
Expand All @@ -20,6 +19,7 @@ import cats.Applicative
import cats.data.NonEmptyList
import scala.util.matching.Regex
import cats.MonadThrow
import cats.Contravariant

trait ProjectActions[F[_]] {
type Action
Expand Down Expand Up @@ -97,7 +97,6 @@ object ProjectActions {

}

@autoContravariant
trait MatcherFunction[-In] {
def matches(in: In): Matched[Unit]
def atPath(path: String): MatcherFunction[In] = mapFailures(_.map(_.atPath(path)))
Expand All @@ -108,6 +107,10 @@ object ProjectActions {

object MatcherFunction {

implicit val contravariantMatcherFunction: Contravariant[MatcherFunction] = new Contravariant[MatcherFunction] {
def contramap[A, B](fa: MatcherFunction[A])(f: B => A): MatcherFunction[B] = b => fa.matches(f(b))
}

implicit val monoidK: MonoidK[MatcherFunction] = new MonoidK[MatcherFunction] {
override def combineK[A](x: MatcherFunction[A], y: MatcherFunction[A]): MatcherFunction[A] =
in => (x.matches(in).toValidated |+| y.matches(in).toValidated).toEither
Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/io/pg/config/format.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ object TextMatcher {
implicit val codec: Codec[TextMatcher] = deriveConfiguredCodec
}

@ConfiguredJsonCodec()
@ConfiguredJsonCodec
sealed trait Matcher extends Product with Serializable {
def and(another: Matcher): Matcher = Matcher.Many(List(this, another))
}
Expand All @@ -62,14 +62,14 @@ object Action {
implicit val codec: Codec[Action] = deriveEnumerationCodec
}

@ConfiguredJsonCodec()
@ConfiguredJsonCodec
final case class Rule(name: String, matcher: Matcher, action: Action)

object Rule {
val mergeAnything = Rule("anything", Matcher.Many(Nil), Action.Merge)
}

@ConfiguredJsonCodec()
@ConfiguredJsonCodec
final case class ProjectConfig(rules: List[Rule])

object ProjectConfig {
Expand Down

0 comments on commit 06c8a6f

Please sign in to comment.