Skip to content

Commit 47ebeca

Browse files
Merge pull request #51 from scala-exercises/sbt-org-policies-integration-2nd-attempt
sbt-org-policies Plugin Integration
2 parents 06cf74e + fa47114 commit 47ebeca

File tree

27 files changed

+655
-532
lines changed

27 files changed

+655
-532
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+

.travis.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ services:
44
- docker
55
scala:
66
- 2.11.8
7+
- 2.12.1
78
jdk:
89
- oraclejdk8
910
cache:
@@ -14,21 +15,28 @@ cache:
1415
env:
1516
global: JAVA_OPTS=-Xmx2g SBT_OPTS="-XX:+UseConcMarkSweepGC -XX:MaxPermSize=512m"
1617
script:
17-
- sbt test
18+
- sbt ++$TRAVIS_SCALA_VERSION test
1819

1920
before_install:
2021
- if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then
2122
openssl aes-256-cbc -K $encrypted_98b97a2f355e_key -iv $encrypted_98b97a2f355e_iv -in secring.gpg.enc -out secring.gpg -d;
2223
fi
2324

2425
after_success:
25-
- if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then
26+
- if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" -a "$TRAVIS_SCALA_VERSION" = "2.11.8" ]; then
2627
sbt publishSignedAll;
2728
echo "Deploying to Heroku";
2829
docker login [email protected] --password=$heroku_token registry.heroku.com;
2930
sbt dockerBuildAndPush;
3031
sbt smoketests/test;
3132
fi
33+
- if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" -a "$TRAVIS_SCALA_VERSION" = "2.12.1" ]; then
34+
sbt -Devaluator.heroku.name=scala-evaluator-212 publishSignedAll;
35+
echo "Deploying to Heroku";
36+
docker login [email protected] --password=$heroku_token registry.heroku.com;
37+
sbt -Devaluator.heroku.name=scala-evaluator-212 dockerBuildAndPush;
38+
sbt smoketests/test;
39+
fi
3240
- if [ "$TRAVIS_PULL_REQUEST" = "true" ]; then
3341
echo "Not in master branch, skipping deploy and release";
34-
fi
42+
fi

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,14 @@ Evaluating code that may result in a thrown exception
153153
```
154154

155155

156+
# License
157+
158+
Copyright (C) 2015-2016 47 Degrees, LLC. Reactive, scalable software solutions. http://47deg.com [email protected]
159+
160+
Some parts of the code have been taken from twitter-eval, and slightly adapted to the evaluator needs. Copyright 2010 Twitter, Inc.
161+
162+
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
163+
164+
http://www.apache.org/licenses/LICENSE-2.0
165+
166+
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.

build.sbt

Lines changed: 55 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,98 @@
1-
lazy val noPublishSettings = Seq(
2-
publish := (),
3-
publishLocal := (),
4-
publishArtifact := false
5-
)
6-
71
lazy val root = (project in file("."))
82
.settings(mainClass in Universal := Some("org.scalaexercises.evaluator.EvaluatorServer"))
93
.settings(stage <<= (stage in Universal in `evaluator-server`))
104
.settings(noPublishSettings: _*)
11-
.aggregate(`evaluator-server`, `evaluator-shared-jvm`, `evaluator-shared-js`, `evaluator-client-jvm`, `evaluator-client-js`)
5+
.aggregate(
6+
`evaluator-server`,
7+
`evaluator-shared-jvm`,
8+
`evaluator-shared-js`,
9+
`evaluator-client-jvm`,
10+
`evaluator-client-js`)
1211

1312
lazy val `evaluator-shared` = (crossProject in file("shared"))
1413
.enablePlugins(AutomateHeaderPlugin)
1514
.settings(name := "evaluator-shared")
1615

1716
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-
)
17+
lazy val `evaluator-shared-js` = `evaluator-shared`.js
3218

3319
lazy val `evaluator-client` = (crossProject in file("client"))
3420
.dependsOn(`evaluator-shared`)
3521
.enablePlugins(AutomateHeaderPlugin)
3622
.settings(
3723
name := "evaluator-client",
3824
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"
25+
%%("roshttp"),
26+
%%("cats-free"),
27+
%%("circe-core"),
28+
%%("circe-generic"),
29+
%%("circe-parser"),
30+
%%("log4s"),
31+
%("slf4j-simple"),
32+
%%("scalatest") % "test"
4833
)
49-
)
50-
.jsSettings(scalaJSSettings: _*)
34+
)
35+
.jsSettings(sharedJsSettings: _*)
5136

5237
lazy val `evaluator-client-jvm` = `evaluator-client`.jvm
53-
lazy val `evaluator-client-js` = `evaluator-client`.js
38+
lazy val `evaluator-client-js` = `evaluator-client`.js
5439

5540
lazy val `evaluator-server` = (project in file("server"))
5641
.dependsOn(`evaluator-shared-jvm`)
5742
.enablePlugins(JavaAppPackaging)
5843
.enablePlugins(AutomateHeaderPlugin)
5944
.enablePlugins(sbtdocker.DockerPlugin)
45+
.enablePlugins(BuildInfoPlugin)
6046
.settings(noPublishSettings: _*)
6147
.settings(
6248
name := "evaluator-server",
6349
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"
50+
%%("monix"),
51+
%%("circe-core"),
52+
%%("circe-generic"),
53+
%%("circe-parser"),
54+
%%("log4s"),
55+
%("slf4j-simple"),
56+
%%("http4s-dsl", http4sV),
57+
%%("http4s-blaze-server", http4sV),
58+
%%("http4s-blaze-client", http4sV),
59+
%%("http4s-circe", http4sV),
60+
%("config"),
61+
%%("jwt-core"),
62+
"io.get-coursier" %% "coursier" % "1.0.0-M15-3",
63+
"io.get-coursier" %% "coursier-cache" % "1.0.0-M15-3",
64+
%%("scalatest") % "test"
7965
),
80-
assemblyJarName in assembly := "evaluator-server.jar"
66+
assemblyJarName in assembly := "evaluator-server.jar",
67+
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion),
68+
buildInfoPackage := "org.scalaexercises.evaluator"
8169
)
8270
.settings(dockerSettings)
83-
.settings(compilerDependencySettings: _*)
71+
.settings(scalaMacroDependencies: _*)
8472

8573
lazy val `smoketests` = (project in file("smoketests"))
8674
.dependsOn(`evaluator-server`)
75+
.settings(noPublishSettings: _*)
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")
103-
104-
lazy val dockerSettings = Seq(
105-
docker <<= docker dependsOn assembly,
106-
dockerfile in docker := {
107-
108-
val artifact: File = assembly.value
109-
val artifactTargetPath = artifact.name
110-
111-
sbtdocker.immutable.Dockerfile.empty
112-
.from("ubuntu:latest")
113-
.run("apt-get", "update")
114-
.run("apt-get", "install", "-y", "openjdk-8-jdk")
115-
.run("useradd", "-m", "evaluator")
116-
.user("evaluator")
117-
.add(artifact, artifactTargetPath)
118-
.cmdRaw(s"java -Dhttp.port=$$PORT -Deval.auth.secretKey=$$EVAL_SECRET_KEY -jar $artifactTargetPath")
119-
},
120-
imageNames in docker := Seq(ImageName(repository = "registry.heroku.com/scala-evaluator/web"))
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"
12194
)
95+
96+
pgpPassphrase := Some(getEnvVar("PGP_PASSPHRASE").getOrElse("").toCharArray)
97+
pgpPublicRing := file(s"$gpgFolder/pubring.gpg")
98+
pgpSecretRing := file(s"$gpgFolder/secring.gpg")

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
}

0 commit comments

Comments
 (0)