diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9b96383e..e30e783d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,7 +11,7 @@ the code. Pull requests are also welcome. People are expected to follow the [Code of Conduct](CODE_OF_CONDUCT.md) when discussing _evaluator_ on the Github page or other venues. -If you are being harassed, please contact one of [us](AUTHORS.md#maintainers) immediately so that we can support you. In case you cannot get in touch with us please write an email to [47 Degrees](mailto:scala-exercises@47deg.com). +If you are being harassed, please contact one of [us](AUTHORS.md#maintainers) immediately so that we can support you. In case you cannot get in touch with us please write an email to [47 Degrees Open Source](mailto:hello@47deg.com). ## How can I help? diff --git a/LICENSE.md b/LICENSE.md index fef1c3a0..c21be17b 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright (C) 2016-2020 47 Degrees + Copyright (C) 2016-2020 47 Degrees Open Source Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/NOTICE.md b/NOTICE.md index 5fd14c12..a90085a1 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -4,6 +4,6 @@ evaluator -Copyright (c) 2016-2020 47 Degrees. All rights reserved. +Copyright (c) 2016-2020 47 Degrees Open Source. All rights reserved. Licensed under Apache-2.0. See [LICENSE](LICENSE.md) for terms. \ No newline at end of file diff --git a/build.sbt b/build.sbt index 71df837e..18811668 100644 --- a/build.sbt +++ b/build.sbt @@ -1,7 +1,16 @@ -addCommandAlias("ci-test", "scalafmtCheckAll; scalafmtSbtCheck; test") -addCommandAlias("ci-docs", "github; project-docs/mdoc; headerCreateAll") +ThisBuild / organization := "org.scala-exercises" +ThisBuild / githubOrganization := "47degrees" +ThisBuild / scalaVersion := V.scala Universal / javaOptions += "-Dscala.classpath.closeZip=true" +Universal / mainClass := Some("org.scalaexercises.evaluator.EvaluatorServer") + +stage := (stage in Universal in `evaluator-server`).value +skip in publish := true + +addCommandAlias("ci-test", "scalafmtCheckAll; scalafmtSbtCheck; test") +addCommandAlias("ci-docs", "github; mdoc; headerCreateAll") +addCommandAlias("ci-publish", "github; ci-release") lazy val `evaluator-server` = (project in file("server")) .enablePlugins(JavaAppPackaging) @@ -17,27 +26,7 @@ lazy val `evaluator-server` = (project in file("server")) .settings(buildInfoSettings: _*) .settings(serverScalaMacroDependencies: _*) -lazy val smoketests = (project in file("smoketests")) - .dependsOn(`evaluator-server`) - .enablePlugins(BuildInfoPlugin) - .settings(skip in publish := true) - .settings( - name := "evaluator-server-smoke-tests", - serverHttpDependencies - ) - .settings(buildInfoSettings: _*) - -lazy val root = (project in file(".")) - .settings(mainClass in Universal := Some("org.scalaexercises.evaluator.EvaluatorServer")) - .settings(stage := (stage in Universal in `evaluator-server`).value) - .settings(skip in publish := true) - .aggregate(`evaluator-server`) - .dependsOn(`evaluator-server`) - -lazy val `project-docs` = (project in file(".docs")) - .aggregate(`evaluator-server`, smoketests) - .settings(moduleName := "evaluator-project-docs") - .settings(mdocIn := file(".docs")) +lazy val documentation = project .settings(mdocOut := file(".")) - .settings(skip in publish := true) + .settings(publish / skip := true) .enablePlugins(MdocPlugin) diff --git a/.docs/AUTHORS.md b/docs/AUTHORS.md similarity index 100% rename from .docs/AUTHORS.md rename to docs/AUTHORS.md diff --git a/.docs/CODE_OF_CONDUCT.md b/docs/CODE_OF_CONDUCT.md similarity index 100% rename from .docs/CODE_OF_CONDUCT.md rename to docs/CODE_OF_CONDUCT.md diff --git a/.docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md similarity index 100% rename from .docs/CONTRIBUTING.md rename to docs/CONTRIBUTING.md diff --git a/.docs/LICENSE.md b/docs/LICENSE.md similarity index 100% rename from .docs/LICENSE.md rename to docs/LICENSE.md diff --git a/.docs/NOTICE.md b/docs/NOTICE.md similarity index 100% rename from .docs/NOTICE.md rename to docs/NOTICE.md diff --git a/project/ProjectPlugin.scala b/project/ProjectPlugin.scala index 88cfdad3..21d9b6dd 100644 --- a/project/ProjectPlugin.scala +++ b/project/ProjectPlugin.scala @@ -1,5 +1,3 @@ -import de.heikoseeberger.sbtheader.HeaderPlugin -import de.heikoseeberger.sbtheader.HeaderPlugin.autoImport._ import sbt.Keys._ import sbt._ import sbtassembly.AssemblyPlugin.autoImport.assembly @@ -17,19 +15,19 @@ object ProjectPlugin extends AutoPlugin { object autoImport { object V { - lazy val cats = "2.1.0" + lazy val cats = "2.1.1" lazy val catsEffect = "2.1.3" - lazy val http4s = "0.21.3" + lazy val http4s = "0.21.4" lazy val circe = "0.13.0" lazy val log4s = "1.7.0" lazy val scalatest = "3.1.2" - lazy val scalatestplusScheck = "3.1.1.1" + lazy val scalatestplusScheck = "3.1.2.0" lazy val jodaTime = "2.10.6" lazy val slf4j = "1.7.30" lazy val jwtCore = "4.3.0" - lazy val coursier = "2.0.0-RC6-12" + lazy val coursier = "2.0.0-RC6-21" lazy val config = "1.4.0" - lazy val scala = "2.13.1" + lazy val scala = "2.13.2" } lazy val dockerSettings = Seq( @@ -92,15 +90,8 @@ object ProjectPlugin extends AutoPlugin { } - import autoImport._ - override def projectSettings: Seq[Def.Setting[_]] = Seq( - name := "evaluator", - description := "Scala Exercises: The path to enlightenment", - organization := "org.scala-exercises", - organizationName := "47 Degrees", - organizationHomepage := Some(url("https://47deg.com")), scmInfo := Some( ScmInfo( url("https://github.com/scala-exercises/evaluator"), @@ -108,8 +99,6 @@ object ProjectPlugin extends AutoPlugin { Some("scm:git:git@github.com:scala-exercises/evaluator.git") ) ), - scalaVersion := V.scala, - crossScalaVersions := Seq(V.scala), scalacOptions ~= (_ filterNot (_ == "-Xfuture")), scalacOptions += "-Ymacro-annotations", javacOptions ++= Seq("-encoding", "UTF-8", "-Xlint:-options"), diff --git a/project/build.properties b/project/build.properties index 2cc552f5..0caa33f3 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.3.11 \ No newline at end of file +sbt.version=1.3.12 \ No newline at end of file diff --git a/project/plugins.sbt b/project/plugins.sbt index 0fe73206..859dcf3d 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,12 +1,12 @@ -addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.7.1") -addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10") -addSbtPlugin("se.marcuslonnberg" % "sbt-docker" % "1.5.0") -addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0") -addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.3") -addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.3.4") -addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.1.5") -addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0") -addSbtPlugin("com.alejandrohdezma" %% "sbt-github" % "0.8.1") -addSbtPlugin("com.alejandrohdezma" % "sbt-github-header" % "0.8.1") -addSbtPlugin("com.alejandrohdezma" % "sbt-github-mdoc" % "0.8.1") -addSbtPlugin("com.alejandrohdezma" % "sbt-mdoc-toc" % "0.2") +addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.7.1") +addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10") +addSbtPlugin("se.marcuslonnberg" % "sbt-docker" % "1.5.0") +addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0") +addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.3") +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.0") +addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.1.5") +addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0") +addSbtPlugin("com.alejandrohdezma" %% "sbt-github" % "0.8.2") +addSbtPlugin("com.alejandrohdezma" % "sbt-github-header" % "0.8.2") +addSbtPlugin("com.alejandrohdezma" % "sbt-github-mdoc" % "0.8.2") +addSbtPlugin("com.alejandrohdezma" % "sbt-remove-test-from-pom" % "0.1.0") diff --git a/server/src/main/scala/org/scalaexercises/evaluator/auth.scala b/server/src/main/scala/org/scalaexercises/evaluator/auth.scala index 209c3e85..cf3a81ef 100644 --- a/server/src/main/scala/org/scalaexercises/evaluator/auth.scala +++ b/server/src/main/scala/org/scalaexercises/evaluator/auth.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/server/src/main/scala/org/scalaexercises/evaluator/codecs.scala b/server/src/main/scala/org/scalaexercises/evaluator/codecs.scala index 4e0227b0..ea476727 100644 --- a/server/src/main/scala/org/scalaexercises/evaluator/codecs.scala +++ b/server/src/main/scala/org/scalaexercises/evaluator/codecs.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/server/src/main/scala/org/scalaexercises/evaluator/evaluation.scala b/server/src/main/scala/org/scalaexercises/evaluator/evaluation.scala index 814e4c75..725eea5f 100644 --- a/server/src/main/scala/org/scalaexercises/evaluator/evaluation.scala +++ b/server/src/main/scala/org/scalaexercises/evaluator/evaluation.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/server/src/main/scala/org/scalaexercises/evaluator/services.scala b/server/src/main/scala/org/scalaexercises/evaluator/services.scala index be7ab666..808f958d 100644 --- a/server/src/main/scala/org/scalaexercises/evaluator/services.scala +++ b/server/src/main/scala/org/scalaexercises/evaluator/services.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/server/src/main/scala/org/scalaexercises/evaluator/types.scala b/server/src/main/scala/org/scalaexercises/evaluator/types.scala index e5a82e67..884c99ff 100644 --- a/server/src/main/scala/org/scalaexercises/evaluator/types.scala +++ b/server/src/main/scala/org/scalaexercises/evaluator/types.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/server/src/test/scala/org/scalaexercises/evaluator/EvalEndpointSpec.scala b/server/src/test/scala/org/scalaexercises/evaluator/EvalEndpointSpec.scala index 76aec46d..f14f4dd6 100644 --- a/server/src/test/scala/org/scalaexercises/evaluator/EvalEndpointSpec.scala +++ b/server/src/test/scala/org/scalaexercises/evaluator/EvalEndpointSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/server/src/test/scala/org/scalaexercises/evaluator/EvaluatorSpec.scala b/server/src/test/scala/org/scalaexercises/evaluator/EvaluatorSpec.scala index 906fabd3..1a274193 100644 --- a/server/src/test/scala/org/scalaexercises/evaluator/EvaluatorSpec.scala +++ b/server/src/test/scala/org/scalaexercises/evaluator/EvaluatorSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/server/src/test/scala/org/scalaexercises/evaluator/Implicits.scala b/server/src/test/scala/org/scalaexercises/evaluator/Implicits.scala index 375bcc77..b7dca31f 100644 --- a/server/src/test/scala/org/scalaexercises/evaluator/Implicits.scala +++ b/server/src/test/scala/org/scalaexercises/evaluator/Implicits.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/server/src/test/scala/org/scalaexercises/evaluator/helper.scala b/server/src/test/scala/org/scalaexercises/evaluator/helper.scala index 2fa3d004..dd434cc2 100644 --- a/server/src/test/scala/org/scalaexercises/evaluator/helper.scala +++ b/server/src/test/scala/org/scalaexercises/evaluator/helper.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/smoketests/src/test/scala/org/scalaexercises/evaluator/Smoketests.scala b/smoketests/src/test/scala/org/scalaexercises/evaluator/Smoketests.scala deleted file mode 100644 index 3bd05219..00000000 --- a/smoketests/src/test/scala/org/scalaexercises/evaluator/Smoketests.scala +++ /dev/null @@ -1,102 +0,0 @@ -/* - * scala-exercises - evaluator-server-smoke-tests - * Copyright (C) 2015-2016 47 Degrees, LLC. - */ - -package org.scalaexercises.evaluator - -import cats.effect.{IO, Sync} -import io.circe.Printer -import io.circe.generic.auto._ -import org.http4s._ -import org.http4s.circe._ -import org.http4s.client.Client -import org.http4s.client.blaze._ -import org.scalaexercises.evaluator.helper._ -import org.scalatest.funspec.AnyFunSpec -import org.scalatest.matchers.should.Matchers - -import pdi.jwt.{Jwt, JwtAlgorithm} - -import scala.concurrent.ExecutionContext -import scala.concurrent.duration._ - -class Smoketests extends AnyFunSpec with Matchers with CirceInstances with Implicits { - - val evaluatorUrl: Uri = IO - .fromEither(toScalaVersion(BuildInfo.scalaVersion) match { - case Scala211 => Uri.fromString("https://scala-evaluator.herokuapp.com/eval") - case _ => Uri.fromString("https://scala-evaluator-212.herokuapp.com/eval") - }) - .handleErrorWith(_ => - IO.raiseError( - new RuntimeException( - s"Unable to parse the scala evaluator url for scala version ${BuildInfo.scalaVersion}" - ) - ) - ) - .unsafeRunSync() - - case class EvaluatorResponse( - msg: String, - value: String, - valueType: String, - compilationInfos: Map[String, String] - ) - - implicit def decoder[F[_]: Sync]: EntityDecoder[F, EvaluatorResponse] = - jsonOf[F, EvaluatorResponse] - - val validToken = - Jwt.encode("""{"user": "scala-exercises"}""", auth.secretKey, JwtAlgorithm.HS256) - - def makeRequest( - code: String - )(expectation: EvaluatorResponse => Unit, failExpectation: Throwable => Unit = fail(_)): Unit = { - - val request = Request[IO](method = Method.POST, uri = evaluatorUrl) - .withEntity(s"""{"resolvers" : [], "dependencies" : [], "code" : "$code"}""") - .withHeaders(Headers.of(headers: _*)) - - def task(client: Client[IO]) = client.expect[EvaluatorResponse](request) - - client - .use(task) - .attempt - .map(_.fold(failExpectation, expectation)) - .timeout(60.seconds) - .unsafeRunSync() - } - - val headers = List( - Header("Content-Type", "application/json").parsed, - Header("x-scala-eval-api-token", validToken).parsed - ) - - val client = BlazeClientBuilder[IO](ExecutionContext.global).resource - - describe("Querying the /eval endpoint") { - it("should succeed for a simple request") { - makeRequest("1 + 1")(evaluatorResponse => evaluatorResponse.value shouldBe "2") - } - - it("should continue to work after calling System.exit") { - makeRequest("System.exit(1)")( - expectation = _ => fail("Request should not succeed"), - failExpectation = _ => () - ) - - makeRequest("1 + 1")(evaluatorResponse => evaluatorResponse.value shouldBe "2") - } - - it("should not expose sensitive details by calling sys.env") { - val keywords = List("password", "key", "api") - makeRequest("sys.env") { evaluatorResponse => - keywords.foreach(kw => evaluatorResponse.value.contains(kw) shouldBe false) - } - - } - } - - override protected def defaultPrinter: Printer = Printer.noSpaces.copy(dropNullValues = true) -}