diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 98eb49d0b..9cc159f7a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,77 +1,272 @@ -name: CI +# This file was automatically generated by sbt-github-actions using the +# githubWorkflowGenerate task. You should add and commit this file to +# your git repository. It goes without saying that you shouldn't edit +# this file by hand! Instead, if you wish to make changes, you should +# change your sbt build configuration to revise the workflow description +# to meet your needs, then regenerate this file. + +name: Continuous Integration + on: pull_request: + branches: [main] push: - branches: - - main + branches: [main] + tags: [v*] + +env: + PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + SONATYPE_CREDENTIAL_HOST: ${{ secrets.SONATYPE_CREDENTIAL_HOST }} + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + PGP_SECRET: ${{ secrets.PGP_SECRET }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} jobs: - checks: - runs-on: ubuntu-latest + build: + name: Build and Test + strategy: + matrix: + os: [ubuntu-latest] + scala: [2.13.10, 2.12.17] + java: [corretto@11, corretto@8] + exclude: + - scala: 2.12.17 + java: corretto@8 + runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 - - name: Cache sbt - uses: coursier/cache-action@v5 - - name: Java 11 setup - uses: olafurpg/setup-scala@v10 + - name: Checkout current branch (full) + uses: actions/checkout@v3 with: - java-version: 1.11.0 - - run: sbt +headerCheckAll +scalafmtCheckAll scalafmtSbtCheck + fetch-depth: 0 + + - name: Download Java (corretto@11) + id: download-java-corretto-11 + if: matrix.java == 'corretto@11' + uses: typelevel/download-java@v2 + with: + distribution: corretto + java-version: 11 + + - name: Setup Java (corretto@11) + if: matrix.java == 'corretto@11' + uses: actions/setup-java@v3 + with: + distribution: jdkfile + java-version: 11 + jdkFile: ${{ steps.download-java-corretto-11.outputs.jdkFile }} + + - name: Download Java (corretto@8) + id: download-java-corretto-8 + if: matrix.java == 'corretto@8' + uses: typelevel/download-java@v2 + with: + distribution: corretto + java-version: 8 + + - name: Setup Java (corretto@8) + if: matrix.java == 'corretto@8' + uses: actions/setup-java@v3 + with: + distribution: jdkfile + java-version: 8 + jdkFile: ${{ steps.download-java-corretto-8.outputs.jdkFile }} - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - name: Cache sbt - uses: coursier/cache-action@v5 - - name: Java ${{matrix.java}} setup - uses: olafurpg/setup-scala@v10 + uses: actions/cache@v3 with: - java-version: ${{matrix.java}} - - run: sbt "++${{matrix.scala}} test" + path: | + ~/.sbt + ~/.ivy2/cache + ~/.coursier/cache/v1 + ~/.cache/coursier/v1 + ~/AppData/Local/Coursier/Cache/v1 + ~/Library/Caches/Coursier/v1 + key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} + + - name: Check that workflows are up to date + run: sbt githubWorkflowCheck + + - name: Build project + if: matrix.scala == '2.13.10' && matrix.java == 'corretto@11' + run: sbt '++ ${{ matrix.scala }}' coverage test coverageAggregate + + - name: Upload coverage report + if: matrix.scala == '2.13.10' && matrix.java == 'corretto@11' + run: 'bash <(curl -s https://codecov.io/bash)' + + - name: Build project + if: '!(matrix.scala == ''2.13.10'' && matrix.java == ''corretto@11'')' + run: sbt '++ ${{ matrix.scala }}' test + + - name: Make target directories + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') + run: mkdir -p test/target refined/target target shared/target tensorflow/target parquet/target tools/target protobuf/target jmh/target bigquery/target avro/target scalacheck/target datastore/target neo4j/target cats/target bigtable/target guava/target project/target + + - name: Compress target directories + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') + run: tar cf targets.tar test/target refined/target target shared/target tensorflow/target parquet/target tools/target protobuf/target jmh/target bigquery/target avro/target scalacheck/target datastore/target neo4j/target cats/target bigtable/target guava/target project/target + + - name: Upload target directories + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') + uses: actions/upload-artifact@v3 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-${{ matrix.scala }} + path: targets.tar + + publish: + name: Publish Artifacts + needs: [build] + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') strategy: matrix: - java: - - 1.8.0 - - 1.11.0 - scala: - - 2.12.17 - - 2.13.10 - -# scala3: -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v2 -# - name: Cache sbt -# uses: coursier/cache-action@v5 -# - name: Java ${{matrix.java}} setup -# uses: olafurpg/setup-scala@v10 -# with: -# java-version: 1.11.0 -# - run: sbt "++3.1.2! $module/test" - - avro: - runs-on: ubuntu-latest + os: [ubuntu-latest] + scala: [2.13.10] + java: [corretto@11] + runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 + - name: Checkout current branch (full) + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Download Java (corretto@11) + id: download-java-corretto-11 + if: matrix.java == 'corretto@11' + uses: typelevel/download-java@v2 + with: + distribution: corretto + java-version: 11 + + - name: Setup Java (corretto@11) + if: matrix.java == 'corretto@11' + uses: actions/setup-java@v3 + with: + distribution: jdkfile + java-version: 11 + jdkFile: ${{ steps.download-java-corretto-11.outputs.jdkFile }} + + - name: Download Java (corretto@8) + id: download-java-corretto-8 + if: matrix.java == 'corretto@8' + uses: typelevel/download-java@v2 + with: + distribution: corretto + java-version: 8 + + - name: Setup Java (corretto@8) + if: matrix.java == 'corretto@8' + uses: actions/setup-java@v3 + with: + distribution: jdkfile + java-version: 8 + jdkFile: ${{ steps.download-java-corretto-8.outputs.jdkFile }} + - name: Cache sbt - uses: coursier/cache-action@v5 - - name: Java 11 setup - uses: olafurpg/setup-scala@v10 + uses: actions/cache@v3 + with: + path: | + ~/.sbt + ~/.ivy2/cache + ~/.coursier/cache/v1 + ~/.cache/coursier/v1 + ~/AppData/Local/Coursier/Cache/v1 + ~/Library/Caches/Coursier/v1 + key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} + + - name: Download target directories (2.13.10) + uses: actions/download-artifact@v3 with: - java-version: 1.11.0 - - run: sbt -Davro.version=1.8.2 test + name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.10 + + - name: Inflate target directories (2.13.10) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (2.12.17) + uses: actions/download-artifact@v3 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.17 + + - name: Inflate target directories (2.12.17) + run: | + tar xf targets.tar + rm targets.tar + + - name: Import signing key + if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE == '' + run: echo $PGP_SECRET | base64 -di | gpg --import + + - name: Import signing key and strip passphrase + if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE != '' + run: | + echo "$PGP_SECRET" | base64 -di > /tmp/signing-key.gpg + echo "$PGP_PASSPHRASE" | gpg --pinentry-mode loopback --passphrase-fd 0 --import /tmp/signing-key.gpg + (echo "$PGP_PASSPHRASE"; echo; echo) | gpg --command-fd 0 --pinentry-mode loopback --change-passphrase $(gpg --list-secret-keys --with-colons 2> /dev/null | grep '^sec:' | cut --delimiter ':' --fields 5 | tail -n 1) + + - name: Publish + run: sbt '++ ${{ matrix.scala }}' tlRelease - coverage: - runs-on: ubuntu-latest + avro-legacy: + name: Test with legacy avro + strategy: + matrix: + os: [ubuntu-latest] + scala: [2.13.10] + java: [corretto@11] + runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 + - name: Checkout current branch (full) + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Download Java (corretto@11) + id: download-java-corretto-11 + if: matrix.java == 'corretto@11' + uses: typelevel/download-java@v2 + with: + distribution: corretto + java-version: 11 + + - name: Setup Java (corretto@11) + if: matrix.java == 'corretto@11' + uses: actions/setup-java@v3 + with: + distribution: jdkfile + java-version: 11 + jdkFile: ${{ steps.download-java-corretto-11.outputs.jdkFile }} + + - name: Download Java (corretto@8) + id: download-java-corretto-8 + if: matrix.java == 'corretto@8' + uses: typelevel/download-java@v2 + with: + distribution: corretto + java-version: 8 + + - name: Setup Java (corretto@8) + if: matrix.java == 'corretto@8' + uses: actions/setup-java@v3 + with: + distribution: jdkfile + java-version: 8 + jdkFile: ${{ steps.download-java-corretto-8.outputs.jdkFile }} + - name: Cache sbt - uses: coursier/cache-action@v5 - - name: Java 11 setup - uses: olafurpg/setup-scala@v10 - with: - java-version: 1.11.0 - - run: | - sbt coverage test coverageAggregate - bash <(curl -s https://codecov.io/bash) + uses: actions/cache@v3 + with: + path: | + ~/.sbt + ~/.ivy2/cache + ~/.coursier/cache/v1 + ~/.cache/coursier/v1 + ~/AppData/Local/Coursier/Cache/v1 + ~/Library/Caches/Coursier/v1 + key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} + + - name: Build project + env: + JAVA_OPTS: '-Davro.version=1.8.2' + run: sbt '++ ${{ matrix.scala }}' avro/test diff --git a/.github/workflows/clean.yml b/.github/workflows/clean.yml new file mode 100644 index 000000000..547aaa43e --- /dev/null +++ b/.github/workflows/clean.yml @@ -0,0 +1,59 @@ +# This file was automatically generated by sbt-github-actions using the +# githubWorkflowGenerate task. You should add and commit this file to +# your git repository. It goes without saying that you shouldn't edit +# this file by hand! Instead, if you wish to make changes, you should +# change your sbt build configuration to revise the workflow description +# to meet your needs, then regenerate this file. + +name: Clean + +on: push + +jobs: + delete-artifacts: + name: Delete Artifacts + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: Delete artifacts + run: | + # Customize those three lines with your repository and credentials: + REPO=${GITHUB_API_URL}/repos/${{ github.repository }} + + # A shortcut to call GitHub API. + ghapi() { curl --silent --location --user _:$GITHUB_TOKEN "$@"; } + + # A temporary file which receives HTTP response headers. + TMPFILE=/tmp/tmp.$$ + + # An associative array, key: artifact name, value: number of artifacts of that name. + declare -A ARTCOUNT + + # Process all artifacts on this repository, loop on returned "pages". + URL=$REPO/actions/artifacts + while [[ -n "$URL" ]]; do + + # Get current page, get response headers in a temporary file. + JSON=$(ghapi --dump-header $TMPFILE "$URL") + + # Get URL of next page. Will be empty if we are at the last page. + URL=$(grep '^Link:' "$TMPFILE" | tr ',' '\n' | grep 'rel="next"' | head -1 | sed -e 's/.*.*//') + rm -f $TMPFILE + + # Number of artifacts on this page: + COUNT=$(( $(jq <<<$JSON -r '.artifacts | length') )) + + # Loop on all artifacts on this page. + for ((i=0; $i < $COUNT; i++)); do + + # Get name of artifact and count instances of this name. + name=$(jq <<<$JSON -r ".artifacts[$i].name?") + ARTCOUNT[$name]=$(( $(( ${ARTCOUNT[$name]} )) + 1)) + + id=$(jq <<<$JSON -r ".artifacts[$i].id?") + size=$(( $(jq <<<$JSON -r ".artifacts[$i].size_in_bytes?") )) + printf "Deleting '%s' #%d, %'d bytes\n" $name ${ARTCOUNT[$name]} $size + ghapi -X DELETE $REPO/actions/artifacts/$id + done + done diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 15ba106fd..000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: release -on: - push: - branches: [main] - tags: ["*"] -jobs: - publish: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2.4.0 - with: - fetch-depth: 0 - - name: cache SBT - uses: coursier/cache-action@v6 - - name: Java 11 setup - uses: olafurpg/setup-scala@v10 - with: - java-version: 1.11.0 - - uses: olafurpg/setup-gpg@v3 - - name: Publish ${{ github.ref }} - run: sbt ci-release - env: - PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} - PGP_SECRET: ${{ secrets.PGP_SECRET }} - SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} - SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} diff --git a/build.sbt b/build.sbt index 007791d07..c8058419d 100644 --- a/build.sbt +++ b/build.sbt @@ -13,10 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import _root_.io.github.davidgregory084._ -import _root_.io.github.davidgregory084.ScalaVersion._ import sbtprotoc.ProtocPlugin.ProtobufConfig -import scala.Ordering.Implicits._ val magnoliaScala2Version = "1.1.2" val magnoliaScala3Version = "1.1.4" @@ -42,52 +39,115 @@ val shapelessVersion = "2.3.10" val tensorflowMetadataVersion = "1.10.0" val tensorflowVersion = "0.4.2" -lazy val currentYear = java.time.LocalDate.now().getYear -lazy val keepExistingHeader = - HeaderCommentStyle.cStyleBlockComment.copy(commentCreator = - (text: String, existingText: Option[String]) => - existingText - .getOrElse(HeaderCommentStyle.cStyleBlockComment.commentCreator(text)) - .trim() - ) - -ThisBuild / tpolecatDefaultOptionsMode := DevMode -ThisBuild / tpolecatDevModeOptions ~= { opts => - val excludes = Set( - ScalacOptions.lintPackageObjectClasses, - ScalacOptions.privateWarnDeadCode, - ScalacOptions.privateWarnValueDiscard, - ScalacOptions.warnDeadCode, - ScalacOptions.warnValueDiscard +// project +ThisBuild / tlBaseVersion := "0.6" +ThisBuild / organization := "com.spotify" +ThisBuild / organizationName := "Spotify AB" +ThisBuild / startYear := Some(2016) +ThisBuild / licenses := Seq(License.Apache2) +ThisBuild / developers := List( + Developer( + id = "sinisa_lyh", + name = "Neville Li", + email = "neville.lyh@gmail.com", + url = url("https://twitter.com/sinisa_lyh") + ), + Developer( + id = "andrewsmartin", + name = "Andrew Martin", + email = "andrewsmartin.mg@gmail.com", + url = url("https://twitter.com/andrew_martin92") + ), + Developer( + id = "daikeshi", + name = "Keshi Dai", + email = "keshi.dai@gmail.com", + url = url("https://twitter.com/daikeshi") + ), + Developer( + id = "clairemcginty", + name = "Claire McGinty", + email = "clairem@spotify.com", + url = url("http://github.com/clairemcginty") + ), + Developer( + id = "anne-decusatis", + name = "Anne DeCusatis", + email = "anned@spotify.com", + url = url("http://twitter.com/precisememory") + ), + Developer( + id = "stormy-ua", + name = "Kirill Panarin", + email = "kirill.panarin@gmail.com", + url = url("https://twitter.com/panarin_kirill") + ), + Developer( + id = "syodage", + name = "Shameera Rathnayaka Yodage", + email = "shameerayodage@gmail.com", + url = url("https://twitter.com/syodage") + ), + Developer( + id = "shnapz", + name = "Andrew Kabas", + email = "akabas@spotify.com", + url = url("https://github.com/shnapz") ) +) - val extras = Set( - // required by magnolia for accessing default values - ScalacOptions.privateOption("retain-trees", _ >= V3_0_0), - // allow some nested auto derivation - ScalacOptions.advancedOption("max-inlines", List("64"), _ >= V3_0_0), - ScalacOptions.warnOption("macros:after", _.isBetween(V2_13_0, V3_0_0)), - ScalacOptions.privateWarnOption("macros:after", _.isBetween(V2_12_0, V2_13_0)), - ScalacOptions.privateBackendParallelism(), - ScalacOptions.release("8"), - // silence cross-build unused imports - ScalacOptions.warnOption( - "conf:cat=unused-imports&origin=scala\\.collection\\.compat\\..*:s" + - ",cat=unused-imports&origin=magnolify\\.shims\\..*:s", - _.isBetween(V2_13_2, V3_0_0) - ) - ) +// scala versions +val scala3 = "3.2.1" +val scala213 = "2.13.10" +val scala212 = "2.12.17" +val defaultScala = scala213 - opts.filterNot(excludes).union(extras) -} +// github actions +val java11 = JavaSpec.corretto("11") +val java8 = JavaSpec.corretto("8") +val defaultJava = java11 +val coverageCond = Seq( + s"matrix.scala == '$defaultScala'", + s"matrix.java == '${defaultJava.render}'" +).mkString(" && ") -ThisBuild / javacOptions ++= Seq( - "-source", - "1.8", - "-target", - "1.8" +ThisBuild / scalaVersion := defaultScala +ThisBuild / crossScalaVersions := Seq(scala213, scala212) +ThisBuild / githubWorkflowTargetBranches := Seq("main") +ThisBuild / githubWorkflowJavaVersions := Seq(java11, java8) +ThisBuild / githubWorkflowBuild := Seq( + WorkflowStep.Sbt( + List("coverage", "test", "coverageAggregate"), + name = Some("Build project"), + cond = Some(coverageCond) + ), + WorkflowStep.Run( + List("bash <(curl -s https://codecov.io/bash)"), + name = Some("Upload coverage report"), + cond = Some(coverageCond) + ), + WorkflowStep.Sbt( + List("test"), + name = Some("Build project"), + cond = Some(s"!($coverageCond)")) +) +ThisBuild / githubWorkflowAddedJobs ++= Seq( + WorkflowJob( + "avro-legacy", + "Test with legacy avro", + githubWorkflowJobSetup.value.toList ::: List( + WorkflowStep.Sbt( + List("avro/test"), + env = Map("JAVA_OPTS" -> "-Davro.version=1.8.2"), + name = Some("Build project") + ) + ), + scalas = List(defaultScala), + javas = List(defaultJava) + ) ) +// protobuf ThisBuild / PB.protocVersion := protobufVersion lazy val scopedProtobufSettings = Def.settings( PB.targets := Seq( @@ -97,17 +157,55 @@ lazy val scopedProtobufSettings = Def.settings( ), managedSourceDirectories ++= PB.targets.value.map(_.outputPath) ) - lazy val protobufSettings = Seq( PB.additionalDependencies := Seq( "com.google.protobuf" % "protobuf-java" % protobufVersion % Provided ) ) ++ Seq(Compile, Test).flatMap(c => inConfig(c)(scopedProtobufSettings)) +lazy val currentYear = java.time.LocalDate.now().getYear +lazy val keepExistingHeader = + HeaderCommentStyle.cStyleBlockComment.copy(commentCreator = + (text: String, existingText: Option[String]) => + existingText + .getOrElse(HeaderCommentStyle.cStyleBlockComment.commentCreator(text)) + .trim() + ) + val commonSettings = Seq( - organization := "com.spotify", - crossScalaVersions := Seq("2.13.10", "2.12.17"), - scalaVersion := crossScalaVersions.value.head, + tlFatalWarningsInCi := false, + tlJdkRelease := Some(8), + tlSkipIrrelevantScalas := true, + scalacOptions ++= { + CrossVersion.partialVersion(scalaVersion.value) match { + case Some((3, _)) => + Seq( + // required by magnolia for accessing default values + "-Xretain-trees", + // tolerate some nested macro expansion + "-Ymax-inlines", + "64" + ) + case Some((2, 13)) => + Seq( + // silence warnings + "-Wmacros:after", + "-Wconf:cat=unused-imports&origin=scala\\.collection\\.compat\\..*:s" + + ",cat=unused-imports&origin=magnolify\\.shims\\..*:s" + ) + case Some((2, 12)) => + Seq( + "-Ywarn-macros:after" + ) + case _ => + Seq.empty + } + }, + headerLicense := Some(HeaderLicense.ALv2(currentYear.toString, organizationName.value)), + headerMappings ++= Map( + HeaderFileType.scala -> keepExistingHeader, + HeaderFileType.java -> keepExistingHeader + ), libraryDependencies ++= { CrossVersion.partialVersion(scalaVersion.value) match { case Some((3, _)) => @@ -128,87 +226,14 @@ val commonSettings = Seq( }, // https://github.com/typelevel/scalacheck/pull/427#issuecomment-424330310 // FIXME: workaround for Java serialization issues - Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat, - Test / publishArtifact := false, - sonatypeProfileName := "com.spotify", - organizationName := "Spotify AB", - startYear := Some(2016), - licenses := Seq("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt")), - headerLicense := Some(HeaderLicense.ALv2(currentYear.toString, "Spotify AB")), - headerMappings ++= Map( - HeaderFileType.scala -> keepExistingHeader, - HeaderFileType.java -> keepExistingHeader - ), - homepage := Some(url("https://github.com/spotify/magnolify")), - scmInfo := Some( - ScmInfo( - url("https://github.com/spotify/magnolify.git"), - "scm:git:git@github.com:spotify/magnolify.git" - ) - ), - developers := List( - Developer( - id = "sinisa_lyh", - name = "Neville Li", - email = "neville.lyh@gmail.com", - url = url("https://twitter.com/sinisa_lyh") - ), - Developer( - id = "andrewsmartin", - name = "Andrew Martin", - email = "andrewsmartin.mg@gmail.com", - url = url("https://twitter.com/andrew_martin92") - ), - Developer( - id = "daikeshi", - name = "Keshi Dai", - email = "keshi.dai@gmail.com", - url = url("https://twitter.com/daikeshi") - ), - Developer( - id = "clairemcginty", - name = "Claire McGinty", - email = "clairem@spotify.com", - url = url("http://github.com/clairemcginty") - ), - Developer( - id = "anne-decusatis", - name = "Anne DeCusatis", - email = "anned@spotify.com", - url = url("http://twitter.com/precisememory") - ), - Developer( - id = "stormy-ua", - name = "Kirill Panarin", - email = "kirill.panarin@gmail.com", - url = url("https://twitter.com/panarin_kirill") - ), - Developer( - id = "syodage", - name = "Shameera Rathnayaka Yodage", - email = "shameerayodage@gmail.com", - url = url("https://twitter.com/syodage") - ), - Developer( - id = "shnapz", - name = "Andrew Kabas", - email = "akabas@spotify.com", - url = url("https://github.com/shnapz") - ) - ) -) - -val noPublishSettings = Seq( - publish := {}, - publishLocal := {}, - publishArtifact := false + Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat ) -lazy val root: Project = project +lazy val root = project .in(file(".")) + .enablePlugins(NoPublishPlugin) .settings( commonSettings, - noPublishSettings, name := "magnolify", description := "A collection of Magnolia add-on modules" ) @@ -230,7 +255,7 @@ lazy val root: Project = project tools ) -lazy val shared: Project = project +lazy val shared = project .in(file("shared")) .settings( commonSettings, @@ -239,33 +264,38 @@ lazy val shared: Project = project ) // shared code for unit tests -lazy val test: Project = project +lazy val test = project .in(file("test")) + .enablePlugins(NoPublishPlugin) + .dependsOn(shared) .settings( commonSettings, - noPublishSettings, libraryDependencies ++= Seq( "org.scalameta" %% "munit-scalacheck" % munitVersion % Test, "org.typelevel" %% "cats-core" % catsVersion % Test ) ) - .dependsOn(shared) -lazy val scalacheck: Project = project +lazy val scalacheck = project .in(file("scalacheck")) + .dependsOn( + shared, + test % "test->test" + ) .settings( commonSettings, moduleName := "magnolify-scalacheck", description := "Magnolia add-on for ScalaCheck", libraryDependencies += "org.scalacheck" %% "scalacheck" % scalacheckVersion % Provided ) + +lazy val cats = project + .in(file("cats")) .dependsOn( shared, + scalacheck % "test->test", test % "test->test" ) - -lazy val cats: Project = project - .in(file("cats")) .settings( commonSettings, moduleName := "magnolify-cats", @@ -276,14 +306,14 @@ lazy val cats: Project = project "org.typelevel" %% "cats-laws" % catsVersion % Test ) ) + +lazy val guava = project + .in(file("guava")) .dependsOn( shared, scalacheck % "test->test", test % "test->test" ) - -lazy val guava: Project = project - .in(file("guava")) .settings( commonSettings, moduleName := "magnolify-guava", @@ -292,14 +322,19 @@ lazy val guava: Project = project "com.google.guava" % "guava" % guavaVersion % Provided ) ) + +lazy val refined = project + .in(file("refined")) .dependsOn( - shared, - scalacheck % "test->test", + avro % Provided, + bigquery % Provided, + bigtable % Provided, + datastore % Provided, + guava % "provided,test->test", + protobuf % "provided,test->test", + tensorflow % Provided, test % "test->test" ) - -lazy val refined: Project = project - .in(file("refined")) .settings( commonSettings, moduleName := "magnolify-refined", @@ -315,19 +350,15 @@ lazy val refined: Project = project "org.tensorflow" % "tensorflow-core-api" % tensorflowVersion % Test ) ) + +lazy val avro = project + .in(file("avro")) .dependsOn( - avro % Provided, - bigquery % Provided, - bigtable % Provided, - datastore % Provided, - guava % "provided,test->test", - protobuf % "provided,test->test", - tensorflow % Provided, + shared, + cats % "test->test", + scalacheck % "test->test", test % "test->test" ) - -lazy val avro: Project = project - .in(file("avro")) .settings( commonSettings, moduleName := "magnolify-avro", @@ -337,15 +368,15 @@ lazy val avro: Project = project "com.fasterxml.jackson.core" % "jackson-databind" % jacksonVersion % Test ) ) + +lazy val bigquery = project + .in(file("bigquery")) .dependsOn( shared, cats % "test->test", scalacheck % "test->test", test % "test->test" ) - -lazy val bigquery: Project = project - .in(file("bigquery")) .settings( commonSettings, moduleName := "magnolify-bigquery", @@ -355,15 +386,15 @@ lazy val bigquery: Project = project "com.fasterxml.jackson.core" % "jackson-databind" % jacksonVersion % Test ) ) + +lazy val bigtable: Project = project + .in(file("bigtable")) .dependsOn( shared, cats % "test->test", scalacheck % "test->test", test % "test->test" ) - -lazy val bigtable: Project = project - .in(file("bigtable")) .settings( commonSettings, moduleName := "magnolify-bigtable", @@ -372,15 +403,15 @@ lazy val bigtable: Project = project "com.google.api.grpc" % "proto-google-cloud-bigtable-v2" % bigtableVersion % Provided ) ) + +lazy val datastore = project + .in(file("datastore")) .dependsOn( shared, cats % "test->test", scalacheck % "test->test", test % "test->test" ) - -lazy val datastore: Project = project - .in(file("datastore")) .settings( commonSettings, moduleName := "magnolify-datastore", @@ -389,15 +420,16 @@ lazy val datastore: Project = project "com.google.cloud.datastore" % "datastore-v1-proto-client" % datastoreVersion % Provided ) ) + +lazy val parquet = project + .in(file("parquet")) .dependsOn( shared, + avro % Test, cats % "test->test", scalacheck % "test->test", test % "test->test" ) - -lazy val parquet: Project = project - .in(file("parquet")) .settings( commonSettings, moduleName := "magnolify-parquet", @@ -412,33 +444,32 @@ lazy val parquet: Project = project "org.apache.avro" % "avro" % avroVersion % Test ) ) + +lazy val protobuf = project + .in(file("protobuf")) .dependsOn( shared, - avro % Test, cats % "test->test", scalacheck % "test->test", test % "test->test" ) - -lazy val protobuf: Project = project - .in(file("protobuf")) .settings( commonSettings, protobufSettings, moduleName := "magnolify-protobuf", description := "Magnolia add-on for Google Protocol Buffer" ) + +val unpackMetadata = taskKey[Seq[File]]("Unpack tensorflow metadata proto files.") + +lazy val tensorflow = project + .in(file("tensorflow")) .dependsOn( shared, cats % "test->test", scalacheck % "test->test", test % "test->test" ) - -val unpackMetadata = taskKey[Seq[File]]("Unpack tensorflow metadata proto files.") - -lazy val tensorflow: Project = project - .in(file("tensorflow")) .settings( commonSettings, protobufSettings, @@ -465,15 +496,15 @@ lazy val tensorflow: Project = project _.filterNot { case (_, n) => n.startsWith("org/tensorflow") } } ) + +lazy val neo4j = project + .in(file("neo4j")) .dependsOn( shared, cats % "test->test", scalacheck % "test->test", test % "test->test" ) - -lazy val neo4j: Project = project - .in(file("neo4j")) .settings( commonSettings, moduleName := "magnolify-neo4j", @@ -482,15 +513,16 @@ lazy val neo4j: Project = project "org.neo4j.driver" % "neo4j-java-driver" % neo4jDriverVersion % Provided ) ) + +lazy val tools = project + .in(file("tools")) .dependsOn( shared, - cats % "test->test", - scalacheck % "test->test", + avro % Test, + bigquery % Test, + parquet % Test, test % "test->test" ) - -lazy val tools: Project = project - .in(file("tools")) .settings( commonSettings, moduleName := "magnolify-tools", @@ -502,16 +534,22 @@ lazy val tools: Project = project "org.typelevel" %% "paiges-core" % paigesVersion ) ) + +lazy val jmh: Project = project + .in(file("jmh")) + .enablePlugins(JmhPlugin) .dependsOn( - shared, avro % Test, bigquery % Test, - parquet % Test, + bigtable % Test, + cats % Test, + datastore % Test, + guava % Test, + protobuf % "test->test", + scalacheck % Test, + tensorflow % Test, test % "test->test" ) - -lazy val jmh: Project = project - .in(file("jmh")) .settings( commonSettings, Jmh / classDirectory := (Test / classDirectory).value, @@ -528,16 +566,3 @@ lazy val jmh: Project = project "org.tensorflow" % "tensorflow-core-api" % tensorflowVersion % Test ) ) - .dependsOn( - avro % Test, - bigquery % Test, - bigtable % Test, - cats % Test, - datastore % Test, - guava % Test, - protobuf % "test->test", - scalacheck % Test, - tensorflow % Test, - test % "test->test" - ) - .enablePlugins(JmhPlugin) diff --git a/project/plugins.sbt b/project/plugins.sbt index 16923679c..f378c5332 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,14 +1,4 @@ +addSbtPlugin("org.typelevel" % "sbt-typelevel" % "0.4.18") addSbtPlugin("com.thesamet" % "sbt-protoc" % "1.0.6") -addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0") -addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.1") -addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0") addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.6") -addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.15") addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3") -addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.11") -addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.9.0") -addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.4.2") - -// force usage of scala-xml v2 -// See https://github.com/scoverage/sbt-scoverage/issues/439 -dependencyOverrides += "org.scala-lang.modules" %% "scala-xml" % "2.1.0"