Skip to content

sbt-org-policies Plugin Integration #51

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

Merged
merged 11 commits into from
Apr 5, 2017
5 changes: 0 additions & 5 deletions .scalafmt

This file was deleted.

23 changes: 23 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
style = defaultWithAlign
maxColumn = 100

continuationIndent.callSite = 2

newlines {
sometimesBeforeColonInMethodReturnType = false
}

align {
arrowEnumeratorGenerator = false
ifWhileOpenParen = false
openParenCallSite = false
openParenDefnSite = false
}

docstrings = JavaDoc

rewrite {
rules = [SortImports, RedundantBraces]
redundantBraces.maxLines = 1
}

14 changes: 11 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ services:
- docker
scala:
- 2.11.8
- 2.12.1
jdk:
- oraclejdk8
cache:
Expand All @@ -14,21 +15,28 @@ cache:
env:
global: JAVA_OPTS=-Xmx2g SBT_OPTS="-XX:+UseConcMarkSweepGC -XX:MaxPermSize=512m"
script:
- sbt test
- sbt ++$TRAVIS_SCALA_VERSION test

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

after_success:
- if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then
- if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" -a "$TRAVIS_SCALA_VERSION" = "2.11.8" ]; then
sbt publishSignedAll;
echo "Deploying to Heroku";
docker login [email protected] --password=$heroku_token registry.heroku.com;
sbt dockerBuildAndPush;
sbt smoketests/test;
fi
- if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" -a "$TRAVIS_SCALA_VERSION" = "2.12.1" ]; then
sbt -Devaluator.heroku.name=scala-evaluator-212 publishSignedAll;
echo "Deploying to Heroku";
docker login [email protected] --password=$heroku_token registry.heroku.com;
sbt -Devaluator.heroku.name=scala-evaluator-212 dockerBuildAndPush;
sbt smoketests/test;
fi
- if [ "$TRAVIS_PULL_REQUEST" = "true" ]; then
echo "Not in master branch, skipping deploy and release";
fi
fi
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,14 @@ Evaluating code that may result in a thrown exception
```


# License

Copyright (C) 2015-2016 47 Degrees, LLC. Reactive, scalable software solutions. http://47deg.com [email protected]

Some parts of the code have been taken from twitter-eval, and slightly adapted to the evaluator needs. Copyright 2010 Twitter, Inc.

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.
133 changes: 55 additions & 78 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,121 +1,98 @@
lazy val noPublishSettings = Seq(
publish := (),
publishLocal := (),
publishArtifact := false
)

lazy val root = (project in file("."))
.settings(mainClass in Universal := Some("org.scalaexercises.evaluator.EvaluatorServer"))
.settings(stage <<= (stage in Universal in `evaluator-server`))
.settings(noPublishSettings: _*)
.aggregate(`evaluator-server`, `evaluator-shared-jvm`, `evaluator-shared-js`, `evaluator-client-jvm`, `evaluator-client-js`)
.aggregate(
`evaluator-server`,
`evaluator-shared-jvm`,
`evaluator-shared-js`,
`evaluator-client-jvm`,
`evaluator-client-js`)

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

lazy val `evaluator-shared-jvm` = `evaluator-shared`.jvm
lazy val `evaluator-shared-js` = `evaluator-shared`.js

lazy val scalaJSSettings = Seq(
requiresDOM := false,
scalaJSUseRhino := false,
jsEnv := NodeJSEnv().value,
libraryDependencies ++= Seq(
"fr.hmil" %%% "roshttp" % v('roshttp),
"org.typelevel" %%% "cats-free" % v('cats),
"io.circe" %%% "circe-core" % v('circe),
"io.circe" %%% "circe-generic" % v('circe),
"io.circe" %%% "circe-parser" % v('circe)
)
)
lazy val `evaluator-shared-js` = `evaluator-shared`.js

lazy val `evaluator-client` = (crossProject in file("client"))
.dependsOn(`evaluator-shared`)
.enablePlugins(AutomateHeaderPlugin)
.settings(
name := "evaluator-client",
libraryDependencies ++= Seq(
"fr.hmil" %% "roshttp" % v('roshttp),
"org.typelevel" %% "cats-free" % v('cats),
"io.circe" %% "circe-core" % v('circe),
"io.circe" %% "circe-generic" % v('circe),
"io.circe" %% "circe-parser" % v('circe),
"org.log4s" %% "log4s" % v('log4s),
"org.slf4j" % "slf4j-simple" % v('slf4j),
// Testing libraries
"org.scalatest" %% "scalatest" % v('scalaTest) % "test"
%%("roshttp"),
%%("cats-free"),
%%("circe-core"),
%%("circe-generic"),
%%("circe-parser"),
%%("log4s"),
%("slf4j-simple"),
%%("scalatest") % "test"
)
)
.jsSettings(scalaJSSettings: _*)
)
.jsSettings(sharedJsSettings: _*)

lazy val `evaluator-client-jvm` = `evaluator-client`.jvm
lazy val `evaluator-client-js` = `evaluator-client`.js
lazy val `evaluator-client-js` = `evaluator-client`.js

lazy val `evaluator-server` = (project in file("server"))
.dependsOn(`evaluator-shared-jvm`)
.enablePlugins(JavaAppPackaging)
.enablePlugins(AutomateHeaderPlugin)
.enablePlugins(sbtdocker.DockerPlugin)
.enablePlugins(BuildInfoPlugin)
.settings(noPublishSettings: _*)
.settings(
name := "evaluator-server",
libraryDependencies ++= Seq(
"io.monix" %% "monix" % v('monix),
"org.http4s" %% "http4s-dsl" % v('http4s),
"org.http4s" %% "http4s-blaze-server" % v('http4s),
"org.http4s" %% "http4s-blaze-client" % v('http4s),
"org.http4s" %% "http4s-circe" % v('http4s),
"io.circe" %% "circe-core" % v('circe),
"io.circe" %% "circe-generic" % v('circe),
"io.circe" %% "circe-parser" % v('circe),
"com.typesafe" % "config" % v('config),
"com.pauldijou" %% "jwt-core" % v('jwtcore),
"org.log4s" %% "log4s" % v('log4s),
"org.slf4j" % "slf4j-simple" % v('slf4j),
"io.get-coursier" %% "coursier" % v('coursier),
"io.get-coursier" %% "coursier-cache" % v('coursier),
"org.scalatest" %% "scalatest" % v('scalaTest) % "test"
%%("monix"),
%%("circe-core"),
%%("circe-generic"),
%%("circe-parser"),
%%("log4s"),
%("slf4j-simple"),
%%("http4s-dsl", http4sV),
%%("http4s-blaze-server", http4sV),
%%("http4s-blaze-client", http4sV),
%%("http4s-circe", http4sV),
%("config"),
%%("jwt-core"),
"io.get-coursier" %% "coursier" % "1.0.0-M15-3",
"io.get-coursier" %% "coursier-cache" % "1.0.0-M15-3",
%%("scalatest") % "test"
),
assemblyJarName in assembly := "evaluator-server.jar"
assemblyJarName in assembly := "evaluator-server.jar",
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion),
buildInfoPackage := "org.scalaexercises.evaluator"
)
.settings(dockerSettings)
.settings(compilerDependencySettings: _*)
.settings(scalaMacroDependencies: _*)

lazy val `smoketests` = (project in file("smoketests"))
.dependsOn(`evaluator-server`)
.settings(noPublishSettings: _*)
.settings(
name := "evaluator-server-smoke-tests",
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % v('scalaTest) % "test",
"org.http4s" %% "http4s-blaze-client" % v('http4s),
"org.http4s" %% "http4s-circe" % v('http4s),
"io.circe" %% "circe-core" % v('circe),
"io.circe" %% "circe-generic" % v('circe),
"io.circe" %% "circe-parser" % v('circe),
"com.pauldijou" %% "jwt-core" % v('jwtcore)
%%("circe-core"),
%%("circe-generic"),
%%("circe-parser"),
%%("http4s-blaze-client", http4sV),
%%("http4s-circe", http4sV),
%%("jwt-core"),
%%("scalatest") % "test"
)

)

onLoad in Global := (Command.process("project evaluator-server", _: State)) compose (onLoad in Global).value
addCommandAlias("publishSignedAll", ";evaluator-sharedJS/publishSigned;evaluator-sharedJVM/publishSigned;evaluator-clientJS/publishSigned;evaluator-clientJVM/publishSigned")

lazy val dockerSettings = Seq(
docker <<= docker dependsOn assembly,
dockerfile in docker := {

val artifact: File = assembly.value
val artifactTargetPath = artifact.name

sbtdocker.immutable.Dockerfile.empty
.from("ubuntu:latest")
.run("apt-get", "update")
.run("apt-get", "install", "-y", "openjdk-8-jdk")
.run("useradd", "-m", "evaluator")
.user("evaluator")
.add(artifact, artifactTargetPath)
.cmdRaw(s"java -Dhttp.port=$$PORT -Deval.auth.secretKey=$$EVAL_SECRET_KEY -jar $artifactTargetPath")
},
imageNames in docker := Seq(ImageName(repository = "registry.heroku.com/scala-evaluator/web"))
onLoad in Global := (Command
.process("project evaluator-server", _: State)) compose (onLoad in Global).value
addCommandAlias(
"publishSignedAll",
";evaluator-sharedJS/publishSigned;evaluator-sharedJVM/publishSigned;evaluator-clientJS/publishSigned;evaluator-clientJVM/publishSigned"
)

pgpPassphrase := Some(getEnvVar("PGP_PASSPHRASE").getOrElse("").toCharArray)
pgpPublicRing := file(s"$gpgFolder/pubring.gpg")
pgpSecretRing := file(s"$gpgFolder/secring.gpg")
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* scala-exercises-evaluator-client
* scala-exercises - evaluator-client
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
*/

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

implicit val decodeEvalResponse: Decoder[EvalResponse] =
Decoder.forProduct4("msg", "value", "valueType", "compilationInfos")(
EvalResponse.apply)
Decoder.forProduct4("msg", "value", "valueType", "compilationInfos")(EvalResponse.apply)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* scala-exercises-evaluator-client
* scala-exercises - evaluator-client
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
*/

Expand All @@ -9,11 +9,11 @@ import cats.free.Free
import org.scalaexercises.evaluator.EvaluatorResponses.EvaluationResponse
import org.scalaexercises.evaluator.free.algebra.EvaluatorOps

class EvaluatorAPI[F[_]](url: String, authKey: String)(
implicit O: EvaluatorOps[F]) {
class EvaluatorAPI[F[_]](url: String, authKey: String)(implicit O: EvaluatorOps[F]) {

def evaluates(resolvers: List[String] = Nil,
dependencies: List[Dependency] = Nil,
code: String): Free[F, EvaluationResponse[EvalResponse]] =
def evaluates(
resolvers: List[String] = Nil,
dependencies: List[Dependency] = Nil,
code: String): Free[F, EvaluationResponse[EvalResponse]] =
O.evaluates(url, authKey, resolvers, dependencies, code)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* scala-exercises-evaluator-client
* scala-exercises - evaluator-client
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
*/

Expand All @@ -8,7 +8,12 @@ package org.scalaexercises.evaluator
import cats.data.EitherT
import cats.~>
import cats.implicits._
import org.scalaexercises.evaluator.EvaluatorResponses.{EvalIO, EvaluationException, EvaluationResponse, EvaluationResult}
import org.scalaexercises.evaluator.EvaluatorResponses.{
EvalIO,
EvaluationException,
EvaluationResponse,
EvaluationResult
}
import org.scalaexercises.evaluator.free.algebra.EvaluatorOp

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

implicit class EvaluationIOSyntaxEither[A](
evalIO: EvalIO[EvaluationResponse[A]]) {
implicit class EvaluationIOSyntaxEither[A](evalIO: EvalIO[EvaluationResponse[A]]) {

def exec(
implicit I: (EvaluatorOp ~> Future)): Future[EvaluationResponse[A]] =
def exec(implicit I: (EvaluatorOp ~> Future)): Future[EvaluationResponse[A]] =
evalIO foldMap I

def liftEvaluator: EitherT[EvalIO,
EvaluationException,
EvaluationResult[A]] =
def liftEvaluator: EitherT[EvalIO, EvaluationException, EvaluationResult[A]] =
EitherT[EvalIO, EvaluationException, EvaluationResult[A]](evalIO)

}
Expand Down
Loading