Skip to content

Commit ac3db32

Browse files
Build CrossVersion.full (#306)
* Use full version number for target/classes * Support newer versions of scala * Permitting tests to run on OSX * Overhauling github workflows to support publishing full compatibility artifacts
1 parent 148db8c commit ac3db32

File tree

7 files changed

+75
-88
lines changed

7 files changed

+75
-88
lines changed

.github/workflows/build.yml

+17-19
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,22 @@ on:
1212
- release/*
1313

1414
jobs:
15-
scala-2_12:
15+
scala:
1616
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
java: [ '11' ]
20+
scala: [
21+
{ version: '2.12.13' },
22+
{ version: '2.12.12' },
23+
{ version: '2.12.11' },
24+
{ version: '2.12.10' },
25+
{ version: '2.13.4' },
26+
{ version: '2.13.3' },
27+
{ version: '2.13.2' },
28+
{ version: '2.13.1' },
29+
{ version: '2.13.0' }
30+
]
1731
steps:
1832
- name: checkout the repo
1933
uses: actions/checkout@v2
@@ -23,23 +37,7 @@ jobs:
2337
- name: Set up JDK
2438
uses: actions/setup-java@v1
2539
with:
26-
java-version: 11
40+
java-version: ${{ matrix.java }}
2741

2842
- name: run tests
29-
run: sbt ++2.12.10 test
30-
31-
scala-2_13:
32-
runs-on: ubuntu-latest
33-
steps:
34-
- name: checkout the repo
35-
uses: actions/checkout@v2
36-
with:
37-
fetch-depth: 0
38-
39-
- name: Set up JDK
40-
uses: actions/setup-java@v1
41-
with:
42-
java-version: 11
43-
44-
- name: run tests
45-
run: sbt ++2.13.3 test
43+
run: sbt ++${{ matrix.scala.version }} test

.github/workflows/pr.yml

+17-19
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,22 @@ on:
88
- '*.md'
99

1010
jobs:
11-
scala-2_12:
11+
scala:
1212
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
java: [ '11' ]
16+
scala: [
17+
{ version: '2.12.13' },
18+
{ version: '2.12.12' },
19+
{ version: '2.12.11' },
20+
{ version: '2.12.10' },
21+
{ version: '2.13.4' },
22+
{ version: '2.13.3' },
23+
{ version: '2.13.2' },
24+
{ version: '2.13.1' },
25+
{ version: '2.13.0' }
26+
]
1327
steps:
1428
- name: checkout the repo
1529
uses: actions/checkout@v2
@@ -19,23 +33,7 @@ jobs:
1933
- name: Set up JDK
2034
uses: actions/setup-java@v1
2135
with:
22-
java-version: 11
36+
java-version: ${{ matrix.java }}
2337

2438
- name: run tests
25-
run: sbt ++2.12.10 test
26-
27-
scala-2_13:
28-
runs-on: ubuntu-latest
29-
steps:
30-
- name: checkout the repo
31-
uses: actions/checkout@v2
32-
with:
33-
fetch-depth: 0
34-
35-
- name: Set up JDK
36-
uses: actions/setup-java@v1
37-
with:
38-
java-version: 11
39-
40-
- name: run tests
41-
run: sbt ++2.13.3 test
39+
run: sbt ++${{ matrix.scala.version }} test

.github/workflows/release.yml

+17-40
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,22 @@ on:
1111
required: true
1212

1313
jobs:
14-
scala-2_12:
14+
scala:
1515
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
java: [ '11' ]
19+
scala: [
20+
{ version: '2.12.13' },
21+
{ version: '2.12.12' },
22+
{ version: '2.12.11' },
23+
{ version: '2.12.10' },
24+
{ version: '2.13.4' },
25+
{ version: '2.13.3' },
26+
{ version: '2.13.2' },
27+
{ version: '2.13.1' },
28+
{ version: '2.13.0' }
29+
]
1630
steps:
1731
- name: checkout the repo
1832
uses: actions/checkout@v2
@@ -22,7 +36,7 @@ jobs:
2236
- name: Set up JDK
2337
uses: actions/setup-java@v1
2438
with:
25-
java-version: 11
39+
java-version: ${{ matrix.java }}
2640

2741
- name: Import GPG key
2842
id: import_gpg
@@ -39,45 +53,8 @@ jobs:
3953
echo "email: ${{ steps.import_gpg.outputs.email }}"
4054
4155
- name: publish release
42-
run: sbt ++2.12.10 publishSigned
56+
run: sbt ++${{ matrix.scala.version }} publishSigned
4357
env:
4458
RELEASE_VERSION: ${{ github.event.inputs.version }}
4559
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
4660
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
47-
48-
scala-2_13:
49-
runs-on: ubuntu-latest
50-
steps:
51-
- name: checkout the repo
52-
uses: actions/checkout@v2
53-
with:
54-
fetch-depth: 0
55-
56-
- name: Set up JDK
57-
uses: actions/setup-java@v1
58-
with:
59-
java-version: 11
60-
61-
- name: Import GPG key
62-
id: import_gpg
63-
uses: crazy-max/ghaction-import-gpg@v3
64-
with:
65-
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
66-
passphrase: ${{ secrets.PGP_PASSPHRASE }}
67-
68-
- name: GPG user IDs
69-
run: |
70-
echo "fingerprint: ${{ steps.import_gpg.outputs.fingerprint }}"
71-
echo "keyid: ${{ steps.import_gpg.outputs.keyid }}"
72-
echo "name: ${{ steps.import_gpg.outputs.name }}"
73-
echo "email: ${{ steps.import_gpg.outputs.email }}"
74-
75-
- name: run tests
76-
run: sbt ++2.13.3 test
77-
78-
- name: publish release
79-
run: sbt ++2.13.3 publishSigned
80-
env:
81-
RELEASE_VERSION: ${{ github.event.inputs.version }}
82-
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
83-
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}

build.sbt

+7-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@ import sbtcrossproject.CrossType
77
val Org = "org.scoverage"
88
val ScalatestVersion = "3.1.1"
99

10+
val bin212 = Seq("2.12.13", "2.12.12", "2.12.11", "2.12.10")
11+
val bin213 = Seq("2.13.4", "2.13.3", "2.13.2", "2.13.1", "2.13.0")
12+
1013
val appSettings = Seq(
1114
organization := Org,
12-
scalaVersion := "2.12.10",
13-
crossScalaVersions := Seq("2.12.10", "2.13.4"),
15+
scalaVersion := "2.12.13",
16+
crossScalaVersions := bin212 ++ bin213,
17+
crossVersion := CrossVersion.full,
18+
crossTarget := target.value / s"scala-${scalaVersion.value}",
1419
fork in Test := false,
1520
publishMavenStyle := true,
1621
publishArtifact in Test := false,

scalac-scoverage-plugin/src/main/scala/scoverage/CoverageFilter.scala

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package scoverage
22

33
import scala.collection.mutable
44
import scala.reflect.internal.util.{Position, SourceFile}
5+
import scala.util.matching.Regex
56

67
/**
78
* Methods related to filtering the instrumentation and coverage.
@@ -72,6 +73,12 @@ class RegexCoverageFilter(excludedPackages: Seq[String],
7273
excludedSymbolPatterns.isEmpty || !excludedSymbolPatterns.exists(_.matcher(symbolName).matches)
7374
}
7475

76+
/**
77+
* Provides overloads to paper over 2.12.13+ SourceFile incompatibility
78+
*/
79+
def compatFindAllIn(regexp: Regex, pattern: Array[Char]): Regex.MatchIterator = regexp.findAllIn(new String(pattern))
80+
def compatFindAllIn(regexp: Regex, pattern: String): Regex.MatchIterator = regexp.findAllIn(pattern)
81+
7582
/**
7683
* Checks the given sourceFile for any magic comments which exclude lines
7784
* from coverage. Returns a list of Ranges of lines that should be excluded.
@@ -83,7 +90,7 @@ class RegexCoverageFilter(excludedPackages: Seq[String],
8390
linesExcludedByScoverageCommentsCache.get(sourceFile) match {
8491
case Some(lineNumbers) => lineNumbers
8592
case None =>
86-
val lineNumbers = scoverageExclusionCommentsRegex.findAllIn(sourceFile.content).matchData.map { m =>
93+
val lineNumbers = compatFindAllIn(scoverageExclusionCommentsRegex, sourceFile.content).matchData.map { m =>
8794
// Asking a SourceFile for the line number of the char after
8895
// the end of the file gives an exception
8996
val endChar = math.min(m.end(2), sourceFile.content.length - 1)

scalac-scoverage-plugin/src/test/scala/scoverage/MacroSupport.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ trait MacroSupport {
1313

1414
val macroSupportDeps = Seq(testClasses)
1515

16-
private def testClasses: File = new File(s"./scalac-scoverage-plugin/target/scala-${ScoverageCompiler.ShortScalaVersion}/test-classes")
16+
private def testClasses: File = new File(s"./scalac-scoverage-plugin/target/scala-${ScoverageCompiler.ScalaVersion}/test-classes")
1717

1818
}

scalac-scoverage-plugin/src/test/scala/scoverage/ScoverageCompiler.scala

+8-6
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ object ScoverageCompiler {
2727
s.Yposdebug.value = true
2828
s.classpath.value = classPath.mkString(File.pathSeparator)
2929

30-
val path = s"./scalac-scoverage-plugin/target/scala-$ShortScalaVersion/test-generated-classes"
30+
val path = s"./scalac-scoverage-plugin/target/scala-$ScalaVersion/test-generated-classes"
3131
new File(path).mkdirs()
3232
s.d.value = path
3333
s
@@ -49,13 +49,13 @@ object ScoverageCompiler {
4949
}
5050

5151
private def sbtCompileDir: File = {
52-
val dir = new File(s"./scalac-scoverage-plugin/target/scala-$ShortScalaVersion/classes")
52+
val dir = new File(s"./scalac-scoverage-plugin/target/scala-$ScalaVersion/classes")
5353
if (!dir.exists)
5454
throw new FileNotFoundException(s"Could not locate SBT compile directory for plugin files [$dir]")
5555
dir
5656
}
5757

58-
private def runtimeClasses: File = new File(s"./scalac-scoverage-runtime/jvm/target/scala-$ShortScalaVersion/classes")
58+
private def runtimeClasses: File = new File(s"./scalac-scoverage-runtime/jvm/target/scala-$ScalaVersion/classes")
5959

6060
private def findScalaJar(artifactId: String): File =
6161
findIvyJar("org.scala-lang", artifactId, ScalaVersion)
@@ -66,9 +66,11 @@ object ScoverageCompiler {
6666

6767
private def findCoursierJar(artifactId: String, version: String): Option[File] = {
6868
val userHome = System.getProperty("user.home")
69-
val jarPath = s"$userHome/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/$artifactId/$version/$artifactId-$version.jar"
70-
val file = new File(jarPath)
71-
if (file.exists()) Some(file) else None
69+
val jarPaths = Seq(
70+
s"$userHome/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/$artifactId/$version/$artifactId-$version.jar",
71+
s"$userHome/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/$artifactId/$version/$artifactId-$version.jar",
72+
)
73+
jarPaths.map(new File(_)).filter(_.exists()).headOption
7274
}
7375

7476
private def findIvyJar(groupId: String, artifactId: String, version: String, packaging: String = "jar"): Option[File] = {

0 commit comments

Comments
 (0)