From e7cc6ed32b0ed0200513427819cdfc0391c441cb Mon Sep 17 00:00:00 2001 From: Matthias Kurz Date: Thu, 11 Jan 2024 13:03:18 +0100 Subject: [PATCH 1/2] Upgrade to latest sbt-js-engine, use GHA/sbt-ci-release --- .github/workflows/build-test.yml | 30 +++++++++++++ .github/workflows/publish.yml | 44 +++++++++++++++++++ .gitignore | 1 + .travis.yml | 18 -------- build.sbt | 23 +++++++++- project/build.properties | 2 +- project/plugins.sbt | 4 +- .../com/typesafe/sbt/jshint/SbtJSHint.scala | 8 ++-- .../test/project/TestBuild.scala | 2 +- .../test/project/build.properties | 1 - .../test/project/plugins.sbt | 4 +- version.sbt | 1 - 12 files changed, 107 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/build-test.yml create mode 100644 .github/workflows/publish.yml delete mode 100644 .travis.yml delete mode 100644 src/sbt-test/sbt-jshint-plugin/test/project/build.properties delete mode 100644 version.sbt diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml new file mode 100644 index 0000000..6ab438e --- /dev/null +++ b/.github/workflows/build-test.yml @@ -0,0 +1,30 @@ +name: Check + +on: + pull_request: + + push: + branches: + - main # Check branch after merge + +concurrency: + # Only run once for latest commit per ref and cancel other (previous) runs. + group: ci-${{ github.ref }} + cancel-in-progress: true + +jobs: + tests: + name: Tests + uses: playframework/.github/.github/workflows/cmd.yml@v3 + with: + java: 17, 11, 8 + scala: 2.12.18 + cmd: | + sbt ++$MATRIX_SCALA test ^scripted + + finish: + name: Finish + if: github.event_name == 'pull_request' + needs: # Should be last + - "tests" + uses: playframework/.github/.github/workflows/rtm.yml@v3 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..6a6c3ae --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,44 @@ +name: Publish + +on: + push: + branches: # Snapshots + - main + tags: ["**"] # Releases + +jobs: + publish-artifacts: + name: JDK 8 + runs-on: ubuntu-20.04 + if: ${{ github.repository_owner == 'sbt' }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + # we don't know what commit the last tag was it's safer to get entire repo so previousStableVersion resolves + fetch-depth: 0 + + - name: Coursier Cache + id: coursier-cache + uses: coursier/cache-action@v6 + + - name: Install Adoptium Temurin OpenJDK + uses: coursier/setup-action@v1 + with: + jvm: adoptium:8 + + - name: Publish artifacts + run: sbt ci-release + env: + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} + PGP_SECRET: ${{ secrets.PGP_SECRET }} + + - name: Cleanup before cache + shell: bash + run: | + find $HOME/Library/Caches/Coursier/v1 -name "ivydata-*.properties" -delete || true + find $HOME/.ivy2/cache -name "ivydata-*.properties" -delete || true + find $HOME/.cache/coursier/v1 -name "ivydata-*.properties" -delete || true + find $HOME/.sbt -name "*.lock" -delete || true diff --git a/.gitignore b/.gitignore index 86f0e5f..56d525f 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ project/plugins/project/ .idea/ .idea_modules/ +.bsp/ diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 536469d..0000000 --- a/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -jdk: oraclejdk8 -language: scala -script: sbt ^scripted - -# Use container-based infrastructure -# See also http://www.scala-sbt.org/0.13/docs/Travis-CI-with-sbt.html -sudo: false - -# These directories are cached to S3 at the end of the build -cache: - directories: - - $HOME/.ivy2/cache - - $HOME/.sbt/boot/ - -before_cache: - # Tricks to avoid unnecessary cache updates - - find $HOME/.ivy2 -name "ivydata-*.properties" -delete - - find $HOME/.sbt -name "*.lock" -delete diff --git a/build.sbt b/build.sbt index 44802f7..ab120ce 100644 --- a/build.sbt +++ b/build.sbt @@ -1,10 +1,31 @@ lazy val `sbt-jshint` = project in file(".") +enablePlugins(SbtWebBase) + +sonatypeProfileName := "com.github.sbt.sbt-jshint" // See https://issues.sonatype.org/browse/OSSRH-77819#comment-1203625 + description := "Allows JSHint to be used from within sbt" +developers += Developer( + "playframework", + "The Play Framework Team", + "contact@playframework.com", + url("https://github.com/playframework") +) + libraryDependencies ++= Seq( "org.webjars.npm" % "jshint" % "2.9.7", "org.webjars" % "strip-json-comments" % "1.0.2-1" ) -addSbtJsEngine("1.2.2") +addSbtJsEngine("1.3.5") + +// Customise sbt-dynver's behaviour to make it work with tags which aren't v-prefixed +ThisBuild / dynverVTagPrefix := false + +// Sanity-check: assert that version comes from a tag (e.g. not a too-shallow clone) +// https://github.com/dwijnand/sbt-dynver/#sanity-checking-the-version +Global / onLoad := (Global / onLoad).value.andThen { s => + dynverAssertTagVersion.value + s +} diff --git a/project/build.properties b/project/build.properties index b7dd3cb..e8a1e24 100755 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.0.2 +sbt.version=1.9.7 diff --git a/project/plugins.sbt b/project/plugins.sbt index 7a1196f..6e4254c 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1 +1,3 @@ -addSbtPlugin("com.typesafe.sbt" % "sbt-web-build-base" % "1.2.0") +addSbtPlugin("com.github.sbt" % "sbt-web-build-base" % "2.0.2") + +addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12") diff --git a/src/main/scala/com/typesafe/sbt/jshint/SbtJSHint.scala b/src/main/scala/com/typesafe/sbt/jshint/SbtJSHint.scala index 64f8c14..bc371db 100644 --- a/src/main/scala/com/typesafe/sbt/jshint/SbtJSHint.scala +++ b/src/main/scala/com/typesafe/sbt/jshint/SbtJSHint.scala @@ -63,13 +63,13 @@ object SbtJSHint extends AutoPlugin { } ) ++ inTask(jshint)( SbtJsTask.jsTaskSpecificUnscopedProjectSettings ++ Seq( - includeFilter in Assets := (jsFilter in Assets).value, - includeFilter in TestAssets := (jsFilter in TestAssets).value, + Assets / includeFilter := (Assets / jsFilter).value, + TestAssets / includeFilter := (TestAssets / jsFilter).value, jsOptions := resolvedConfig.value.fold("{}")(IO.read(_)), - taskMessage in Assets := "JavaScript linting", - taskMessage in TestAssets := "JavaScript test linting" + Assets / taskMessage := "JavaScript linting", + TestAssets / taskMessage := "JavaScript test linting" ) ) ++ SbtJsTask.addJsSourceFileTasks(jshint) diff --git a/src/sbt-test/sbt-jshint-plugin/test/project/TestBuild.scala b/src/sbt-test/sbt-jshint-plugin/test/project/TestBuild.scala index cf00633..2c29ae1 100644 --- a/src/sbt-test/sbt-jshint-plugin/test/project/TestBuild.scala +++ b/src/sbt-test/sbt-jshint-plugin/test/project/TestBuild.scala @@ -28,4 +28,4 @@ object TestBuild extends Build { settings = Seq(WebKeys.reporter := new TestReporter(target.value)) ).enablePlugins(SbtWeb) -} \ No newline at end of file +} diff --git a/src/sbt-test/sbt-jshint-plugin/test/project/build.properties b/src/sbt-test/sbt-jshint-plugin/test/project/build.properties deleted file mode 100644 index 64317fd..0000000 --- a/src/sbt-test/sbt-jshint-plugin/test/project/build.properties +++ /dev/null @@ -1 +0,0 @@ -sbt.version=0.13.15 diff --git a/src/sbt-test/sbt-jshint-plugin/test/project/plugins.sbt b/src/sbt-test/sbt-jshint-plugin/test/project/plugins.sbt index c768483..144d486 100644 --- a/src/sbt-test/sbt-jshint-plugin/test/project/plugins.sbt +++ b/src/sbt-test/sbt-jshint-plugin/test/project/plugins.sbt @@ -1,8 +1,6 @@ resolvers ++= Seq( - Resolver.url("sbt snapshot plugins", url("http://repo.scala-sbt.org/scalasbt/sbt-plugin-snapshots"))(Resolver.ivyStylePatterns), Resolver.mavenLocal, Resolver.sonatypeRepo("snapshots"), - "Typesafe Snapshots Repository" at "http://repo.typesafe.com/typesafe/snapshots/" ) -addSbtPlugin("com.typesafe.sbt" % "sbt-jshint" % sys.props("project.version")) \ No newline at end of file +addSbtPlugin("com.github.sbt" % "sbt-jshint" % sys.props("project.version")) diff --git a/version.sbt b/version.sbt deleted file mode 100644 index c695c92..0000000 --- a/version.sbt +++ /dev/null @@ -1 +0,0 @@ -version in ThisBuild := "1.0.7-SNAPSHOT" From 2c5367d3c249caea52f43e512f26915d620dbbef Mon Sep 17 00:00:00 2001 From: Matthias Kurz Date: Thu, 11 Jan 2024 13:04:36 +0100 Subject: [PATCH 2/2] Make scripted tests compile --- src/sbt-test/sbt-jshint-plugin/test/build.sbt | 4 +++ .../test/project/TestBuild.scala | 34 +++++++------------ 2 files changed, 16 insertions(+), 22 deletions(-) create mode 100644 src/sbt-test/sbt-jshint-plugin/test/build.sbt diff --git a/src/sbt-test/sbt-jshint-plugin/test/build.sbt b/src/sbt-test/sbt-jshint-plugin/test/build.sbt new file mode 100644 index 0000000..579294a --- /dev/null +++ b/src/sbt-test/sbt-jshint-plugin/test/build.sbt @@ -0,0 +1,4 @@ +lazy val root = (project in file(".")).enablePlugins(SbtWeb) + +WebKeys.reporter := new TestBuild.TestReporter(target.value) + diff --git a/src/sbt-test/sbt-jshint-plugin/test/project/TestBuild.scala b/src/sbt-test/sbt-jshint-plugin/test/project/TestBuild.scala index 2c29ae1..5940245 100644 --- a/src/sbt-test/sbt-jshint-plugin/test/project/TestBuild.scala +++ b/src/sbt-test/sbt-jshint-plugin/test/project/TestBuild.scala @@ -1,31 +1,21 @@ import sbt._ -import sbt.Keys._ +import java.util.function.Supplier -import com.typesafe.sbt.web.SbtWeb -import com.typesafe.sbt.web.SbtWeb.autoImport._ +object TestBuild { -object TestBuild extends Build { + class TestLogger(target: File) extends xsbti.Logger { - class TestLogger(target: File) extends Logger { - def trace(t: => Throwable): Unit = {} - - def success(message: => String): Unit = {} - - def log(level: Level.Value, message: => String): Unit = { - if (level == Level.Error) { - if (message.contains("Missing semicolon.")) { - IO.touch(target / "missing-semi-error") - } + def error(msg: Supplier[String]): Unit = { + if (msg.get().contains("Missing semicolon.")) { + IO.touch(target / "missing-semi-error") } } - } - class TestReporter(target: File) extends LoggerReporter(-1, new TestLogger(target)) - - lazy val root = Project( - id = "test-build", - base = file("."), - settings = Seq(WebKeys.reporter := new TestReporter(target.value)) - ).enablePlugins(SbtWeb) + def warn(msg: Supplier[String]): Unit = {} + def info(msg: Supplier[String]): Unit = {} + def debug(msg: Supplier[String]): Unit = {} + def trace(t: Supplier[Throwable]): Unit = {} + } + class TestReporter(target: File) extends sbt.internal.inc.LoggedReporter(-1, new TestLogger(target)) }