Skip to content
This repository has been archived by the owner on Apr 22, 2020. It is now read-only.

Cross compile to SBT {0.13.16, 1.0.1} #510

Merged
merged 11 commits into from
Sep 8, 2017
56 changes: 33 additions & 23 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,38 @@
language: scala
scala:
- 2.10.6
jdk:
- oraclejdk8

matrix:
include:
- scala: 2.12.3
jdk: oraclejdk8
env:
- SBT_VERSION=1.0.1
- scala: 2.10.6
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might need to be 2.12.3 because sbt version in build.properties is 1.0.1, but we are compiling for 0.13.16 which requires 2.10.6. It might be a trial/error to see if one is faster than the other.

jdk: oraclejdk8
env:
- SBT_VERSION=0.13.16

cache:
directories:
- $HOME/.ivy2/cache
- $HOME/.sbt/boot/

before_install:
- if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then
openssl aes-256-cbc -K $encrypted_7c61f7d7bb76_key -iv $encrypted_7c61f7d7bb76_iv
-in secring.gpg.enc -out secring.gpg -d;
fi
- rm -rf $HOME/.ivy2/cache/scala_2.10/sbt_0.13/com.47deg/sbt-org-policies
- if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then
openssl aes-256-cbc -K $encrypted_7c61f7d7bb76_key -iv $encrypted_7c61f7d7bb76_iv
-in secring.gpg.enc -out secring.gpg -d;
fi
- rm -rf $HOME/.ivy2/cache/scala_2.11/sbt_0.13/com.47deg/sbt-org-policies

script:
- sbt ++$TRAVIS_SCALA_VERSION clean compile test
- if [ "$TRAVIS_BRANCH" = "master" ]; then
sbt ++$TRAVIS_SCALA_VERSION publishLocal;
sbt ++$TRAVIS_SCALA_VERSION scripted;
fi
- sbt ^^$SBT_VERSION clean compile test
- if [ "$TRAVIS_BRANCH" = "master" ]; then
sbt ^^$SBT_VERSION scripted;
fi

after_success:
- sbt ++$TRAVIS_SCALA_VERSION orgAfterCISuccess
- sbt ++$TRAVIS_SCALA_VERSION publishLocal
- cd autocheck && sbt -Dplugin.version=$(cat ../version.sbt | sed 's/.*"\(.*\)".*/\1/') checkDependencies
- sbt ^^$SBT_VERSION orgAfterCISuccess
- sbt ^^$SBT_VERSION publishLocal
- cd autocheck && sbt ^^$SBT_VERSION -Dplugin.version=$(cat ../version.sbt | sed 's/.*"\(.*\)".*/\1/') checkDependencies

cache:
directories:
Expand All @@ -34,9 +44,9 @@ cache:
- $HOME/.coursier

before_cache:
- du -h -d 1 $HOME/.ivy2/
- du -h -d 2 $HOME/.sbt/
- du -h -d 4 $HOME/.coursier/
- find $HOME/.sbt -name "*.lock" -type f -delete
- find $HOME/.ivy2/cache -name "ivydata-*.properties" -type f -delete
- find $HOME/.coursier/cache -name "*.lock" -type f -delete
- du -h -d 1 $HOME/.ivy2/
- du -h -d 2 $HOME/.sbt/
- du -h -d 4 $HOME/.coursier/
- find $HOME/.sbt -name "*.lock" -type f -delete
- find $HOME/.ivy2/cache -name "ivydata-*.properties" -type f -delete
- find $HOME/.coursier/cache -name "*.lock" -type f -delete
32 changes: 22 additions & 10 deletions autocheck/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ import sbtorgpolicies.io.FileReader
import sbtorgpolicies.libraries._
import sbtorgpolicies.model.GitHubSettings

resolvers += Resolver.sonatypeRepo("snapshots")

lazy val checkDependencies = taskKey[Unit]("Check the module dependencies")

