Skip to content

Commit

Permalink
Create a Scala 2.11 branch (#3052)
Browse files Browse the repository at this point in the history
* wip make it purely scala 2.11

*  make it purely scala 2.11

* fix tests

* format
  • Loading branch information
kailuowang authored Sep 17, 2019
1 parent 27178ff commit bdc7789
Show file tree
Hide file tree
Showing 86 changed files with 41 additions and 2,572 deletions.
34 changes: 5 additions & 29 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,11 @@ git:
jdk:
- openjdk8

scala_version_211: &scala_version_211 2.11.12
scala_version_212: &scala_version_212 2.12.9
scala_version_213: &scala_version_213 2.13.0
scala: 2.11.12


before_install:
- export PATH=${PATH}:./vendor/bundle
- if [[ ! -z "$HydraLicense" ]]; then
mkdir -p /home/travis/.triplequote/metrics/config && echo "$HydraLicense" > "/home/travis/.triplequote/hydra.license" && cp hydra-metrics-service.conf /home/travis/.triplequote/metrics/config/metrics-service.conf;
fi

stages:
- name: styling
Expand All @@ -34,44 +30,24 @@ jobs:
install: pip install --user codecov
script: sbt coverage buildJVM bench/test coverageReport && codecov

- &js_tests
stage: test
- stage: test
env: TEST="JS tests"
# http://austinpray.com/ops/2015/09/20/change-travis-node-version.html
install: rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install $TRAVIS_NODE_VERSION
script: sbt ++$TRAVIS_SCALA_VERSION! validateJS && sbt ++$TRAVIS_SCALA_VERSION! validateKernelJS && sbt ++$TRAVIS_SCALA_VERSION! validateFreeJS
scala: *scala_version_211
- <<: *js_tests
scala: *scala_version_212

- &jvm_tests
stage: test
- stage: test
env: TEST="JVM tests"
script: sbt ++$TRAVIS_SCALA_VERSION! buildJVM bench/test
scala: *scala_version_211
- <<: *jvm_tests
scala: *scala_version_212
- <<: *jvm_tests
scala: *scala_version_213
# the bench module has dependencies not available in Scala 2.13, so don't test it
script: sbt ++$TRAVIS_SCALA_VERSION! buildJVM


- stage: test
env: TEST="docs"
install: gem install jekyll -v 2.5
script: sbt docs/makeMicrosite

- stage: test
env: TEST="scalafix"
script: cd scalafix && sbt tests/test

- &bincompat_check
stage: test
env: TEST="binary compatibility"
script: sbt ++$TRAVIS_SCALA_VERSION! validateBC
scala: *scala_version_211
- <<: *bincompat_check
scala: *scala_version_212

- stage: styling
env: TEST="linting"
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package cats.bench

import cats.instances.list._
import cats.instances.int._
import cats.instances.map._

import org.openjdk.jmh.annotations.{Benchmark, Scope, State}
import scalaz.std.anyVal._
import scalaz.std.list._
import scalaz.std.map._

import org.openjdk.jmh.annotations.{ Benchmark, Scope, State }
import cats.instances.list._
import cats.instances.int._
import cats.instances.map._

@State(Scope.Benchmark)
class MapMonoidBench {
Expand Down
144 changes: 27 additions & 117 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ import scala.xml.transform.{RewriteRule, RuleTransformer}
import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType}

lazy val scoverageSettings = Seq(
coverageEnabled := {
if (priorTo2_13(scalaVersion.value))
coverageEnabled.value
else
false
},
coverageMinimum := 60,
coverageFailOnMinimum := false,
coverageHighlighting := true
Expand All @@ -35,54 +29,14 @@ val disciplineScalatestVersion = "1.0.0-M1"

val kindProjectorVersion = "0.10.3"

crossScalaVersionsFromTravis in Global := {
val manifest = (baseDirectory in ThisBuild).value / ".travis.yml"
import collection.JavaConverters._
Using.fileInputStream(manifest) { fis =>
new org.yaml.snakeyaml.Yaml().loadAs(fis, classOf[java.util.Map[_, _]]).asScala.toList.collect {
case (k: String, v: String) if k.contains("scala_version_") => v
}
}
}

def scalaVersionSpecificFolders(srcName: String, srcBaseDir: java.io.File, scalaVersion: String) = {
def extraDirs(suffix: String) =
List(CrossType.Pure, CrossType.Full)
.flatMap(_.sharedSrcDir(srcBaseDir, srcName).toList.map(f => file(f.getPath + suffix)))
CrossVersion.partialVersion(scalaVersion) match {
case Some((2, y)) if y <= 12 =>
extraDirs("-2.12-")
case Some((2, y)) if y >= 13 =>
extraDirs("-2.13+")
case _ => Nil
}
}

lazy val commonScalaVersionSettings = Seq(
crossScalaVersions := (crossScalaVersionsFromTravis in Global).value,
scalaVersion := crossScalaVersions.value.find(_.contains("2.12")).get
)

commonScalaVersionSettings
lazy val commonScalaVersionSettings = Seq(scalaVersion := "2.11.12")

lazy val commonSettings = commonScalaVersionSettings ++ Seq(
scalacOptions ++= commonScalacOptions(scalaVersion.value),
Compile / unmanagedSourceDirectories ++= scalaVersionSpecificFolders("main", baseDirectory.value, scalaVersion.value),
Test / unmanagedSourceDirectories ++= scalaVersionSpecificFolders("test", baseDirectory.value, scalaVersion.value),
resolvers ++= Seq(Resolver.sonatypeRepo("releases"), Resolver.sonatypeRepo("snapshots")),
parallelExecution in Test := false,
scalacOptions in (Compile, doc) := (scalacOptions in (Compile, doc)).value.filter(_ != "-Xfatal-warnings"),
// TODO: reenable doctests on 2.13 once it's officially released. it's disabled for now due to changes to the `toString` impl of collections
doctestGenTests := {
val unchanged = doctestGenTests.value
if (priorTo2_13(scalaVersion.value)) unchanged else Nil
},
// TODO: re-enable disable scaladoc on 2.13 due to https://github.com/scala/bug/issues/11045
sources in (Compile, doc) := {
val docSource = (sources in (Compile, doc)).value
if (priorTo2_13(scalaVersion.value)) docSource else Nil
}
) ++ warnUnusedImport ++ update2_12 ++ xlint
scalacOptions in (Compile, doc) := (scalacOptions in (Compile, doc)).value.filter(_ != "-Xfatal-warnings")
) ++ warnUnusedImport

def macroDependencies(scalaVersion: String) =
CrossVersion.partialVersion(scalaVersion) match {
Expand Down Expand Up @@ -234,11 +188,9 @@ lazy val docSettings = Seq(
scmInfo.value.get.browseUrl + "/tree/master€{FILE_PATH}.scala",
"-sourcepath",
baseDirectory.in(LocalRootProject).value.getAbsolutePath,
"-diagrams"
) ++ (if (priorTo2_13(scalaVersion.value))
Seq("-Yno-adapted-args")
else
Seq("-Ymacro-annotations")),
"-diagrams",
"-Yno-adapted-args"
),
scalacOptions in Tut ~= (_.filterNot(Set("-Ywarn-unused-import", "-Ywarn-unused:imports", "-Ywarn-dead-code"))),
git.remoteRepo := "git@github.com:typelevel/cats.git",
includeFilter in makeSite := "*.html" | "*.css" | "*.png" | "*.jpg" | "*.gif" | "*.js" | "*.swf" | "*.yml" | "*.md" | "*.svg",
Expand Down Expand Up @@ -281,11 +233,9 @@ def mimaPrevious(moduleName: String, scalaVer: String, ver: String): List[Module
// Safety Net for Inclusions
lazy val extraVersions: List[String] = List("1.0.1", "1.1.0", "1.2.0", "1.3.1", "1.4.0", "1.5.0", "1.6.1")

if (priorTo2_13(scalaVer)) {
(mimaVersions ++ extraVersions)
.filterNot(excludedVersions.contains(_))
.map(v => "org.typelevel" %% moduleName % v)
} else List()
(mimaVersions ++ extraVersions)
.filterNot(excludedVersions.contains(_))
.map(v => "org.typelevel" %% moduleName % v)

}

Expand Down Expand Up @@ -420,7 +370,10 @@ lazy val docs = project
lazy val cats = project
.in(file("."))
.settings(moduleName := "root", crossScalaVersions := Nil)
.settings(publishSettings) // these settings are needed to release all aggregated modules under this root module
.settings(
commonScalaVersionSettings,
publishSettings
) // these settings are needed to release all aggregated modules under this root module
.settings(noPublishSettings) // this is to exclue the root module itself from being published.
.aggregate(catsJVM, catsJS)
.dependsOn(catsJVM, catsJS, tests.jvm % "test-internal -> test")
Expand Down Expand Up @@ -639,13 +592,12 @@ lazy val bench = project
.settings(coverageEnabled := false)
.settings(
libraryDependencies ++= {
if (priorTo2_13(scalaVersion.value))
Seq(
"org.scalaz" %% "scalaz-core" % "7.2.23",
"org.spire-math" %% "chain" % "0.3.0",
"co.fs2" %% "fs2-core" % "0.10.4"
)
else Nil
Seq(
"org.scalaz" %% "scalaz-core" % "7.2.23",
"org.spire-math" %% "chain" % "0.3.0",
"co.fs2" %% "fs2-core" % "0.10.4"
)

}
)
.enablePlugins(JmhPlugin)
Expand All @@ -657,12 +609,7 @@ lazy val binCompatTest = project
commonScalaVersionSettings,
addCompilerPlugin("org.typelevel" %% "kind-projector" % kindProjectorVersion),
libraryDependencies ++= List(
{
if (priorTo2_13(scalaVersion.value))
mimaPrevious("cats-core", scalaVersion.value, version.value).last % Provided
else //We are not testing BC on Scala 2.13 yet.
"org.typelevel" %% "cats-core" % "2.0.0-M4" % Provided
},
mimaPrevious("cats-core", scalaVersion.value, version.value).last % Provided,
"org.scalatest" %%% "scalatest" % scalatestVersion % Test
)
)
Expand Down Expand Up @@ -788,7 +735,7 @@ addCommandAlias("validateKernelJS", "kernelLawsJS/test")
addCommandAlias("validateFreeJS", "freeJS/test") //separated due to memory constraint on travis
addCommandAlias("validate", ";clean;validateJS;validateKernelJS;validateFreeJS;validateJVM")

