From 00ec2cd40cbb8ee0fa574dd2d0b8023be2a8d2dc Mon Sep 17 00:00:00 2001 From: Jan Chyb Date: Thu, 4 Aug 2022 13:10:17 +0200 Subject: [PATCH] Setup GHA manually for Scala 3 and run scalafmt --- .github/workflows/ci-scala3.yml | 55 +++++++++++++++++++ .github/workflows/ci.yml | 17 ++---- build.sbt | 30 +++++----- .../sangria/execution/ValueCollector.scala | 3 +- 4 files changed, 76 insertions(+), 29 deletions(-) create mode 100644 .github/workflows/ci-scala3.yml diff --git a/.github/workflows/ci-scala3.yml b/.github/workflows/ci-scala3.yml new file mode 100644 index 00000000..37caaf0d --- /dev/null +++ b/.github/workflows/ci-scala3.yml @@ -0,0 +1,55 @@ +# This file was based on ci.yml file, but is unmanaged by the sbt plugin +# and was edited manually. Should be removed when sangria-derivation will +# be merged for Scala 3 + +name: Continuous Integration (Scala 3) + +on: + pull_request: + branches: ['**'] + push: + branches: ['**'] + tags: [v*] + +jobs: + build: + name: Build and Test on Scala 3 + strategy: + matrix: + os: [ubuntu-latest] + scala: [3.1.3] + java: [temurin@11] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout current branch (full) + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup Java (temurin@11) + if: matrix.java == 'temurin@11' + uses: actions/setup-java@v2 + with: + distribution: temurin + java-version: 11 + + - name: Cache sbt + uses: actions/cache@v2 + 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: Check binary compatibility + run: sbt ++${{ matrix.scala }} "sangria-ast/mimaReportBinaryIssues;sangria-parser/mimaReportBinaryIssues;sangria-core/mimaReportBinaryIssues" + + - name: Check formatting + run: sbt ++${{ matrix.scala }} scalafmtCheckAll + + - name: Build and test project + run: sbt ++${{ matrix.scala }} "sangria-parser/test;sangria-core/test" \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7ed4e28b..ea4716e6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - scala: [2.12.16, 2.13.8, 3.1.3] + scala: [2.12.16, 2.13.8] java: [temurin@11] runs-on: ${{ matrix.os }} steps: @@ -60,7 +60,8 @@ jobs: - name: Check that workflows are up to date run: sbt ++${{ matrix.scala }} githubWorkflowCheck - - run: sbt ++${{ matrix.scala }} testAll + - name: Build project + run: sbt ++${{ matrix.scala }} test - name: Compress target directories run: tar cf targets.tar modules/core/target modules/parser/target modules/benchmarks/target modules/derivation/target modules/ast/target target modules/sangria/target project/target @@ -78,7 +79,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - scala: [3.1.3] + scala: [2.13.8] java: [temurin@11] runs-on: ${{ matrix.os }} steps: @@ -126,16 +127,6 @@ jobs: tar xf targets.tar rm targets.tar - - name: Download target directories (3.1.3) - uses: actions/download-artifact@v2 - with: - name: target-${{ matrix.os }}-3.1.3-${{ matrix.java }} - - - name: Inflate target directories (3.1.3) - run: | - tar xf targets.tar - rm targets.tar - - env: PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} PGP_SECRET: ${{ secrets.PGP_SECRET }} diff --git a/build.sbt b/build.sbt index f7217a08..92a3a36a 100644 --- a/build.sbt +++ b/build.sbt @@ -9,21 +9,14 @@ val isScala3 = Def.setting( // sbt-github-actions needs configuration in `ThisBuild` ThisBuild / crossScalaVersions := Seq("2.12.16", "2.13.8", "3.1.3") -ThisBuild / scalaVersion := crossScalaVersions.value.last +ThisBuild / scalaVersion := "2.13.8" ThisBuild / githubWorkflowBuildPreamble ++= List( WorkflowStep.Sbt(List("mimaReportBinaryIssues"), name = Some("Check binary compatibility")), WorkflowStep.Sbt(List("scalafmtCheckAll"), name = Some("Check formatting")) ) -// Workaround for not running derivation tests for Scala 3 yet. -// Should be deleted and githubWorkflowBuild should be restored to default when -// derivation is compiling for all versions -lazy val testAll = taskKey[Unit]("Test all available modules depending on the Scala version") -testAll := { - if (isScala3.value) Def.sequential(parser / Test / test, core / Test / test).value - else Def.sequential(parser / Test / test, core / Test / test, derivation / Test / test).value -} -ThisBuild / githubWorkflowBuild := Seq(WorkflowStep.Sbt(List("testAll"))) +// For now we set up GH Actions manually for Scala 3 +ThisBuild / githubWorkflowScalaVersions := crossScalaVersions.value.filterNot(_.startsWith("3.")) // Release ThisBuild / githubWorkflowTargetTags ++= Seq("v*") @@ -63,7 +56,9 @@ lazy val ast = project .settings( name := "sangria-ast", description := "Scala GraphQL AST representation", - mimaPreviousArtifacts := emptyForScala3(isScala3.value, "org.sangria-graphql" %% "sangria-ast" % "3.0.0"), + mimaPreviousArtifacts := emptyForScala3( + isScala3.value, + "org.sangria-graphql" %% "sangria-ast" % "3.0.0"), mimaBinaryIssueFilters ++= Seq( ProblemFilters.exclude[IncompatibleResultTypeProblem]("sangria.ast.DirectiveDefinition.*"), ProblemFilters.exclude[DirectMissingMethodProblem]("sangria.ast.DirectiveDefinition.apply"), @@ -85,8 +80,9 @@ lazy val parser = project .settings( name := "sangria-parser", description := "Scala GraphQL parser", - mimaPreviousArtifacts := emptyForScala3(isScala3.value, "org.sangria-graphql" %% "sangria-parser" % "3.0.0"), - + mimaPreviousArtifacts := emptyForScala3( + isScala3.value, + "org.sangria-graphql" %% "sangria-parser" % "3.0.0"), libraryDependencies ++= Seq( // AST Parser "org.parboiled" %% "parboiled" % "2.4.0", @@ -106,7 +102,9 @@ lazy val core = project .settings( name := "sangria-core", description := "Scala GraphQL implementation", - mimaPreviousArtifacts := emptyForScala3(isScala3.value, "org.sangria-graphql" %% "sangria-core" % "3.0.0"), + mimaPreviousArtifacts := emptyForScala3( + isScala3.value, + "org.sangria-graphql" %% "sangria-core" % "3.0.0"), mimaBinaryIssueFilters ++= Seq( ProblemFilters.exclude[DirectMissingMethodProblem]( "sangria.introspection.IntrospectionDirective.apply"), @@ -167,7 +165,9 @@ lazy val derivation = project .settings( name := "sangria-derivation", Test / testOptions += Tests.Argument(TestFrameworks.ScalaTest, "-oF"), - mimaPreviousArtifacts := emptyForScala3(isScala3.value, "org.sangria-graphql" %% "sangria-derivation" % "3.0.0"), + mimaPreviousArtifacts := emptyForScala3( + isScala3.value, + "org.sangria-graphql" %% "sangria-derivation" % "3.0.0"), // Macros libraryDependencies ++= (if (isScala3.value) Seq.empty else Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value)), diff --git a/modules/core/src/main/scala/sangria/execution/ValueCollector.scala b/modules/core/src/main/scala/sangria/execution/ValueCollector.scala index c878cf7d..7e56139e 100644 --- a/modules/core/src/main/scala/sangria/execution/ValueCollector.scala +++ b/modules/core/src/main/scala/sangria/execution/ValueCollector.scala @@ -146,7 +146,8 @@ object ValueCollector { marshaller, fromInput.marshaller, errors = errors, - valueMap = (v: Any) => fromInput.fromResult(v.asInstanceOf[fromInput.marshaller.Node]), + valueMap = + (v: Any) => fromInput.fromResult(v.asInstanceOf[fromInput.marshaller.Node]), defaultValueInfo = defaultInfo, undefinedValues = undefinedArgs, isArgument = true,