Skip to content
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

clean: Merge all modules into one #508

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
172 changes: 70 additions & 102 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,108 +1,76 @@
inThisBuild(Seq(scalaVersion := "3.3.3"))

def commonSettings =
Seq(scalacOptions := {
val toFilter = Set("-deprecation:false")
scalacOptions.value.filterNot(toFilter) ++ Seq("-deprecation")
})

name := "codacy-coverage-reporter"

// Runtime dependencies
libraryDependencies ++= Seq(
"com.github.alexarchambault" %% "case-app" % "2.1.0-M28",
"org.wvlet.airframe" %% "airframe-log" % "24.6.0"
)

// Test dependencies
libraryDependencies ++= Seq(scalatest % "it,test", "org.scalamock" %% "scalamock" % "6.0.0" % Test)

assembly / mainClass := Some("com.codacy.CodacyCoverageReporter")
assembly / assemblyMergeStrategy := {
case PathList("META-INF", "MANIFEST.MF") => MergeStrategy.discard
case m if m.toLowerCase.matches("meta-inf.*\\.sf$") => MergeStrategy.discard
case _ => MergeStrategy.first
}
assembly / test := {}
crossPaths := false
run / fork := true

// HACK: Since we are only using the public resolvers we need to remove the private for it to not fail
resolvers ~= {
_.filterNot(_.name.toLowerCase.contains("codacy"))
}

description := "CLI to send coverage reports to Codacy through the API"

scmInfo := Some(
ScmInfo(
url("https://github.com/codacy/codacy-coverage-reporter"),
"scm:git:[email protected]:codacy/codacy-coverage-reporter.git"
)
)

Test / fork := true
Global / cancelable := true

javacOptions ++= Seq("-source", "11", "-target", "11")

enablePlugins(NativeImagePlugin)

nativeImageVersion := "22.3.0"

val osSpecificOptions =
if (sys.props("os.name") == "Mac OS X") Seq.empty[String]
else Seq("--static", "--libc=musl")

nativeImageOptions := Seq(
"--verbose",
"--no-server",
"--enable-http",
"--enable-https",
"--enable-url-protocols=http,https,jar",
"--enable-all-security-services",
"-H:+JNI",
"-H:IncludeResourceBundles=com.sun.org.apache.xerces.internal.impl.msg.XMLMessages",
"-H:+ReportExceptionStackTraces",
"--no-fallback",
"--report-unsupported-elements-at-runtime"
) ++ osSpecificOptions

dependsOn(coverageParser)

commonSettings

val scalatest = "org.scalatest" %% "scalatest" % "3.2.18"

lazy val apiScala = project
.in(file("api-scala"))
lazy val root = project
.in(file("."))
.settings(
commonSettings,
scalaVersion := "3.3.3",
scalacOptions := {
val toFilter = Set("-deprecation:false")
scalacOptions.value.filterNot(toFilter) ++ Seq("-deprecation")
},
name := "codacy-coverage-reporter",
// Runtime dependencies
libraryDependencies ++= Seq(
"com.github.alexarchambault" %% "case-app" % "2.1.0-M28",
"org.wvlet.airframe" %% "airframe-log" % "24.6.0",
"com.codacy" %% "codacy-plugins-api" % "8.1.4",
"org.scala-lang.modules" %% "scala-xml" % "2.3.0",
"com.typesafe.play" %% "play-json" % "2.10.5",
("org.scalaj" %% "scalaj-http" % "2.4.2").cross(CrossVersion.for3Use2_13),
"org.eclipse.jgit" % "org.eclipse.jgit" % "4.11.9.201909030838-r",
scalatest % Test
)
)

