Skip to content

Commit c54044e

Browse files
Integrates sbt-org-policies plugin
1 parent 11119f5 commit c54044e

File tree

23 files changed

+316
-447
lines changed

23 files changed

+316
-447
lines changed

.scalafmt

Lines changed: 0 additions & 5 deletions
This file was deleted.

.scalafmt.conf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
style = defaultWithAlign
2+
maxColumn = 100
3+
4+
continuationIndent.callSite = 2
5+
6+
newlines {
7+
sometimesBeforeColonInMethodReturnType = false
8+
}
9+
10+
align {
11+
arrowEnumeratorGenerator = false
12+
ifWhileOpenParen = false
13+
openParenCallSite = false
14+
openParenDefnSite = false
15+
}
16+
17+
docstrings = JavaDoc
18+
19+
rewrite {
20+
rules = [SortImports, RedundantBraces]
21+
redundantBraces.maxLines = 1
22+
}
23+

build.sbt

Lines changed: 53 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,45 @@
1-
lazy val noPublishSettings = Seq(
2-
publish := (),
3-
publishLocal := (),
4-
publishArtifact := false
5-
)
1+
pgpPassphrase := Some(getEnvVar("PGP_PASSPHRASE").getOrElse("").toCharArray)
2+
pgpPublicRing := file(s"$gpgFolder/pubring.gpg")
3+
pgpSecretRing := file(s"$gpgFolder/secring.gpg")
64

75
lazy val root = (project in file("."))
86
.settings(mainClass in Universal := Some("org.scalaexercises.evaluator.EvaluatorServer"))
97
.settings(stage <<= (stage in Universal in `evaluator-server`))
108
.settings(noPublishSettings: _*)
11-
.aggregate(`evaluator-server`, `evaluator-shared-jvm`, `evaluator-shared-js`, `evaluator-client-jvm`, `evaluator-client-js`)
9+
.aggregate(
10+
`evaluator-server`,
11+
`evaluator-shared-jvm`,
12+
`evaluator-shared-js`,
13+
`evaluator-client-jvm`,
14+
`evaluator-client-js`)
1215

1316
lazy val `evaluator-shared` = (crossProject in file("shared"))
1417
.enablePlugins(AutomateHeaderPlugin)
1518
.settings(name := "evaluator-shared")
1619

