Skip to content

Commit 4c36ecc

Browse files
Merge pull request #52 from scala-exercises/revert-51-sbt-org-policies-integration-2nd-attempt
Revert "sbt-org-policies Plugin Integration"
2 parents 47ebeca + e16c854 commit 4c36ecc

File tree

27 files changed

+532
-655
lines changed

27 files changed

+532
-655
lines changed

.scalafmt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
--style defaultWithAlign
2+
--maxColumn 80
3+
--continuationIndentCallSite 2
4+
--continuationIndentDefnSite 2
5+
--alignByOpenParenCallSite false

.scalafmt.conf

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

.travis.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ services:
44
- docker
55
scala:
66
- 2.11.8
7-
- 2.12.1
87
jdk:
98
- oraclejdk8
109
cache:
@@ -15,28 +14,21 @@ cache:
1514
env:
1615
global: JAVA_OPTS=-Xmx2g SBT_OPTS="-XX:+UseConcMarkSweepGC -XX:MaxPermSize=512m"
1716
script:
18-
- sbt ++$TRAVIS_SCALA_VERSION test
17+
- sbt test
1918

2019
before_install:
2120
- if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then
2221
openssl aes-256-cbc -K $encrypted_98b97a2f355e_key -iv $encrypted_98b97a2f355e_iv -in secring.gpg.enc -out secring.gpg -d;
2322
fi
2423

2524
after_success:
26-
- if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" -a "$TRAVIS_SCALA_VERSION" = "2.11.8" ]; then
25+
- if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then
2726
sbt publishSignedAll;
2827
echo "Deploying to Heroku";
2928
docker login [email protected] --password=$heroku_token registry.heroku.com;
3029
sbt dockerBuildAndPush;
3130
sbt smoketests/test;
3231
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
4032
- if [ "$TRAVIS_PULL_REQUEST" = "true" ]; then
4133
echo "Not in master branch, skipping deploy and release";
42-
fi
34+
fi

README.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,3 @@ 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: 78 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,121 @@
1+
lazy val noPublishSettings = Seq(
2+
publish := (),
3+
publishLocal := (),
4+
publishArtifact := false
5+
)
6+
17
lazy val root = (project in file("."))
28
.settings(mainClass in Universal := Some("org.scalaexercises.evaluator.EvaluatorServer"))
39
.settings(stage <<= (stage in Universal in `evaluator-server`))
410
.settings(noPublishSettings: _*)
5-
.aggregate(
6-
`evaluator-server`,
7-
`evaluator-shared-jvm`,
8-
`evaluator-shared-js`,
9-
`evaluator-client-jvm`,
10-
`evaluator-client-js`)
11+
.aggregate(`evaluator-server`, `evaluator-shared-jvm`, `evaluator-shared-js`, `evaluator-client-jvm`, `evaluator-client-js`)
1112

1213
lazy val `evaluator-shared` = (crossProject in file("shared"))
1314
.enablePlugins(AutomateHeaderPlugin)
1415
.settings(name := "evaluator-shared")
1516

1617
lazy val `evaluator-shared-jvm` = `evaluator-shared`.jvm
17-
lazy val `evaluator-shared-js` = `evaluator-shared`.js
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+
)
1832

1933
lazy val `evaluator-client` = (crossProject in file("client"))
2034
.dependsOn(`evaluator-shared`)
2135
.enablePlugins(AutomateHeaderPlugin)
2236
.settings(
2337
name := "evaluator-client",
2438
libraryDependencies ++= Seq(
25-
%%("roshttp"),
26-
%%("cats-free"),
27-
%%("circe-core"),
28-
%%("circe-generic"),
29-
%%("circe-parser"),
30-
%%("log4s"),
31-
%("slf4j-simple"),
32-
%%("scalatest") % "test"
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"
3348
)
34-
)
35-
.jsSettings(sharedJsSettings: _*)
49+
)
50+
.jsSettings(scalaJSSettings: _*)
3651