lazy val `org-policies-auto-dep-check` = (project in file("."))
.settings(name := "org-policies-auto-dep-check")
.settings(noPublishSettings: _*)
.settings(Seq(
scalaVersion := "2.11.8",
crossScalaVersions := Seq("2.11.8"),
scalaVersion := "2.12.3",
crossScalaVersions := Seq("2.12.3"),
scalaOrganization := "org.scala-lang",
orgGithubSetting := GitHubSettings(
organization = "47deg",
Expand All @@ -23,25 +25,35 @@ lazy val `org-policies-auto-dep-check` = (project in file("."))
),
resolvers ++= Seq(Resolver.sonatypeRepo("snapshots"), Resolver.bintrayIvyRepo("sbt", "sbt-plugin-releases")),
libraryDependencies ++=
scalaLibs.mapValues(lib => lib._1 %% lib._2 % lib._3).values.toList ++
javaLibs.mapValues(lib => lib._1 % lib._2 % lib._3).values.toList,
scalaLibs
.filter(_._1 != "scalameta-paradise")
.mapValues(lib => lib._1 %% lib._2 % lib._3)
.values
.toList ++
javaLibs.mapValues(lib => lib._1 % lib._2 % lib._3).values.toList,
checkDependencies := Def.taskDyn {
val fr = new FileReader
val versionSbtFile = baseDirectory.value.getParentFile / "version.sbt"
val VersionRegex = """.*"(.*-SNAPSHOT)".*""".r

val currentPluginVersion = fr.getFileContent(versionSbtFile.getAbsolutePath) match {
case Right(VersionRegex(v)) => Some(v)
case _ => None
}
val currentPluginVersion =
fr.getFileContent(versionSbtFile.getAbsolutePath) match {
case Right(VersionRegex(v)) => Some(v)
case _ => None
}

val isTravisMaster = getEnvVarOrElse("TRAVIS_BRANCH") == "master" &&
getEnvVarOrElse("TRAVIS_PULL_REQUEST") == "false"

if (isTravisMaster && currentPluginVersion.isDefined)
Def.task(depUpdateDependencyIssues.value)
// Def.task(depUpdateDependencyIssues.value)
Def.task()
else
Def.task(streams.value.log.warn("Skipping auto-dependency check"))
}.value
): _*)
.settings(allPlugins.mapValues(lib => addSbtPlugin(lib._1 % lib._2 % lib._3, "0.13", "2.10")).values.toList: _*)
.settings(
allPlugins
.mapValues(lib => addSbtPlugin(lib._1 % lib._2 % lib._3))
.values
.toList: _*)
2 changes: 1 addition & 1 deletion autocheck/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version = 0.13.15
sbt.version = 1.0.1
2 changes: 1 addition & 1 deletion autocheck/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
resolvers += Resolver.sonatypeRepo("snapshots")
addSbtPlugin("com.47deg" % "sbt-org-policies" % sys.props("plugin.version"))
addSbtPlugin("com.47deg" % "sbt-org-policies" % "0.6.0-SNAPSHOT")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep the environment variable

6 changes: 3 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ lazy val `org-policies-core` = (project in file("core"))

addCommandAlias("publishLocalAll", ";org-policies-core/publishLocal;sbt-org-policies/publishLocal")

pgpPassphrase := Some(getEnvVar("PGP_PASSPHRASE").getOrElse("").toCharArray)
pgpPublicRing := file(s"$gpgFolder/pubring.gpg")
pgpSecretRing := file(s"$gpgFolder/secring.gpg")
pgpPassphrase := Some(Option(System.getenv().get("PGP_PASSPHRASE")).getOrElse("").toCharArray)
// pgpPublicRing := file(s"$gpgFolder/pubring.gpg")
// pgpSecretRing := file(s"$gpgFolder/secring.gpg")
6 changes: 5 additions & 1 deletion core/src/main/scala/sbtorgpolicies/github/GitHubOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import com.github.marklister.base64.Base64._
import github4s.Github
import github4s.GithubResponses._
import github4s.free.domain._
// import sbt.io.IO
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following