lazy val coverageParser = project
.in(file("coverage-parser"))
.settings(
commonSettings,
"org.eclipse.jgit" % "org.eclipse.jgit" % "4.11.9.201909030838-r"
),
// Test dependencies
libraryDependencies ++= Seq(
"com.codacy" %% "codacy-plugins-api" % "8.1.4",
"org.scala-lang.modules" %% "scala-xml" % "2.3.0",
scalatest % Test
)
"org.scalatest" %% "scalatest" % "3.2.18" % "it,test",
"org.scalamock" %% "scalamock" % "6.0.0" % Test
),
assembly / mainClass := Some("com.codacy.CodacyCoverageReporter"),
assembly / assemblyMergeStrategy := {
case PathList("META-INF", "MANIFEST.MF") => MergeStrategy.discard
case m if m.toLowerCase.matches("meta-inf.*\\.sf$") => MergeStrategy.discard
case _ => MergeStrategy.first
},
assembly / test := {},
crossPaths := false,
run / fork := true,
// HACK: Since we are only using the public resolvers we need to remove the private for it to not fail
resolvers ~= {
_.filterNot(_.name.toLowerCase.contains("codacy"))
},
description := "CLI to send coverage reports to Codacy through the API",
scmInfo := Some(
ScmInfo(
url("https://github.com/codacy/codacy-coverage-reporter"),
"scm:git:[email protected]:codacy/codacy-coverage-reporter.git"
)
),
Test / fork := true,
Global / cancelable := true,
javacOptions ++= Seq("-source", "11", "-target", "11"),
nativeImageVersion := "22.3.0", {
val osSpecificOptions =
if (sys.props("os.name") == "Mac OS X") Seq.empty[String]
else Seq("--static", "--libc=musl")

nativeImageOptions := Seq(
"--verbose",
"--no-server",
"--enable-http",
"--enable-https",
"--enable-url-protocols=http,https,jar",
"--enable-all-security-services",
"-H:+JNI",
"-H:IncludeResourceBundles=com.sun.org.apache.xerces.internal.impl.msg.XMLMessages",
"-H:+ReportExceptionStackTraces",
"--no-fallback",
"--report-unsupported-elements-at-runtime"
) ++ osSpecificOptions
},
// https://github.com/sbt/sbt-assembly/issues/146
assemblyMergeStrategy := {
case PathList("module-info.class") => MergeStrategy.discard
case x if x.endsWith("/module-info.class") => MergeStrategy.discard
case x =>
val oldStrategy = (ThisBuild / assemblyMergeStrategy).value
oldStrategy(x)
}
)
.dependsOn(apiScala)

// https://github.com/sbt/sbt-assembly/issues/146
ThisBuild / assemblyMergeStrategy := {
case PathList("module-info.class") => MergeStrategy.discard
case x if x.endsWith("/module-info.class") => MergeStrategy.discard
case x =>
val oldStrategy = (ThisBuild / assemblyMergeStrategy).value
oldStrategy(x)
}
.enablePlugins(NativeImagePlugin)
9 changes: 0 additions & 9 deletions coverage-parser/src/test/resources/test_lcov.lcov

This file was deleted.