3752
lazy val `evaluator-client-jvm` = `evaluator-client`.jvm
38-
lazy val `evaluator-client-js` = `evaluator-client`.js
53+
lazy val `evaluator-client-js` = `evaluator-client`.js
3954

4055
lazy val `evaluator-server` = (project in file("server"))
4156
.dependsOn(`evaluator-shared-jvm`)
4257
.enablePlugins(JavaAppPackaging)
4358
.enablePlugins(AutomateHeaderPlugin)
4459
.enablePlugins(sbtdocker.DockerPlugin)
45-
.enablePlugins(BuildInfoPlugin)
4660
.settings(noPublishSettings: _*)
4761
.settings(
4862
name := "evaluator-server",
4963
libraryDependencies ++= Seq(
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"
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"
6579
),
66-
assemblyJarName in assembly := "evaluator-server.jar",
67-
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion),
68-
buildInfoPackage := "org.scalaexercises.evaluator"
80+
assemblyJarName in assembly := "evaluator-server.jar"
6981
)
7082
.settings(dockerSettings)
71-
.settings(scalaMacroDependencies: _*)
83+
.settings(compilerDependencySettings: _*)
7284

7385
lazy val `smoketests` = (project in file("smoketests"))
7486
.dependsOn(`evaluator-server`)
75-
.settings(noPublishSettings: _*)
7687
.settings(
7788
name := "evaluator-server-smoke-tests",
7889
libraryDependencies ++= Seq(
79-
%%("circe-core"),
80-
%%("circe-generic"),
81-
%%("circe-parser"),
82-
%%("http4s-blaze-client", http4sV),
83-
%%("http4s-circe", http4sV),
84-
%%("jwt-core"),
85-
%%("scalatest") % "test"
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)
8697
)
98+
8799
)
88100

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-
)
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")
95103

96-
pgpPassphrase := Some(getEnvVar("PGP_PASSPHRASE").getOrElse("").toCharArray)
97-
pgpPublicRing := file(s"$gpgFolder/pubring.gpg")
98-
pgpSecretRing := file(s"$gpgFolder/secring.gpg")
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"))
121+
)

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

Lines changed: 3 additions & 2 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,5 +16,6 @@ object Decoders {
1616
Decoder.forProduct2("message", "pos")(CompilationInfo.apply)
1717

1818
implicit val decodeEvalResponse: Decoder[EvalResponse] =
19-
Decoder.forProduct4("msg", "value", "valueType", "compilationInfos")(EvalResponse.apply)
19+
Decoder.forProduct4("msg", "value", "valueType", "compilationInfos")(
20+
EvalResponse.apply)
2021
}
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)(implicit O: EvaluatorOps[F]) {
12+
class EvaluatorAPI[F[_]](url: String, authKey: String)(
13+
implicit O: EvaluatorOps[F]) {
1314

14-
def evaluates(
15-
resolvers: List[String] = Nil,
16-
dependencies: List[Dependency] = Nil,
17-
code: String): Free[F, EvaluationResponse[EvalResponse]] =
15+
def evaluates(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: 9 additions & 10 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,12 +8,7 @@ package org.scalaexercises.evaluator
88
import cats.data.EitherT
99
import cats.~>
1010
import cats.implicits._
11-
import org.scalaexercises.evaluator.EvaluatorResponses.{
12-
EvalIO,
13-
EvaluationException,
14-
EvaluationResponse,
15-
EvaluationResult
16-
}
11+
import org.scalaexercises.evaluator.EvaluatorResponses.{EvalIO, EvaluationException, EvaluationResponse, EvaluationResult}
1712
import org.scalaexercises.evaluator.free.algebra.EvaluatorOp
1813

1914
import scala.concurrent.Future
@@ -30,12 +25,16 @@ object EvaluatorClient {
3025
def apply(url: String, authKey: String) =
3126
new EvaluatorClient(url, authKey)
3227

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

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

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

4140
}

0 commit comments

Comments
 (0)