1720
lazy val `evaluator-shared-jvm` = `evaluator-shared`.jvm
18-
lazy val `evaluator-shared-js` = `evaluator-shared`.js
19-
20-
lazy val scalaJSSettings = Seq(
21-
requiresDOM := false,
22-
scalaJSUseRhino := false,
23-
jsEnv := NodeJSEnv().value,
24-
libraryDependencies ++= Seq(
25-
"fr.hmil" %%% "roshttp" % v('roshttp),
26-
"org.typelevel" %%% "cats-free" % v('cats),
27-
"io.circe" %%% "circe-core" % v('circe),
28-
"io.circe" %%% "circe-generic" % v('circe),
29-
"io.circe" %%% "circe-parser" % v('circe)
30-
)
31-
)
21+
lazy val `evaluator-shared-js` = `evaluator-shared`.js
3222

3323
lazy val `evaluator-client` = (crossProject in file("client"))
3424
.dependsOn(`evaluator-shared`)
3525
.enablePlugins(AutomateHeaderPlugin)
3626
.settings(
3727
name := "evaluator-client",
3828
libraryDependencies ++= Seq(
39-
"fr.hmil" %% "roshttp" % v('roshttp),
40-
"org.typelevel" %% "cats-free" % v('cats),
41-
"io.circe" %% "circe-core" % v('circe),
42-
"io.circe" %% "circe-generic" % v('circe),
43-
"io.circe" %% "circe-parser" % v('circe),
44-
"org.log4s" %% "log4s" % v('log4s),
45-
"org.slf4j" % "slf4j-simple" % v('slf4j),
46-
// Testing libraries
47-
"org.scalatest" %% "scalatest" % v('scalaTest) % "test"
29+
%%("roshttp"),
30+
%%("cats-free"),
31+
%%("circe-core"),
32+
%%("circe-generic"),
33+
%%("circe-parser"),
34+
%%("log4s"),
35+
%("slf4j-simple"),
36+
%%("scalatest") % "test"
4837
)
49-
)
50-
.jsSettings(scalaJSSettings: _*)
38+
)
39+
.jsSettings(sharedJsSettings: _*)
5140

5241
lazy val `evaluator-client-jvm` = `evaluator-client`.jvm
53-
lazy val `evaluator-client-js` = `evaluator-client`.js
42+
lazy val `evaluator-client-js` = `evaluator-client`.js
5443

5544
lazy val `evaluator-server` = (project in file("server"))
5645
.dependsOn(`evaluator-shared-jvm`)
@@ -61,51 +50,54 @@ lazy val `evaluator-server` = (project in file("server"))
6150
.settings(
6251
name := "evaluator-server",
6352
libraryDependencies ++= Seq(
64-
"io.monix" %% "monix" % v('monix),
65-
"org.http4s" %% "http4s-dsl" % v('http4s),
66-
"org.http4s" %% "http4s-blaze-server" % v('http4s),
67-
"org.http4s" %% "http4s-blaze-client" % v('http4s),
68-
"org.http4s" %% "http4s-circe" % v('http4s),
69-
"io.circe" %% "circe-core" % v('circe),
70-
"io.circe" %% "circe-generic" % v('circe),
71-
"io.circe" %% "circe-parser" % v('circe),
72-
"com.typesafe" % "config" % v('config),
73-
"com.pauldijou" %% "jwt-core" % v('jwtcore),
74-
"org.log4s" %% "log4s" % v('log4s),
75-
"org.slf4j" % "slf4j-simple" % v('slf4j),
76-
"io.get-coursier" %% "coursier" % v('coursier),
77-
"io.get-coursier" %% "coursier-cache" % v('coursier),
78-
"org.scalatest" %% "scalatest" % v('scalaTest) % "test"
53+
%%("monix"),
54+
%%("circe-core"),
55+
%%("circe-generic"),
56+
%%("circe-parser"),
57+
%%("log4s"),
58+
%("slf4j-simple"),
59+
%%("http4s-dsl", http4sV),
60+
%%("http4s-blaze-server", http4sV),
61+
%%("http4s-blaze-client", http4sV),
62+
%%("http4s-circe", http4sV),
63+
%("config"),
64+
%%("jwt-core"),
65+
%%("coursier"),
66+
%%("coursier-cache"),
67+
%%("scalatest") % "test"
7968
),
8069
assemblyJarName in assembly := "evaluator-server.jar"
8170
)
8271
.settings(dockerSettings)
83-
.settings(compilerDependencySettings: _*)
72+
.settings(scalaMacroDependencies: _*)
8473

8574
lazy val `smoketests` = (project in file("smoketests"))
8675
.dependsOn(`evaluator-server`)
8776
.settings(
8877
name := "evaluator-server-smoke-tests",
8978
libraryDependencies ++= Seq(
90-
"org.scalatest" %% "scalatest" % v('scalaTest) % "test",
91-
"org.http4s" %% "http4s-blaze-client" % v('http4s),
92-
"org.http4s" %% "http4s-circe" % v('http4s),
93-
"io.circe" %% "circe-core" % v('circe),
94-
"io.circe" %% "circe-generic" % v('circe),
95-
"io.circe" %% "circe-parser" % v('circe),
96-
"com.pauldijou" %% "jwt-core" % v('jwtcore)
79+
%%("circe-core"),
80+
%%("circe-generic"),
81+
%%("circe-parser"),
82+
%%("http4s-blaze-client", http4sV),
83+
%%("http4s-circe", http4sV),
84+
%%("jwt-core"),
85+
%%("scalatest") % "test"
9786
)
98-
9987
)
10088

101-
onLoad in Global := (Command.process("project evaluator-server", _: State)) compose (onLoad in Global).value
102-
addCommandAlias("publishSignedAll", ";evaluator-sharedJS/publishSigned;evaluator-sharedJVM/publishSigned;evaluator-clientJS/publishSigned;evaluator-clientJVM/publishSigned")
89+
onLoad in Global := (Command
90+
.process("project evaluator-server", _: State)) compose (onLoad in Global).value
91+
addCommandAlias(
92+
"publishSignedAll",
93+
";evaluator-sharedJS/publishSigned;evaluator-sharedJVM/publishSigned;evaluator-clientJS/publishSigned;evaluator-clientJVM/publishSigned"
94+
)
10395

10496
lazy val dockerSettings = Seq(
10597
docker <<= docker dependsOn assembly,
10698
dockerfile in docker := {
10799

108-
val artifact: File = assembly.value
100+
val artifact: File = assembly.value
109101
val artifactTargetPath = artifact.name
110102

111103
sbtdocker.immutable.Dockerfile.empty
@@ -115,7 +107,8 @@ lazy val dockerSettings = Seq(
115107
.run("useradd", "-m", "evaluator")
116108
.user("evaluator")
117109
.add(artifact, artifactTargetPath)
118-
.cmdRaw(s"java -Dhttp.port=$$PORT -Deval.auth.secretKey=$$EVAL_SECRET_KEY -jar $artifactTargetPath")
110+
.cmdRaw(
111+
s"java -Dhttp.port=$$PORT -Deval.auth.secretKey=$$EVAL_SECRET_KEY -jar $artifactTargetPath")
119112
},
120113
imageNames in docker := Seq(ImageName(repository = "registry.heroku.com/scala-evaluator/web"))
121114
)

client/shared/src/main/scala/org/scalaexercises/evaluator/Decoders.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* scala-exercises-evaluator-client
2+
* scala-exercises - evaluator-client
33
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
44
*/
55

@@ -16,6 +16,5 @@ object Decoders {
1616
Decoder.forProduct2("message", "pos")(CompilationInfo.apply)
1717

1818
implicit val decodeEvalResponse: Decoder[EvalResponse] =
19-
Decoder.forProduct4("msg", "value", "valueType", "compilationInfos")(
20-
EvalResponse.apply)
19+
Decoder.forProduct4("msg", "value", "valueType", "compilationInfos")(EvalResponse.apply)
2120
}
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* scala-exercises-evaluator-client
2+
* scala-exercises - evaluator-client
33
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
44
*/
55

@@ -9,11 +9,11 @@ import cats.free.Free
99
import org.scalaexercises.evaluator.EvaluatorResponses.EvaluationResponse
1010
import org.scalaexercises.evaluator.free.algebra.EvaluatorOps
1111

12-
class EvaluatorAPI[F[_]](url: String, authKey: String)(
13-
implicit O: EvaluatorOps[F]) {
12+
class EvaluatorAPI[F[_]](url: String, authKey: String)(implicit O: EvaluatorOps[F]) {
1413

15-
def evaluates(resolvers: List[String] = Nil,
16-
dependencies: List[Dependency] = Nil,
17-
code: String): Free[F, EvaluationResponse[EvalResponse]] =
14+
def evaluates(
15+
resolvers: List[String] = Nil,
16+
dependencies: List[Dependency] = Nil,
17+
code: String): Free[F, EvaluationResponse[EvalResponse]] =
1818
O.evaluates(url, authKey, resolvers, dependencies, code)
19-
}
19+
}

client/shared/src/main/scala/org/scalaexercises/evaluator/EvaluatorClient.scala

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* scala-exercises-evaluator-client
2+
* scala-exercises - evaluator-client
33
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
44
*/
55

@@ -8,7 +8,12 @@ package org.scalaexercises.evaluator
88
import cats.data.EitherT
99
import cats.~>
1010
import cats.implicits._
11-
import org.scalaexercises.evaluator.EvaluatorResponses.{EvalIO, EvaluationException, EvaluationResponse, EvaluationResult}
11+
import org.scalaexercises.evaluator.EvaluatorResponses.{
12+
EvalIO,
13+
EvaluationException,
14+
EvaluationResponse,
15+
EvaluationResult
16+
}
1217
import org.scalaexercises.evaluator.free.algebra.EvaluatorOp
1318

1419
import scala.concurrent.Future
@@ -25,16 +30,12 @@ object EvaluatorClient {
2530
def apply(url: String, authKey: String) =
2631
new EvaluatorClient(url, authKey)
2732

28-
implicit class EvaluationIOSyntaxEither[A](
29-
evalIO: EvalIO[EvaluationResponse[A]]) {
33+
implicit class EvaluationIOSyntaxEither[A](evalIO: EvalIO[EvaluationResponse[A]]) {
3034

31-
def exec(
32-
implicit I: (EvaluatorOp ~> Future)): Future[EvaluationResponse[A]] =
35+
def exec(implicit I: (EvaluatorOp ~> Future)): Future[EvaluationResponse[A]] =
3336
evalIO foldMap I
3437

35-
def liftEvaluator: EitherT[EvalIO,
36-
EvaluationException,
37-
EvaluationResult[A]] =
38+
def liftEvaluator: EitherT[EvalIO, EvaluationException, EvaluationResult[A]] =
3839
EitherT[EvalIO, EvaluationException, EvaluationResult[A]](evalIO)
3940

4041
}

client/shared/src/main/scala/org/scalaexercises/evaluator/EvaluatorResponses.scala

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
/*
2-
* scala-exercises-evaluator-client
2+
* scala-exercises - evaluator-client
33
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
44
*/
55

66
package org.scalaexercises.evaluator
77

8-
import cats.data.Xor
98
import cats.free.Free
109
import cats.implicits._
1110
import io.circe.Decoder
1211
import io.circe.parser._
13-
import io.circe.generic.auto._
1412
import org.scalaexercises.evaluator.free.algebra.EvaluatorOp
1513

1614
import scala.concurrent.Future
@@ -24,31 +22,26 @@ object EvaluatorResponses {
2422

2523
type EvaluationResponse[A] = Either[EvaluationException, EvaluationResult[A]]
2624

27-
case class EvaluationResult[A](result: A,
28-
statusCode: Int,
29-
headers: Map[String, String])
25+
case class EvaluationResult[A](result: A, statusCode: Int, headers: Map[String, String])
3026

31-
sealed abstract class EvaluationException(msg: String,
32-
cause: Option[Throwable] = None)
27+
sealed abstract class EvaluationException(msg: String, cause: Option[Throwable] = None)
3328
extends Throwable(msg) {
3429
cause foreach initCause
3530
}
3631

37-
case class JsonParsingException(msg: String, json: String)
38-
extends EvaluationException(msg)
32+
case class JsonParsingException(msg: String, json: String) extends EvaluationException(msg)
3933

4034
case class UnexpectedException(msg: String) extends EvaluationException(msg)
4135

4236
def toEntity[A](futureResponse: Future[SimpleHttpResponse])(
43-
implicit D: Decoder[A]): Future[EvaluationResponse[A]] =
37+
implicit D: Decoder[A]): Future[EvaluationResponse[A]] =
4438
futureResponse map {
4539
case r if isSuccess(r.statusCode)
4640
decode[A](r.body) match {
47-
case Xor.Left(e) =>
41+
case Left(e) =>
4842
Either.left(JsonParsingException(e.getMessage, r.body))
49-
case Xor.Right(result) =>
50-
Either.right(
51-
EvaluationResult(result, r.statusCode, r.headers.toLowerCase))
43+
case Right(result) =>
44+
Either.right(EvaluationResult(result, r.statusCode, r.headers.toLowerCase))
5245
}
5346
case r
5447
Either.left(

client/shared/src/main/scala/org/scalaexercises/evaluator/api/Evaluator.scala

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* scala-exercises-evaluator-client
2+
* scala-exercises - evaluator-client
33
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
44
*/
55

@@ -19,11 +19,12 @@ class Evaluator {
1919

2020
private val httpClient = new HttpClient
2121

22-
def eval(url: String,
23-
authKey: String,
24-
resolvers: List[String] = Nil,
25-
dependencies: List[Dependency] = Nil,
26-
code: String): Future[EvaluationResponse[EvalResponse]] =
22+
def eval(
23+
url: String,
24+
authKey: String,
25+
resolvers: List[String] = Nil,
26+
dependencies: List[Dependency] = Nil,
27+
code: String): Future[EvaluationResponse[EvalResponse]] =
2728
httpClient.post[EvalResponse](
2829
url = url,
2930
secretKey = authKey,

0 commit comments

Comments
 (0)