From bf93f1d5bc126f0672983c67f3e82166eb1dce1f Mon Sep 17 00:00:00 2001 From: Brice Jaglin Date: Sun, 11 Jun 2023 21:54:02 +0200 Subject: [PATCH] run CI scalafixAll with local scalafix-interfaces --- .github/workflows/ci.yml | 2 +- CONTRIBUTING.md | 3 ++- build.sbt | 2 +- project/ScalafixBuild.scala | 21 ++++++++++++++++++++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa43033aa..454b310b8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,7 +38,7 @@ jobs: steps: - uses: actions/checkout@v3 - uses: coursier/setup-action@v1 - - run: sbt "scalafixAll --check" + - run: sbt "dogfoodScalafixInterfaces; scalafixAll --check" - run: ./bin/scalafmt --test mima: name: Version Policy diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2561dc950..a32c57377 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -71,7 +71,8 @@ scalafix-tests ## Formatting We use scalafix to apply some rules that are configured in .scalafix.conf. -Make sure to run `sbt scalafixAll` to apply those rules. +Make sure to run `sbt "dogfoodScalafixInterfaces; scalafixAll"` to execute +the latest version of those rules. Be sure to run `scalafmt` (available in the `bin` folder) to ensure code formatting. `./bin/scalafmt --diff` formats only the files that have changed diff --git a/build.sbt b/build.sbt index 58fac3262..1e91fa8e7 100644 --- a/build.sbt +++ b/build.sbt @@ -7,7 +7,7 @@ inThisBuild( onLoadMessage := s"Welcome to scalafix ${version.value}", semanticdbEnabled := true, semanticdbVersion := scalametaV, - scalafixScalaBinaryVersion := "2.13", + scalafixScalaBinaryVersion := "2.13" ) ) diff --git a/project/ScalafixBuild.scala b/project/ScalafixBuild.scala index 3cda40500..77e8788d8 100644 --- a/project/ScalafixBuild.scala +++ b/project/ScalafixBuild.scala @@ -171,6 +171,25 @@ object ScalafixBuild extends AutoPlugin with GhpagesKeys { "interfaces/doc" :: s }, + commands += Command.command("dogfoodScalafixInterfaces") { state => + val extracted = Project.extract(state) + val v = + (ThisBuild / version) + .get(extracted.structure.data) + .get + val suffix = + (ThisBuild / scalafixScalaBinaryVersion) + .get(extracted.structure.data) + .get + .replace('.', '_') + + s"all cli$suffix/publishLocalTransitive interfaces/publishLocal" :: + "reload plugins" :: + s"""set dependencyOverrides += "ch.epfl.scala" % "scalafix-interfaces" % "$v"""" :: // as documented in installation.md + "session save" :: + "reload return" :: + state + }, Test / publishArtifact := false, licenses := Seq( "Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0") @@ -192,7 +211,7 @@ object ScalafixBuild extends AutoPlugin with GhpagesKeys { Some("^\\d+\\.\\d+\\.\\d+\\+\\d+".r), versionScheme := Some("early-semver"), // coursier-versions always return false for the *.*.*.*-r pattern jgit uses - libraryDependencySchemes += Dependencies.jgit.withRevision("always"), + libraryDependencySchemes += Dependencies.jgit.withRevision("always") ) override def projectSettings: Seq[Def.Setting[_]] = List(