addCommandAlias("prePR", ";fmt;++2.11.12 mimaReportBinaryIssues")
addCommandAlias("prePR", ";fmt;mimaReportBinaryIssues")

////////////////////////////////////////////////////////////////////////////////////////////////////
// Base Build Settings - Should not need to edit below this line.
Expand All @@ -804,15 +751,6 @@ lazy val noPublishSettings = Seq(
publishArtifact := false
)

lazy val crossVersionSharedSources: Seq[Setting[_]] =
Seq(Compile, Test).map { sc =>
(unmanagedSourceDirectories in sc) ++= {
(unmanagedSourceDirectories in sc).value.map { dir: File =>
new File(dir.getPath + "_" + scalaBinaryVersion.value)
}
}
}

def commonScalacOptions(scalaVersion: String) =
Seq(
"-encoding",
Expand All @@ -827,22 +765,12 @@ def commonScalacOptions(scalaVersion: String) =
"-Ywarn-numeric-widen",
"-Ywarn-value-discard",
"-Xfatal-warnings",
"-deprecation"
) ++ (if (priorTo2_13(scalaVersion))
Seq(
"-Yno-adapted-args",
"-Xfuture"
)
else
Seq(
"-Ymacro-annotations"
))

def priorTo2_13(scalaVersion: String): Boolean =
CrossVersion.partialVersion(scalaVersion) match {
case Some((2, minor)) if minor < 13 => true
case _ => false
}
"-deprecation",
"-Yinline-warnings",
"-Xlint",
"-Yno-adapted-args",
"-Xfuture"
)

lazy val sharedPublishSettings = Seq(
releaseTagName := tagName.value,
Expand Down Expand Up @@ -898,21 +826,3 @@ lazy val credentialSettings = Seq(
password <- Option(System.getenv().get("SONATYPE_PASSWORD"))
} yield Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", username, password)).toSeq
)

lazy val update2_12 = Seq(
scalacOptions -= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, scalaMajor)) if scalaMajor >= 12 => "-Yinline-warnings"
case _ => ""
}
}
)

lazy val xlint = Seq(
scalacOptions += {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, scalaMajor)) if scalaMajor >= 12 => "-Xlint:-unused,_"
case _ => "-Xlint"
}
}
)
9 changes: 0 additions & 9 deletions core/src/main/scala-2.13+/cats/compat/SortedSet.scala

This file was deleted.

Loading

0 comments on commit bdc7789

Please sign in to comment.