4 changes: 2 additions & 2 deletions src/test/resources/test-paths-with-different-paths.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<packages>
<package line-rate="0.87" name="com.github.theon.coveralls">
<classes>
<class line-rate="0.87" name="TestSourceFile" filename="coverage-parser\src\test\resources\TESTSOURCEFile.scala">
<class line-rate="0.87" name="TestSourceFile" filename="src\test\resources\TESTSOURCEFile.scala">
<methods/>
<lines>
<line number="3" hits="0"/>
Expand All @@ -11,7 +11,7 @@
<line number="6" hits="2"/>
</lines>
</class>
<class line-rate="0.87" name="TestSourceFile2" filename="coverage-parser\src\test\resources\TeStSOuRcEfIle2.scala">
<class line-rate="0.87" name="TestSourceFile2" filename="src\test\resources\TeStSOuRcEfIle2.scala">
<methods/>
<lines>
<line number="1" hits="1"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<packages>
<package line-rate="0.87" name="com.github.theon.coveralls">
<classes>
<class line-rate="0.87" name="TestSourceFile" filename="coverage-parser/src/test/resources/TestSourceFile.scala">
<class line-rate="0.87" name="TestSourceFile" filename="src/test/resources/TestSourceFile.scala">
<methods/>
<lines>
<line number="3" hits="0"/>
Expand All @@ -16,14 +16,14 @@
<line number="9" hits="9999999999999999"/>
</lines>
</class>
<class line-rate="0.87" name="TestSourceFile" filename="coverage-parser/src/test/resources/TestSourceFile.scala">
<class line-rate="0.87" name="TestSourceFile" filename="src/test/resources/TestSourceFile.scala">
<methods/>
<lines>
<line number="9" hits="1"/>
<line number="10" hits="1"/>
</lines>
</class>
<class line-rate="0.87" name="TestSourceFile2" filename="coverage-parser/src/test/resources/TestSourceFile2.scala">
<class line-rate="0.87" name="TestSourceFile2" filename="src/test/resources/TestSourceFile2.scala">
<methods/>
<lines>
<line number="1" hits="1"/>
Expand Down
9 changes: 9 additions & 0 deletions src/test/resources/test_lcov.lcov
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
SF:src/test/resources/TestSourceFile.scala
DA:3,0
DA:4,1
DA:5,1
DA:6,2
SF:src/test/resources/TestSourceFile2.scala
DA:1,1
DA:2,1
DA:3,1
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
<packages>
<package line-rate="0,87" name="com.github.theon.coveralls">
<classes>
<class line-rate="0,87" name="TestSourceFile" filename="coverage-parser/src/test/resources/TestSourceFile.scala">
<class line-rate="0,87" name="TestSourceFile" filename="src/test/resources/TestSourceFile.scala">
<methods/>
<lines>
<line number="4" hits="1"/>
<line number="5" hits="1"/>
<line number="6" hits="2"/>
</lines>
</class>
<class line-rate="0,87" name="TestSourceFile" filename="coverage-parser/src/test/resources/TestSourceFile.scala">
<class line-rate="0,87" name="TestSourceFile" filename="src/test/resources/TestSourceFile.scala">
<methods/>
<lines>
<line number="8" hits="1"/>
<line number="9" hits="0"/>
<line number="10" hits="1"/>
</lines>
</class>
<class line-rate="0,87" name="TestSourceFile2" filename="coverage-parser/src/test/resources/TestSourceFile2.scala">
<class line-rate="0,87" name="TestSourceFile2" filename="src/test/resources/TestSourceFile2.scala">
<methods/>
<lines>
<line number="1" hits="1"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<packages>
<package line-rate="0.87" name="com.github.theon.coveralls">
<classes>
<class line-rate="0.87" name="TestSourceFile" filename="coverage-parser\src\test\resources\TestSourceFile.scala">
<class line-rate="0.87" name="TestSourceFile" filename="src\test\resources\TestSourceFile.scala">
<methods/>
<lines>
<line number="3" hits="0"/>
Expand All @@ -11,14 +11,14 @@
<line number="6" hits="2"/>
</lines>
</class>
<class line-rate="0.87" name="TestSourceFile" filename="coverage-parser\src\test\resources\TestSourceFile.scala">
<class line-rate="0.87" name="TestSourceFile" filename="src\test\resources\TestSourceFile.scala">
<methods/>
<lines>
<line number="9" hits="1"/>
<line number="10" hits="1"/>
</lines>
</class>
<class line-rate="0.87" name="TestSourceFile2" filename="coverage-parser\src\test\resources\TestSourceFile2.scala">
<class line-rate="0.87" name="TestSourceFile2" filename="src\test\resources\TestSourceFile2.scala">
<methods/>
<lines>
<line number="1" hits="1"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ class CloverParserTest extends AnyWordSpec with Matchers with EitherValues {

"the report file does not exist" in {
// Arrange
val nonExistentReportPath = "coverage-parser/src/test/resources/non-existent.xml"
val nonExistentReportPath = "src/test/resources/non-existent.xml"

// Act
val parseResult = CloverParser.parse(new File("."), new File(nonExistentReportPath))

// Assert
val error = parseResult.left.value
error should startWith("Unparseable report. ")
error should endWith("coverage-parser/src/test/resources/non-existent.xml (No such file or directory)")
error should endWith("src/test/resources/non-existent.xml (No such file or directory)")
}

"the report is not in the Clover format" in {
// Arrange
val reportNotInCloverFormat = "coverage-parser/src/test/resources/test_cobertura.xml"
val reportNotInCloverFormat = "src/test/resources/test_cobertura.xml"

// Act
val parseResult = CloverParser.parse(new File("."), new File(reportNotInCloverFormat))
Expand All @@ -38,8 +38,8 @@ class CloverParserTest extends AnyWordSpec with Matchers with EitherValues {
}
}

val cloverReportPath = "coverage-parser/src/test/resources/test_clover.xml"
val cloverWithoutPackagesFilePath = "coverage-parser/src/test/resources/test_clover_without_packages.xml"
val cloverReportPath = "src/test/resources/test_clover.xml"
val cloverWithoutPackagesFilePath = "src/test/resources/test_clover_without_packages.xml"

"succeed to parse a valid report" when {

Expand All @@ -66,7 +66,7 @@ class CloverParserTest extends AnyWordSpec with Matchers with EitherValues {

"reports contain both name and path attributes in file tags" in {
// Arrange
val cloverWithPaths = new File("coverage-parser/src/test/resources/test_clover_with_paths.xml")
val cloverWithPaths = new File("src/test/resources/test_clover_with_paths.xml")

// Act
val parsedReportFilePaths =
Expand Down
Loading