Skip to content

Build CrossVersion.full #306

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 4 commits into from
Feb 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 17 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
run: sbt ++${{ matrix.scala.version }} test
36 changes: 17 additions & 19 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
run: sbt ++${{ matrix.scala.version }} test
57 changes: 17 additions & 40 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 }}
9 changes: 7 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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] = {
Expand Down