diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 23862471..16c38c78 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,8 +12,22 @@ on: - release/* jobs: - scala-2_12: + scala: runs-on: ubuntu-latest + strategy: + matrix: + java: [ '11' ] + scala: [ + { version: '2.12.13' }, + { version: '2.12.12' }, + { version: '2.12.11' }, + { version: '2.12.10' }, + { version: '2.13.4' }, + { version: '2.13.3' }, + { version: '2.13.2' }, + { version: '2.13.1' }, + { version: '2.13.0' } + ] steps: - name: checkout the repo uses: actions/checkout@v2 @@ -23,23 +37,7 @@ jobs: - name: Set up JDK uses: actions/setup-java@v1 with: - java-version: 11 + java-version: ${{ matrix.java }} - name: run tests - run: sbt ++2.12.10 test - - scala-2_13: - runs-on: ubuntu-latest - steps: - - name: checkout the repo - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Set up JDK - uses: actions/setup-java@v1 - with: - java-version: 11 - - - name: run tests - run: sbt ++2.13.3 test \ No newline at end of file + run: sbt ++${{ matrix.scala.version }} test diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 05ffb87b..5cd20d5b 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -8,8 +8,22 @@ on: - '*.md' jobs: - scala-2_12: + scala: runs-on: ubuntu-latest + strategy: + matrix: + java: [ '11' ] + scala: [ + { version: '2.12.13' }, + { version: '2.12.12' }, + { version: '2.12.11' }, + { version: '2.12.10' }, + { version: '2.13.4' }, + { version: '2.13.3' }, + { version: '2.13.2' }, + { version: '2.13.1' }, + { version: '2.13.0' } + ] steps: - name: checkout the repo uses: actions/checkout@v2 @@ -19,23 +33,7 @@ jobs: - name: Set up JDK uses: actions/setup-java@v1 with: - java-version: 11 + java-version: ${{ matrix.java }} - name: run tests - run: sbt ++2.12.10 test - - scala-2_13: - runs-on: ubuntu-latest - steps: - - name: checkout the repo - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Set up JDK - uses: actions/setup-java@v1 - with: - java-version: 11 - - - name: run tests - run: sbt ++2.13.3 test \ No newline at end of file + run: sbt ++${{ matrix.scala.version }} test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2d243cad..76742b9a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,8 +11,22 @@ on: required: true jobs: - scala-2_12: + scala: runs-on: ubuntu-latest + strategy: + matrix: + java: [ '11' ] + scala: [ + { version: '2.12.13' }, + { version: '2.12.12' }, + { version: '2.12.11' }, + { version: '2.12.10' }, + { version: '2.13.4' }, + { version: '2.13.3' }, + { version: '2.13.2' }, + { version: '2.13.1' }, + { version: '2.13.0' } + ] steps: - name: checkout the repo uses: actions/checkout@v2 @@ -22,7 +36,7 @@ jobs: - name: Set up JDK uses: actions/setup-java@v1 with: - java-version: 11 + java-version: ${{ matrix.java }} - name: Import GPG key id: import_gpg @@ -39,45 +53,8 @@ jobs: echo "email: ${{ steps.import_gpg.outputs.email }}" - name: publish release - run: sbt ++2.12.10 publishSigned + run: sbt ++${{ matrix.scala.version }} publishSigned env: RELEASE_VERSION: ${{ github.event.inputs.version }} OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} - - scala-2_13: - runs-on: ubuntu-latest - steps: - - name: checkout the repo - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Set up JDK - uses: actions/setup-java@v1 - with: - java-version: 11 - - - name: Import GPG key - id: import_gpg - uses: crazy-max/ghaction-import-gpg@v3 - with: - gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} - passphrase: ${{ secrets.PGP_PASSPHRASE }} - - - name: GPG user IDs - run: | - echo "fingerprint: ${{ steps.import_gpg.outputs.fingerprint }}" - echo "keyid: ${{ steps.import_gpg.outputs.keyid }}" - echo "name: ${{ steps.import_gpg.outputs.name }}" - echo "email: ${{ steps.import_gpg.outputs.email }}" - - - name: run tests - run: sbt ++2.13.3 test - - - name: publish release - run: sbt ++2.13.3 publishSigned - env: - RELEASE_VERSION: ${{ github.event.inputs.version }} - OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} - OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} \ No newline at end of file diff --git a/build.sbt b/build.sbt index 55ad4259..b33989bf 100644 --- a/build.sbt +++ b/build.sbt @@ -7,10 +7,15 @@ import sbtcrossproject.CrossType val Org = "org.scoverage" val ScalatestVersion = "3.1.1" +val bin212 = Seq("2.12.13", "2.12.12", "2.12.11", "2.12.10") +val bin213 = Seq("2.13.4", "2.13.3", "2.13.2", "2.13.1", "2.13.0") + val appSettings = Seq( organization := Org, - scalaVersion := "2.12.10", - crossScalaVersions := Seq("2.12.10", "2.13.4"), + scalaVersion := "2.12.13", + crossScalaVersions := bin212 ++ bin213, + crossVersion := CrossVersion.full, + crossTarget := target.value / s"scala-${scalaVersion.value}", fork in Test := false, publishMavenStyle := true, publishArtifact in Test := false, diff --git a/scalac-scoverage-plugin/src/main/scala/scoverage/CoverageFilter.scala b/scalac-scoverage-plugin/src/main/scala/scoverage/CoverageFilter.scala index 1636d08c..ea5206fd 100644 --- a/scalac-scoverage-plugin/src/main/scala/scoverage/CoverageFilter.scala +++ b/scalac-scoverage-plugin/src/main/scala/scoverage/CoverageFilter.scala @@ -2,6 +2,7 @@ package scoverage import scala.collection.mutable import scala.reflect.internal.util.{Position, SourceFile} +import scala.util.matching.Regex /** * Methods related to filtering the instrumentation and coverage. @@ -72,6 +73,12 @@ class RegexCoverageFilter(excludedPackages: Seq[String], excludedSymbolPatterns.isEmpty || !excludedSymbolPatterns.exists(_.matcher(symbolName).matches) } + /** + * Provides overloads to paper over 2.12.13+ SourceFile incompatibility + */ + def compatFindAllIn(regexp: Regex, pattern: Array[Char]): Regex.MatchIterator = regexp.findAllIn(new String(pattern)) + def compatFindAllIn(regexp: Regex, pattern: String): Regex.MatchIterator = regexp.findAllIn(pattern) + /** * Checks the given sourceFile for any magic comments which exclude lines * from coverage. Returns a list of Ranges of lines that should be excluded. @@ -83,7 +90,7 @@ class RegexCoverageFilter(excludedPackages: Seq[String], linesExcludedByScoverageCommentsCache.get(sourceFile) match { case Some(lineNumbers) => lineNumbers case None => - val lineNumbers = scoverageExclusionCommentsRegex.findAllIn(sourceFile.content).matchData.map { m => + val lineNumbers = compatFindAllIn(scoverageExclusionCommentsRegex, sourceFile.content).matchData.map { m => // Asking a SourceFile for the line number of the char after // the end of the file gives an exception val endChar = math.min(m.end(2), sourceFile.content.length - 1) diff --git a/scalac-scoverage-plugin/src/test/scala/scoverage/MacroSupport.scala b/scalac-scoverage-plugin/src/test/scala/scoverage/MacroSupport.scala index 4e963fc9..70fa4641 100644 --- a/scalac-scoverage-plugin/src/test/scala/scoverage/MacroSupport.scala +++ b/scalac-scoverage-plugin/src/test/scala/scoverage/MacroSupport.scala @@ -13,6 +13,6 @@ trait MacroSupport { val macroSupportDeps = Seq(testClasses) - private def testClasses: File = new File(s"./scalac-scoverage-plugin/target/scala-${ScoverageCompiler.ShortScalaVersion}/test-classes") + private def testClasses: File = new File(s"./scalac-scoverage-plugin/target/scala-${ScoverageCompiler.ScalaVersion}/test-classes") } diff --git a/scalac-scoverage-plugin/src/test/scala/scoverage/ScoverageCompiler.scala b/scalac-scoverage-plugin/src/test/scala/scoverage/ScoverageCompiler.scala index a5440a76..c2185c23 100644 --- a/scalac-scoverage-plugin/src/test/scala/scoverage/ScoverageCompiler.scala +++ b/scalac-scoverage-plugin/src/test/scala/scoverage/ScoverageCompiler.scala @@ -27,7 +27,7 @@ object ScoverageCompiler { s.Yposdebug.value = true s.classpath.value = classPath.mkString(File.pathSeparator) - val path = s"./scalac-scoverage-plugin/target/scala-$ShortScalaVersion/test-generated-classes" + val path = s"./scalac-scoverage-plugin/target/scala-$ScalaVersion/test-generated-classes" new File(path).mkdirs() s.d.value = path s @@ -49,13 +49,13 @@ object ScoverageCompiler { } private def sbtCompileDir: File = { - val dir = new File(s"./scalac-scoverage-plugin/target/scala-$ShortScalaVersion/classes") + val dir = new File(s"./scalac-scoverage-plugin/target/scala-$ScalaVersion/classes") if (!dir.exists) throw new FileNotFoundException(s"Could not locate SBT compile directory for plugin files [$dir]") dir } - private def runtimeClasses: File = new File(s"./scalac-scoverage-runtime/jvm/target/scala-$ShortScalaVersion/classes") + private def runtimeClasses: File = new File(s"./scalac-scoverage-runtime/jvm/target/scala-$ScalaVersion/classes") private def findScalaJar(artifactId: String): File = findIvyJar("org.scala-lang", artifactId, ScalaVersion) @@ -66,9 +66,11 @@ object ScoverageCompiler { private def findCoursierJar(artifactId: String, version: String): Option[File] = { val userHome = System.getProperty("user.home") - val jarPath = s"$userHome/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/$artifactId/$version/$artifactId-$version.jar" - val file = new File(jarPath) - if (file.exists()) Some(file) else None + val jarPaths = Seq( + s"$userHome/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/$artifactId/$version/$artifactId-$version.jar", + s"$userHome/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/$artifactId/$version/$artifactId-$version.jar", + ) + jarPaths.map(new File(_)).filter(_.exists()).headOption } private def findIvyJar(groupId: String, artifactId: String, version: String, packaging: String = "jar"): Option[File] = {