import sbt.io._
import sbt.io.syntax._

and the equivalent are the just "notes" and would be the imports if we were using purely sbt 1.0.

https://github.com/dwijnand/sbt-compat allows us to keep the equivalent sbt 0.13 imports.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I think we could starting using those soon

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of how sbt-compat, it exposes the sbt 1.0 api through the sbt 0.13 import statements. It's either that or have scala version specific source files where the only difference is something like

47deg-suhas:main suhas$ diff scala-2.10/sbtorgpolicies/io/io.scala scala-2.12/sbtorgpolicies/io/io.scala
24c24,25
< import sbt.{file, File}
---
> import sbt.io._
> import sbt.io.syntax._

I think we'll need to keep this until we stop supporting sbt 0.13.

import sbt.IO
import sbtorgpolicies.exceptions.{GitHubException, IOException, OrgPolicyException}
import sbtorgpolicies.github.config._
Expand Down Expand Up @@ -281,7 +282,10 @@ class GitHubOps(owner: String, repo: String, accessToken: Option[String]) {
op.execE
}

def latestPullRequests(branch: String, inPath: String, message: String): Either[GitHubException, List[PullRequest]] = {
def latestPullRequests(
branch: String,
inPath: String,
message: String): Either[GitHubException, List[PullRequest]] = {

def fetchLastCommit: Github4sResponse[Option[Commit]] = {

Expand Down
2 changes: 2 additions & 0 deletions core/src/main/scala/sbtorgpolicies/io/FileHelper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import cats.syntax.either._
import cats.syntax.foldable._
import cats.syntax.traverse._
import cats.syntax.traverseFilter._
// import sbt.io._
// import sbt.io.syntax._
import sbt.{File, URL}
import sbtorgpolicies.exceptions.IOException
import sbtorgpolicies.io.syntax._
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/scala/sbtorgpolicies/io/FileReader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package sbtorgpolicies.io
import java.io.File

import cats.syntax.either._
// import sbt.io._
// import sbt.io.syntax._
import sbt.{file, IO}
import sbtorgpolicies.exceptions._
import sbtorgpolicies.io.syntax._
Expand Down Expand Up @@ -91,9 +93,7 @@ class FileReader {
}
.leftMap(e => IOException(s"Error fetching files recursively", Some(e)))

def fetchDirsRecursively(
in: List[File],
isDirSupported: (File) => Boolean = defaultValidDirs): IOResult[List[File]] =
def fetchDirsRecursively(in: List[File], isDirSupported: (File) => Boolean = defaultValidDirs): IOResult[List[File]] =
Either
.catchNonFatal {
@tailrec
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/scala/sbtorgpolicies/io/FileWriter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import cats.instances.either._
import cats.instances.list._
import cats.syntax.either._
import cats.syntax.traverse._
// import sbt.io._
// import sbt.io.syntax._
import sbt.{file, File, IO, URL}
import sbtorgpolicies.exceptions._
import sbtorgpolicies.io.syntax._
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/scala/sbtorgpolicies/io/io.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import java.nio.file.Path
import java.nio.file.Paths.get

import cats.syntax.either._
// import sbt.io._
// import sbt.io.syntax._
import sbt.{file, File}
import sbtorgpolicies.exceptions.IOException

Expand Down
64 changes: 32 additions & 32 deletions core/src/main/scala/sbtorgpolicies/libraries.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ object libraries {
"cats-effect" -> "0.3",
"circe" -> "0.8.0",
"config" -> "1.3.1",
"coursier" -> "1.0.0-RC9",
"coursier" -> "1.0.0-RC11",
"discipline" -> "0.8",
"doobie" -> "0.4.1",
"embedded-redis" -> "0.6",
Expand Down Expand Up @@ -76,7 +76,7 @@ object libraries {
"refined" -> "0.8.2",
"roshttp" -> "2.0.2",
"scala-parser-combinators" -> "1.0.6",
"scala-reflect" -> "2.11.8",
"scala-reflect" -> "2.11.11",
"scalacheck" -> "1.13.5",
"scheckShapeless" -> "1.1.6",
"scalactic" -> "3.0.3",
Expand Down Expand Up @@ -105,20 +105,20 @@ object libraries {

val vPluginsOthers: Map[String, String] = Map[String, String](
"sbt-buildinfo" -> "0.7.0",
"sbt-ghpages" -> "0.6.0",
"sbt-git" -> "0.9.2",
"sbt-header" -> "1.8.0",
"sbt-pgp" -> "1.0.1",
"sbt-jmh" -> "0.2.25",
"sbt-release" -> "1.0.5",
"sbt-ghpages" -> "0.6.2",
"sbt-git" -> "0.9.3",
"sbt-header" -> "3.0.1",
"sbt-pgp" -> "1.1.0-M1",
"sbt-jmh" -> "0.2.27",
"sbt-release" -> "1.0.6",
"sbt-scalafmt" -> "0.6.8",
"sbt-scalajs" -> "0.6.18",
"sbt-scoverage" -> "1.5.0",
"sbt-site" -> "1.2.0",
"sbt-sonatype" -> "1.1",
"sbt-unidoc" -> "0.4.0",
"scalastyle-sbt-plugin" -> "0.8.0",
"tut-plugin" -> "0.5.4"
"sbt-scalajs" -> "0.6.19",
"sbt-scoverage" -> "1.5.1",
"sbt-site" -> "1.3.0",
"sbt-sonatype" -> "2.0",
"sbt-unidoc" -> "0.4.1",
"scalastyle-sbt-plugin" -> "1.0.0",
"tut-plugin" -> "0.6.0"
)

val v: Map[String, String] = v47 ++ vOthers ++ vPlugins47 ++ vPluginsOthers
Expand Down Expand Up @@ -297,23 +297,23 @@ object libraries {
)

val pluginLibs: Map[String, Artifact] = Map[String, Artifact](
"sbt-buildinfo" -> (("com.eed3si9n", "sbt-buildinfo", v("sbt-buildinfo"))),
"sbt-dependencies" -> (("com.47deg", "sbt-dependencies", v("sbt-dependencies"))),
"sbt-coursier" -> (("io.get-coursier", "sbt-coursier", v("coursier"))),
"sbt-ghpages" -> (("com.typesafe.sbt", "sbt-ghpages", v("sbt-ghpages"))),
"sbt-git" -> (("com.typesafe.sbt", "sbt-git", v("sbt-git"))),
"sbt-header" -> (("de.heikoseeberger", "sbt-header", v("sbt-header"))),
"sbt-jmh" -> (("pl.project13.scala", "sbt-jmh", v("sbt-jmh"))),
"sbt-microsites" -> (("com.47deg", "sbt-microsites", v("sbt-microsites"))),
"sbt-pgp" -> (("com.jsuereth", "sbt-pgp", v("sbt-pgp"))),
"sbt-release" -> (("com.github.gseitz", "sbt-release", v("sbt-release"))),
"sbt-site" -> (("com.typesafe.sbt", "sbt-site", v("sbt-site"))),
"sbt-scalafmt" -> (("com.geirsson", "sbt-scalafmt", v("sbt-scalafmt"))),
"sbt-scalajs" -> (("org.scala-js", "sbt-scalajs", v("sbt-scalajs"))),
"sbt-scoverage" -> (("org.scoverage", "sbt-scoverage", v("sbt-scoverage"))),
"sbt-sonatype" -> (("org.xerial.sbt", "sbt-sonatype", v("sbt-sonatype"))),
"sbt-unidoc" -> (("com.eed3si9n", "sbt-unidoc", v("sbt-unidoc"))),
"tut-plugin" -> (("org.tpolecat", "tut-plugin", v("tut-plugin")))
"sbt-buildinfo" -> (("com.eed3si9n", "sbt-buildinfo", v("sbt-buildinfo"))),
// "sbt-dependencies" -> (("com.47deg", "sbt-dependencies", v("sbt-dependencies"))),
// "sbt-coursier" -> (("io.get-coursier", "sbt-coursier", v("coursier"))),
"sbt-ghpages" -> (("com.typesafe.sbt", "sbt-ghpages", v("sbt-ghpages"))),
"sbt-git" -> (("com.typesafe.sbt", "sbt-git", v("sbt-git"))),
"sbt-header" -> (("de.heikoseeberger", "sbt-header", v("sbt-header"))),
"sbt-jmh" -> (("pl.project13.scala", "sbt-jmh", v("sbt-jmh"))),
// "sbt-microsites" -> (("com.47deg", "sbt-microsites", v("sbt-microsites"))),
"sbt-pgp" -> (("com.jsuereth", "sbt-pgp", v("sbt-pgp"))),
"sbt-release" -> (("com.github.gseitz", "sbt-release", v("sbt-release"))),
"sbt-site" -> (("com.typesafe.sbt", "sbt-site", v("sbt-site"))),
"sbt-scalafmt" -> (("com.geirsson", "sbt-scalafmt", v("sbt-scalafmt"))),
"sbt-scalajs" -> (("org.scala-js", "sbt-scalajs", v("sbt-scalajs"))),
"sbt-scoverage" -> (("org.scoverage", "sbt-scoverage", v("sbt-scoverage"))),
"sbt-sonatype" -> (("org.xerial.sbt", "sbt-sonatype", v("sbt-sonatype"))),
"sbt-unidoc" -> (("com.eed3si9n", "sbt-unidoc", v("sbt-unidoc"))),
"tut-plugin" -> (("org.tpolecat", "tut-plugin", v("tut-plugin")))
)

val pluginScalaLibs: Map[String, Artifact] = Map[String, Artifact](
Expand Down
16 changes: 13 additions & 3 deletions core/src/main/scala/sbtorgpolicies/model.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ package sbtorgpolicies

import net.jcazevedo.moultingyaml._
import sbt.Append.Value
import sbt.{url, Append, URL}
// import sbt.io._
// import sbt.io.syntax._
import sbt.{url, URL}
import sbtorgpolicies.runnable.RunnableItemConfigScope
import sbtorgpolicies.runnable.syntax._

Expand Down Expand Up @@ -46,7 +48,7 @@ object model {

}

implicit val settingAppender: Append.Value[Seq[(String, java.net.URL)], License] =
implicit val settingAppender: Value[Seq[(String, java.net.URL)], License] =
new Value[Seq[(String, URL)], License] {
override def appendValue(a: Seq[(String, URL)], b: License): Seq[(String, URL)] = a :+ b.tupled
}
Expand Down Expand Up @@ -126,11 +128,19 @@ object model {
</developer>
}

object sbtV {
val `0.13`: String = "0.13.16"
val `1.0`: String = "1.0.1"

val crossSbtVersions: List[String] = List(`0.13`, `1.0`)
}

object scalac {

val `2.10`: String = "2.10.6"
val `2.11`: String = "2.11.11"
val `2.12`: String = "2.12.2"
val `2.12`: String = "2.12.3"
val `2.13`: String = "2.13.0-M1"

val latestScalaVersion: String = `2.12`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,4 @@ trait ValidationFunctions {
}
}

object ValidationFunctions extends ValidationFunctions
object ValidationFunctions extends ValidationFunctions
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ trait GitHubArbitraries {
} toList

def genGHResponse[T](gen: Gen[T]): Gen[GHResponse[T]] =
Gen.oneOf(
genGHException.map(_.asLeft[GHResult[T]]),
gen.map(v => GHResult(v, 200, Map.empty).asRight[GHException]))
Gen.oneOf(genGHException.map(_.asLeft[GHResult[T]]), gen.map(v => GHResult(v, 200, Map.empty).asRight[GHException]))

val genGHException: Gen[GHException] = {
val message = "Generated Exception"
Expand Down
Loading