From 43352c203e84ab9d5459194f49d3a2ab84ccb7d5 Mon Sep 17 00:00:00 2001 From: Iurii Malchenko Date: Sun, 4 Apr 2021 15:12:11 +0300 Subject: [PATCH] scala 3-RC2, ci --- .github/workflows/ci.yml | 123 ++++++++++++++++++ .github/workflows/clean.yml | 59 +++++++++ CHANGELOG.md | 4 + build.sbt | 65 ++++----- project/ScalaOptions.scala | 41 ++++++ project/ScalaVersions.scala | 4 + project/build.properties | 2 +- project/plugins.sbt | 12 +- .../app/tulz/diff/format/AnsiDiffFormat.scala | 1 - .../tulz/diff/format/AnsiDiffFormatBoth.scala | 2 - .../app/tulz/diff/format/TextDiffFormat.scala | 1 - .../app/tulz/diff/util/DiffPrettier.scala | 13 +- version.sbt | 1 - 13 files changed, 271 insertions(+), 57 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/clean.yml create mode 100644 project/ScalaOptions.scala create mode 100644 project/ScalaVersions.scala delete mode 100644 version.sbt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..fa9d5da --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,123 @@ +# 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: ['*'] + push: + branches: ['*'] + tags: [v*] + +env: + PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + PGP_SECRET: ${{ secrets.PGP_SECRET }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + build: + name: Build and Test + strategy: + matrix: + os: [ubuntu-latest] + scala: [2.13.5, 3.0.0-RC2] + java: [openjdk@1.11.0] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout current branch (full) + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup Java and Scala + uses: olafurpg/setup-scala@v10 + with: + java-version: ${{ matrix.java }} + + - 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 that workflows are up to date + run: sbt ++${{ matrix.scala }} githubWorkflowCheck + + - run: sbt ++${{ matrix.scala }} test website/fastLinkJS + + - name: Compress target directories + run: tar cf targets.tar target stringdiff/.jvm/target stringdiff/.js/target project/target + + - name: Upload target directories + uses: actions/upload-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.scala }}-${{ matrix.java }} + path: targets.tar + + publish: + name: Publish Artifacts + needs: [build] + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v')) + strategy: + matrix: + os: [ubuntu-latest] + scala: [2.13.5] + java: [openjdk@1.11.0] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout current branch (full) + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup Java and Scala + uses: olafurpg/setup-scala@v10 + with: + java-version: ${{ matrix.java }} + + - 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: Download target directories (2.13.5) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-2.13.5-${{ matrix.java }} + + - name: Inflate target directories (2.13.5) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (3.0.0-RC2) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-3.0.0-RC2-${{ matrix.java }} + + - name: Inflate target directories (3.0.0-RC2) + run: | + tar xf targets.tar + rm targets.tar + + - run: sbt ++${{ matrix.scala }} ci-release \ No newline at end of file diff --git a/.github/workflows/clean.yml b/.github/workflows/clean.yml new file mode 100644 index 0000000..b535fcc --- /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 \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index acc4a3b..56e4992 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +### 0.3.2 + +Scala 3-RC2. + ### 0.3.1 Myers algorithm. diff --git a/build.sbt b/build.sbt index 4cede86..9d07ba3 100644 --- a/build.sbt +++ b/build.sbt @@ -1,22 +1,31 @@ -ThisBuild / organization := "app.tulz" -ThisBuild / homepage := Some(url("https://github.com/tulz-app/stringdiff")) -ThisBuild / licenses += ("MIT", url("https://github.com/tulz-app/stringdiff/blob/main/LICENSE.md")) -ThisBuild / developers := List( - Developer( - id = "yurique", - name = "Iurii Malchenko", - email = "i@yurique.com", - url = url("https://github.com/yurique") +inThisBuild( + List( + organization := "app.tulz", + homepage := Some(url("https://github.com/tulz-app/stringdiff")), + licenses := List("MIT" -> url("https://github.com/tulz-app/stringdiff/blob/main/LICENSE.md")), + scmInfo := Some(ScmInfo(url("https://github.com/tulz-app/stringdiff"), "scm:git@github.com/tulz-app/laminext.git")), + developers := List(Developer("yurique", "Iurii Malchenko", "i@yurique.com", url("https://github.com/yurique"))), + scalaVersion := ScalaVersions.v213, + description := "String diff for Scala", + crossScalaVersions := Seq( + ScalaVersions.v213, + ScalaVersions.v3RC2 + ), + Test / publishArtifact := false, + Test / parallelExecution := false, + githubWorkflowJavaVersions := Seq("openjdk@1.11.0"), + githubWorkflowTargetTags ++= Seq("v*"), + githubWorkflowPublishTargetBranches := Seq(RefPredicate.StartsWith(Ref.Tag("v"))), + githubWorkflowPublish := Seq(WorkflowStep.Sbt(List("ci-release"))), + githubWorkflowBuild := Seq(WorkflowStep.Sbt(List("test", "website/fastLinkJS"))), + githubWorkflowEnv ~= (_ ++ Map( + "PGP_PASSPHRASE" -> s"$${{ secrets.PGP_PASSPHRASE }}", + "PGP_SECRET" -> s"$${{ secrets.PGP_SECRET }}", + "SONATYPE_PASSWORD" -> s"$${{ secrets.SONATYPE_PASSWORD }}", + "SONATYPE_USERNAME" -> s"$${{ secrets.SONATYPE_USERNAME }}" + )) ) ) -ThisBuild / releasePublishArtifactsAction := PgpKeys.publishSigned.value -ThisBuild / publishTo := sonatypePublishToBundle.value -ThisBuild / pomIncludeRepository := { _ => false } -ThisBuild / sonatypeProfileName := "yurique" -ThisBuild / publishArtifact in Test := false -ThisBuild / publishMavenStyle := true -ThisBuild / releaseCrossBuild := false -ThisBuild / crossScalaVersions := Seq("2.13.4") lazy val noPublish = Seq( publishLocal / skip := true, @@ -29,27 +38,9 @@ lazy val stringdiff = .crossType(CrossType.Pure) .in(file("stringdiff")) .settings( - scalaVersion := "2.13.4", - scalacOptions := Seq( - "-unchecked", - "-deprecation", - "-feature", - "-Xlint:nullary-unit,inaccessible,infer-any,missing-interpolator,private-shadow,type-parameter-shadow,poly-implicit-overload,option-implicit,delayedinit-select,stars-align", - "-Xcheckinit", - "-Ywarn-value-discard", - "-language:implicitConversions", - "-encoding", - "utf8" - ), + ScalaOptions.fixOptions, libraryDependencies ++= Seq( - "org.scalatest" %%% "scalatest" % "3.2.0" % Test - ), - description := "String diff for scala.", - scmInfo := Some( - ScmInfo( - url("https://github.com/tulz-app/stringdiff"), - "scm:git@github.com/tulz-app/stringdiff.git" - ) + "org.scalatest" %%% "scalatest" % "3.2.7" % Test ) ) diff --git a/project/ScalaOptions.scala b/project/ScalaOptions.scala new file mode 100644 index 0000000..ab94c9f --- /dev/null +++ b/project/ScalaOptions.scala @@ -0,0 +1,41 @@ +import sbt.Keys._ +import sbt._ + +object ScalaOptions { + val fixOptions = Seq( + scalacOptions ~= (_.filterNot( + Set( + "-Wdead-code", + "-Wunused:implicits", + "-Wunused:explicits", + "-Wunused:imports", + "-Wunused:params" + ) + )), + scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match { + case Some((2, _)) => + Seq( + "-Ymacro-annotations" + ) + case Some((3, _)) => Seq() + case _ => Seq() + }), + (Compile / doc / scalacOptions) ~= (_.filterNot( + Set( + "-scalajs", + "-deprecation", + "-explain-types", + "-explain", + "-feature", + "-language:existentials,experimental.macros,higherKinds,implicitConversions", + "-unchecked", + "-Xfatal-warnings", + "-Ykind-projector", + "-from-tasty", + "-encoding", + "utf8" + ) + )) + ) + +} diff --git a/project/ScalaVersions.scala b/project/ScalaVersions.scala new file mode 100644 index 0000000..6bfed89 --- /dev/null +++ b/project/ScalaVersions.scala @@ -0,0 +1,4 @@ +object ScalaVersions { + val v213 = "2.13.5" + val v3RC2 = "3.0.0-RC2" +} diff --git a/project/build.properties b/project/build.properties index d91c272..af4ff6f 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.4.6 +sbt.version=1.5.0-RC2 diff --git a/project/plugins.sbt b/project/plugins.sbt index 4d7ee2a..cafc415 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,13 +1,17 @@ logLevel := Level.Warn -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.1.0") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.0") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2") -addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.2") +addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2") -addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.5") +addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.7") -addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.13") +addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.10.1") + +addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.17") + +addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7") diff --git a/stringdiff/src/main/scala/app/tulz/diff/format/AnsiDiffFormat.scala b/stringdiff/src/main/scala/app/tulz/diff/format/AnsiDiffFormat.scala index 39619fe..95e4f60 100644 --- a/stringdiff/src/main/scala/app/tulz/diff/format/AnsiDiffFormat.scala +++ b/stringdiff/src/main/scala/app/tulz/diff/format/AnsiDiffFormat.scala @@ -45,7 +45,6 @@ object AnsiDiffFormat extends DiffFormat[String] { sb.appendAll(second) sb.append(RESET) sb.append("]") - case _ => } sb.toString() diff --git a/stringdiff/src/main/scala/app/tulz/diff/format/AnsiDiffFormatBoth.scala b/stringdiff/src/main/scala/app/tulz/diff/format/AnsiDiffFormatBoth.scala index a14dada..6b378a8 100644 --- a/stringdiff/src/main/scala/app/tulz/diff/format/AnsiDiffFormatBoth.scala +++ b/stringdiff/src/main/scala/app/tulz/diff/format/AnsiDiffFormatBoth.scala @@ -32,7 +32,6 @@ object AnsiDiffFormatBoth extends DiffFormat[(String, String)] { sb1.append(UNDERLINED) sb1.appendAll(first) sb1.append(RESET) - case _ => } val sb2 = new StringBuilder @@ -58,7 +57,6 @@ object AnsiDiffFormatBoth extends DiffFormat[(String, String)] { sb2.append(UNDERLINED) sb2.appendAll(second) sb2.append(RESET) - case _ => } (sb1.toString(), sb2.toString()) diff --git a/stringdiff/src/main/scala/app/tulz/diff/format/TextDiffFormat.scala b/stringdiff/src/main/scala/app/tulz/diff/format/TextDiffFormat.scala index 8983538..6da827d 100644 --- a/stringdiff/src/main/scala/app/tulz/diff/format/TextDiffFormat.scala +++ b/stringdiff/src/main/scala/app/tulz/diff/format/TextDiffFormat.scala @@ -27,7 +27,6 @@ object TextDiffFormat extends DiffFormat[String] { sb.append("|") sb.appendAll(second) sb.append("]") - case _ => } sb.toString() } diff --git a/stringdiff/src/main/scala/app/tulz/diff/util/DiffPrettier.scala b/stringdiff/src/main/scala/app/tulz/diff/util/DiffPrettier.scala index 991ed7e..c643c51 100644 --- a/stringdiff/src/main/scala/app/tulz/diff/util/DiffPrettier.scala +++ b/stringdiff/src/main/scala/app/tulz/diff/util/DiffPrettier.scala @@ -15,11 +15,11 @@ private[diff] object DiffPrettier { val (prefix, firstRest1, secondRest1) = sameWhitespacePrefix(first, second) val (firstRest2, secondRest2, suffix) = sameWhitespaceSuffix(firstRest1, secondRest1) if (prefix.nonEmpty && suffix.nonEmpty) { - (InBoth(prefix) :: Diff(firstRest2, secondRest2) :: InBoth(suffix) :: Nil) -> tail + (InBoth[String](prefix) :: Diff[String](firstRest2, secondRest2) :: InBoth[String](suffix) :: Nil) -> tail } else if (prefix.nonEmpty) { - (InBoth(prefix) :: Diff(firstRest2, secondRest2) :: Nil) -> tail + (InBoth[String](prefix) :: Diff[String](firstRest2, secondRest2) :: Nil) -> tail } else if (suffix.nonEmpty) { - (Diff(firstRest2, secondRest2) :: InBoth(suffix) :: Nil) -> tail + (Diff[String](firstRest2, secondRest2) :: InBoth[String](suffix) :: Nil) -> tail } else { (d :: Nil) -> tail } @@ -65,11 +65,4 @@ private[diff] object DiffPrettier { (s1.dropRight(sameSuffixLength), s2.dropRight(sameSuffixLength), s1.takeRight(sameSuffixLength)) } - private val whitespace = "\\s+".r - private object Whitespace { - def unapply(s: String): Option[String] = { - Some(s).filter(whitespace.matches) - } - } - } diff --git a/version.sbt b/version.sbt deleted file mode 100644 index 560cbd0..0000000 --- a/version.sbt +++ /dev/null @@ -1 +0,0 @@ -version in ThisBuild := "0.3.1"