From ca8adef671cda1df2c25e1f3a4dac9a99ed55e23 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Wed, 19 Jan 2022 06:13:52 +0000 Subject: [PATCH 1/6] Migrate to sbt-typelevel --- .github/workflows/ci.yml | 182 +++++++++------------------- build.sbt | 192 ++++-------------------------- docs/Gemfile | 4 - docs/{src/main/mdoc => }/index.md | 10 +- project/plugins.sbt | 9 +- 5 files changed, 87 insertions(+), 310 deletions(-) delete mode 100644 docs/Gemfile rename docs/{src/main/mdoc => }/index.md (89%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 53ebc04b..ccb0b2f9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,16 +9,17 @@ name: Continuous Integration on: pull_request: - branches: ['*', series/*] + branches: ['**'] push: - branches: ['*', series/*] - tags: [v*, v*] + branches: ['**'] + tags: [v*] env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + 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: @@ -28,6 +29,14 @@ jobs: os: [ubuntu-latest] scala: [2.13.8, 2.12.15, 3.0.2] java: [temurin@8, temurin@11] + project: [rootJS, rootJVM] + exclude: + - scala: 2.13.8 + java: temurin@11 + - scala: 2.12.15 + java: temurin@11 + - project: rootJS + java: temurin@11 runs-on: ${{ matrix.os }} steps: - name: Checkout current branch (full) @@ -62,16 +71,29 @@ jobs: 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 'project ${{ matrix.project }}' '++${{ matrix.scala }}' 'project /' githubWorkflowCheck + + - name: Check headers and formatting + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' headerCheckAll scalafmtCheckAll 'project /' scalafmtSbtCheck + + - name: fastOptJS + if: matrix.project == 'rootJS' + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' Test/fastOptJS - name: Test - run: sbt ++${{ matrix.scala }} test + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' test - - name: Binary Compatibility Check - run: sbt ++${{ matrix.scala }} mimaReportBinaryIssues + - name: Check binary compatibility + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' mimaReportBinaryIssues + + - name: Generate API documentation + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' doc + + - name: Make target directories + run: mkdir -p testing/jvm/target noop/jvm/target target .js/target site/target core/js/target testing/js/target noop/js/target core/jvm/target .jvm/target .native/target slf4j/target project/target - name: Compress target directories - run: tar cf targets.tar testing/jvm/target noop/jvm/target docs/target target core/js/target testing/js/target noop/js/target core/jvm/target slf4j/target project/target + run: tar cf targets.tar testing/jvm/target noop/jvm/target target .js/target site/target core/js/target testing/js/target noop/js/target core/jvm/target .jvm/target .native/target slf4j/target project/target - name: Upload target directories uses: actions/upload-artifact@v2 @@ -82,7 +104,7 @@ jobs: publish: name: Publish Artifacts needs: [build] - if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v')) + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') strategy: matrix: os: [ubuntu-latest] @@ -152,77 +174,26 @@ jobs: rm targets.tar - name: Import signing key + if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE == '' run: echo $PGP_SECRET | base64 -d | gpg --import - - run: sbt ++${{ matrix.scala }} release - - - if: matrix.scala == '2.12.15' - uses: ruby/setup-ruby@v1 - with: - ruby-version: 2.6 - - - if: matrix.scala == '2.12.15' - run: gem update --system - - - if: matrix.scala == '2.12.15' - run: gem install sass - - - if: matrix.scala == '2.12.15' - run: gem install jekyll -v 4 - - - if: matrix.scala == '2.12.15' - run: sbt ++${{ matrix.scala }} docs/publishMicrosite - - scalafmt: - name: Scalafmt - strategy: - matrix: - os: [ubuntu-latest] - scala: [2.13.8, 2.12.15] - 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@8) - if: matrix.java == 'temurin@8' - uses: actions/setup-java@v2 - with: - distribution: temurin - java-version: 8 - - - 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: Import signing key and strip passphrase + if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE != '' + run: | + echo "$PGP_SECRET" | base64 -d > /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: Scalafmt - run: sbt ++${{ matrix.scala }} scalafmtCheckAll + - name: Publish + run: sbt '++${{ matrix.scala }}' tlRelease - headers: - name: Headers + site: + name: Generate Site strategy: matrix: os: [ubuntu-latest] - scala: [2.13.8, 2.12.15, 3.0.2] - java: [temurin@11] + scala: [3.0.2] + java: [temurin@8] runs-on: ${{ matrix.os }} steps: - name: Checkout current branch (full) @@ -256,58 +227,13 @@ jobs: ~/Library/Caches/Coursier/v1 key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - - name: Headers - run: sbt ++${{ matrix.scala }} headerCheckAll - - microsite: - name: Microsite - strategy: - matrix: - os: [ubuntu-latest] - scala: [2.12.15] - 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@8) - if: matrix.java == 'temurin@8' - uses: actions/setup-java@v2 - with: - distribution: temurin - java-version: 8 - - - name: Setup Java (temurin@11) - if: matrix.java == 'temurin@11' - uses: actions/setup-java@v2 - with: - distribution: temurin - java-version: 11 + - name: Generate site + run: sbt '++${{ matrix.scala }}' tlSite - - name: Cache sbt - uses: actions/cache@v2 + - name: Publish site + if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' + uses: peaceiris/actions-gh-pages@v3.8.0 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') }} - - - uses: ruby/setup-ruby@v1 - with: - ruby-version: 2.6 - - - run: gem update --system - - - run: gem install sass - - - run: gem install jekyll -v 4 - - - name: Build the microsite - run: sbt ++${{ matrix.scala }} docs/makeMicrosite + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: site/target/docs/site + publish_branch: gh-pages diff --git a/build.sbt b/build.sbt index c05b64b7..1ea0fae6 100644 --- a/build.sbt +++ b/build.sbt @@ -1,84 +1,28 @@ -import sbtghactions.UseRef - val Scala213 = "2.13.8" val Scala212 = "2.12.15" val Scala3 = "3.0.2" -enablePlugins(SonatypeCiReleasePlugin) - -ThisBuild / organization := "org.typelevel" -ThisBuild / organizationName := "Typelevel" -ThisBuild / baseVersion := "2.2" +ThisBuild / tlBaseVersion := "2.2" ThisBuild / crossScalaVersions := Seq(Scala213, Scala212, Scala3) ThisBuild / scalaVersion := Scala213 -ThisBuild / publishFullName := "Christopher Davenport" -ThisBuild / publishGithubUser := "christopherdavenport" - -ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.temurin("8"), JavaSpec.temurin("11")) - -ThisBuild / versionIntroduced := Map( - "2.12" -> "1.2.0", - "2.13" -> "1.2.0", - "3.0.0" -> "1.3.1" -) - -val MicrositesCond = s"matrix.scala == '$Scala212'" - -ThisBuild / githubWorkflowBuild := Seq( - WorkflowStep.Sbt(List("test"), name = Some("Test")), - WorkflowStep.Sbt(List("mimaReportBinaryIssues"), name = Some("Binary Compatibility Check")) -) - -def micrositeWorkflowSteps(cond: Option[String] = None): List[WorkflowStep] = List( - WorkflowStep.Use( - UseRef.Public("ruby", "setup-ruby", "v1"), - params = Map("ruby-version" -> "2.6"), - cond = cond - ), - WorkflowStep.Run(List("gem update --system"), cond = cond), - WorkflowStep.Run(List("gem install sass"), cond = cond), - WorkflowStep.Run(List("gem install jekyll -v 4"), cond = cond) -) - -ThisBuild / githubWorkflowAddedJobs ++= Seq( - WorkflowJob( - "scalafmt", - "Scalafmt", - githubWorkflowJobSetup.value.toList ::: List( - WorkflowStep.Sbt(List("scalafmtCheckAll"), name = Some("Scalafmt")) - ), - // Awaiting release of https://github.com/scalameta/scalafmt/pull/2324/files - scalas = crossScalaVersions.value.toList.filter(_.startsWith("2.")) - ), - WorkflowJob( - "headers", - "Headers", - githubWorkflowJobSetup.value.toList ::: List( - WorkflowStep.Sbt(List("headerCheckAll"), name = Some("Headers")) - ), - scalas = crossScalaVersions.value.toList +ThisBuild / startYear := Some(2018) +ThisBuild / developers := List( + Developer( + "christopherdavenport", + "Christopher Davenport", + "chris@christopherdavenport.tech", + new java.net.URL("https://christopherdavenport.github.io/") ), - WorkflowJob( - "microsite", - "Microsite", - githubWorkflowJobSetup.value.toList ::: (micrositeWorkflowSteps(None) :+ WorkflowStep - .Sbt(List("docs/makeMicrosite"), name = Some("Build the microsite"))), - scalas = List(Scala212) + Developer( + "lorandszakacs", + "Loránd Szakács", + "lorand.szakacs@protonmail.com", + new java.net.URL("https://github.com/lorandszakacs") ) ) +ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.temurin("8"), JavaSpec.temurin("11")) -ThisBuild / githubWorkflowTargetBranches := List("*", "series/*") -ThisBuild / githubWorkflowTargetTags ++= Seq("v*") -ThisBuild / githubWorkflowPublishTargetBranches := Seq(RefPredicate.StartsWith(Ref.Tag("v"))) - -ThisBuild / githubWorkflowPublish := Seq( - WorkflowStep.Sbt( - List("release") - ) -) ++ micrositeWorkflowSteps(Some(MicrositesCond)) :+ WorkflowStep.Sbt( - List("docs/publishMicrosite"), - cond = Some(MicrositesCond) -) +ThisBuild / tlVersionIntroduced := Map("3" -> "2.1.1") val catsV = "2.7.0" val catsEffectV = "3.3.4" @@ -88,65 +32,43 @@ val logbackClassicV = "1.2.10" Global / onChangedBuildSource := ReloadOnSourceChanges -lazy val log4cats = project - .in(file(".")) - .aggregate( - coreJVM, - coreJS, - testingJVM, - testingJS, - noopJVM, - noopJS, - slf4j, - docs - ) - .enablePlugins(NoPublishPlugin) - .settings(commonSettings, releaseSettings) +lazy val root = tlCrossRootProject.aggregate(core, testing, noop, slf4j, docs) lazy val docs = project - .settings(commonSettings, micrositeSettings) - .enablePlugins(MicrositesPlugin) - .enablePlugins(MdocPlugin) - .enablePlugins(NoPublishPlugin) - .settings(mdocIn := sourceDirectory.value / "main" / "mdoc") + .in(file("site")) + .enablePlugins(TypelevelSitePlugin) .dependsOn(slf4j) lazy val core = crossProject(JSPlatform, JVMPlatform) - .settings(commonSettings, releaseSettings) + .settings(commonSettings) .settings( name := "log4cats-core", libraryDependencies ++= Seq( "org.typelevel" %%% "cats-core" % catsV ) ) -lazy val coreJVM = core.jvm -lazy val coreJS = core.js lazy val testing = crossProject(JSPlatform, JVMPlatform) - .settings(commonSettings, releaseSettings) + .settings(commonSettings) .dependsOn(core) .settings( name := "log4cats-testing", libraryDependencies ++= Seq( - "org.typelevel" %%% "cats-effect" % catsEffectV, - "ch.qos.logback" % "logback-classic" % logbackClassicV % Test + "org.typelevel" %%% "cats-effect" % catsEffectV, + "ch.qos.logback" % "logback-classic" % logbackClassicV % Test ) ) -lazy val testingJVM = testing.jvm -lazy val testingJS = testing.js lazy val noop = crossProject(JSPlatform, JVMPlatform) - .settings(commonSettings, releaseSettings) + .settings(commonSettings) .dependsOn(core) .settings( name := "log4cats-noop" ) -lazy val noopJVM = noop.jvm -lazy val noopJS = noop.js lazy val slf4j = project - .settings(commonSettings, releaseSettings) - .dependsOn(coreJVM) + .settings(commonSettings) + .dependsOn(core.js) .settings( name := "log4cats-slf4j", libraryDependencies ++= Seq( @@ -155,7 +77,7 @@ lazy val slf4j = project "ch.qos.logback" % "logback-classic" % logbackClassicV % Test ), libraryDependencies ++= { - if (isDotty.value) Seq.empty + if (tlIsScala3.value) Seq.empty else Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value % Provided) } ) @@ -163,67 +85,5 @@ lazy val slf4j = project lazy val commonSettings = Seq( libraryDependencies ++= Seq( "org.typelevel" %%% "munit-cats-effect-3" % munitCatsEffectV % Test - ), - testFrameworks += new TestFramework("munit.Framework"), -) - -lazy val releaseSettings = { - Seq( - Test / publishArtifact := false, - scmInfo := Some( - ScmInfo( - url("https://github.com/typelevel/log4cats"), - "git@github.com:typelevel/log4cats.git" - ) - ), - homepage := Some(url("https://github.com/typelevel/log4cats")), - licenses := Seq("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0.html")), - startYear := Some(2018), - developers := List( - Developer( - "christopherdavenport", - "Christopher Davenport", - "chris@christopherdavenport.tech", - new java.net.URL("https://christopherdavenport.github.io/") - ), - Developer( - "lorandszakacs", - "Loránd Szakács", - "lorand.szakacs@protonmail.com", - new java.net.URL("https://github.com/lorandszakacs") - ) - ) ) -} - -lazy val micrositeSettings = Seq( - micrositeName := "log4cats", - micrositeDescription := "Functional Logging", - micrositeAuthor := "Christopher Davenport", - micrositeGithubOwner := "typelevel", - micrositeGithubRepo := "log4cats", - micrositeBaseUrl := "/log4cats", - micrositeDocumentationUrl := "https://typelevel.github.io/log4cats", - micrositeFooterText := None, - micrositeHighlightTheme := "atom-one-light", - micrositePalette := Map( - "brand-primary" -> "#3e5b95", - "brand-secondary" -> "#294066", - "brand-tertiary" -> "#2d5799", - "gray-dark" -> "#49494B", - "gray" -> "#7B7B7E", - "gray-light" -> "#E5E5E6", - "gray-lighter" -> "#F4F3F4", - "white-color" -> "#FFFFFF" - ), - scalacOptions --= Seq( - "-Xfatal-warnings", - "-Ywarn-unused-import", - "-Ywarn-numeric-widen", - "-Ywarn-dead-code", - "-Ywarn-unused:imports", - "-Xlint:-missing-interpolator,_" - ), - micrositePushSiteWith := GitHub4s, - micrositeGithubToken := sys.env.get("GITHUB_TOKEN") ) diff --git a/docs/Gemfile b/docs/Gemfile deleted file mode 100644 index 2f79a7b2..00000000 --- a/docs/Gemfile +++ /dev/null @@ -1,4 +0,0 @@ -source 'http://rubygems.org' - -gem "jekyll", ">= 4.0.0" -gem "jekyll-relative-links" \ No newline at end of file diff --git a/docs/src/main/mdoc/index.md b/docs/index.md similarity index 89% rename from docs/src/main/mdoc/index.md rename to docs/index.md index 86a7f9b1..bbbb4cda 100644 --- a/docs/src/main/mdoc/index.md +++ b/docs/index.md @@ -1,8 +1,6 @@ ---- -layout: home +# log4cats ---- -# log4cats [![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.typelevel/log4cats-core_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.typelevel/log4cats-core_2.12) +[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.typelevel/log4cats-core_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.typelevel/log4cats-core_2.12) ## Project Goals @@ -17,8 +15,8 @@ To use log4cats in an existing SBT project with Scala 2.12 or a later version, a ```scala libraryDependencies ++= Seq( - "org.typelevel" %% "log4cats-core" % "", // Only if you want to Support Any Backend - "org.typelevel" %% "log4cats-slf4j" % "", // Direct Slf4j Support - Recommended + "org.typelevel" %% "log4cats-core" % "@VERSION@", // Only if you want to Support Any Backend + "org.typelevel" %% "log4cats-slf4j" % "@VERSION@", // Direct Slf4j Support - Recommended ) ``` diff --git a/project/plugins.sbt b/project/plugins.sbt index 4455dd39..d2dc3503 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,8 +1,5 @@ -addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.8.0") -addSbtPlugin("com.47deg" % "sbt-microsites" % "1.3.4") -addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3") -addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0") -addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.24") -addSbtPlugin("com.codecommit" % "sbt-spiewak-sonatype" % "0.23.0") +val sbtTypelevelVersion = "0.4.0" +addSbtPlugin("org.typelevel" % "sbt-typelevel" % sbtTypelevelVersion) +addSbtPlugin("org.typelevel" % "sbt-typelevel-site" % sbtTypelevelVersion) From b708c6e3b1e91399db0f101b2b23115dd45214dc Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Wed, 19 Jan 2022 06:16:55 +0000 Subject: [PATCH 2/6] Formatting --- project/plugins.sbt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index d2dc3503..53413b6d 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,5 +1,5 @@ -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.8.0") -addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.8.0") +addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3") val sbtTypelevelVersion = "0.4.0" -addSbtPlugin("org.typelevel" % "sbt-typelevel" % sbtTypelevelVersion) +addSbtPlugin("org.typelevel" % "sbt-typelevel" % sbtTypelevelVersion) addSbtPlugin("org.typelevel" % "sbt-typelevel-site" % sbtTypelevelVersion) From a1585b4ec78730d6e20ea2fb14de0c34f3fe2a0e Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Wed, 19 Jan 2022 06:19:22 +0000 Subject: [PATCH 3/6] Fix docs --- docs/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.md b/docs/index.md index bbbb4cda..894ae528 100644 --- a/docs/index.md +++ b/docs/index.md @@ -30,7 +30,7 @@ import cats.implicits._ object MyThing { // Impure But What 90% of Folks I know do with log4s - implicit def logger[F[_]: Sync] = Slf4jLogger.getLogger[F] + implicit def logger[F[_]: Sync]: Logger[F] = Slf4jLogger.getLogger[F] // Arbitrary Local Function Declaration def doSomething[F[_]: Sync]: F[Unit] = From b95ff86938609cc9090c2c2378f326e1770f1e6e Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Wed, 19 Jan 2022 06:22:34 +0000 Subject: [PATCH 4/6] Formatting --- .scalafmt.conf | 5 +++++ .../log4cats/slf4j/Slf4jLogger.scala | 6 ++--- .../slf4j/internal/GetLoggerMacros.scala | 22 +++++++++---------- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index 518bbd94..7dd1b94b 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -28,3 +28,8 @@ rewrite { } runner.dialect = "scala213source3" +fileOverride { + "glob:**/scala-3/**" { + runner.dialect = scala3 + } +} diff --git a/slf4j/src/main/scala-3/org/typelevel/log4cats/slf4j/Slf4jLogger.scala b/slf4j/src/main/scala-3/org/typelevel/log4cats/slf4j/Slf4jLogger.scala index c2599b51..e6bd319d 100644 --- a/slf4j/src/main/scala-3/org/typelevel/log4cats/slf4j/Slf4jLogger.scala +++ b/slf4j/src/main/scala-3/org/typelevel/log4cats/slf4j/Slf4jLogger.scala @@ -24,19 +24,19 @@ import org.slf4j.{Logger => JLogger} object Slf4jLogger { inline def getLogger[F[_]](implicit F: Sync[F]): SelfAwareStructuredLogger[F] = - ${GetLoggerMacros.getLoggerImpl('F)} + ${ GetLoggerMacros.getLoggerImpl('F) } def getLoggerFromName[F[_]: Sync](name: String): SelfAwareStructuredLogger[F] = getLoggerFromSlf4j(org.slf4j.LoggerFactory.getLogger(name)) def getLoggerFromClass[F[_]: Sync](clazz: Class[_]): SelfAwareStructuredLogger[F] = getLoggerFromSlf4j[F](org.slf4j.LoggerFactory.getLogger(clazz)) - + def getLoggerFromSlf4j[F[_]: Sync](logger: JLogger): SelfAwareStructuredLogger[F] = new Slf4jLoggerInternal.Slf4jLogger(logger) inline def create[F[_]](implicit F: Sync[F]): F[SelfAwareStructuredLogger[F]] = - ${GetLoggerMacros.createImpl('F)} + ${ GetLoggerMacros.createImpl('F) } def fromName[F[_]: Sync](name: String): F[SelfAwareStructuredLogger[F]] = Sync[F].delay(getLoggerFromName(name)) diff --git a/slf4j/src/main/scala-3/org/typelevel/log4cats/slf4j/internal/GetLoggerMacros.scala b/slf4j/src/main/scala-3/org/typelevel/log4cats/slf4j/internal/GetLoggerMacros.scala index d4bb1edd..26129b96 100644 --- a/slf4j/src/main/scala-3/org/typelevel/log4cats/slf4j/internal/GetLoggerMacros.scala +++ b/slf4j/src/main/scala-3/org/typelevel/log4cats/slf4j/internal/GetLoggerMacros.scala @@ -25,7 +25,9 @@ import scala.quoted._ private[slf4j] object GetLoggerMacros { - def getLoggerImpl[F[_]: Type](F: Expr[Sync[F]])(using qctx: Quotes): Expr[SelfAwareStructuredLogger[F]] = { + def getLoggerImpl[F[_]: Type]( + F: Expr[Sync[F]] + )(using qctx: Quotes): Expr[SelfAwareStructuredLogger[F]] = { import qctx.reflect._ @tailrec def findEnclosingClass(sym: Symbol): Symbol = { @@ -45,22 +47,18 @@ private[slf4j] object GetLoggerMacros { val flags = s.flags if (flags.is(Flags.Package)) { s.fullName - } - else if (s.isClassDef) { + } else if (s.isClassDef) { if (flags.is(Flags.Module)) { if (s.name == "package$") { fullName(s.owner) - } - else { + } else { val chomped = s.name.stripSuffix("$") fullName(s.owner) + "." + chomped } - } - else { + } else { fullName(s.owner) + "." + s.name } - } - else { + } else { fullName(s.owner) } } @@ -73,8 +71,10 @@ private[slf4j] object GetLoggerMacros { logger(cls) } - def createImpl[F[_]: Type](F: Expr[Sync[F]])(using qctx: Quotes): Expr[F[SelfAwareStructuredLogger[F]]] = { + def createImpl[F[_]: Type]( + F: Expr[Sync[F]] + )(using qctx: Quotes): Expr[F[SelfAwareStructuredLogger[F]]] = { val logger = getLoggerImpl(F) - '{$F.delay($logger)} + '{ $F.delay($logger) } } } From 58068000a034c9a2d9d15d6c74c20f336b37a6be Mon Sep 17 00:00:00 2001 From: danicheg Date: Fri, 28 Jan 2022 13:19:08 +0300 Subject: [PATCH 5/6] Bump sbt-typelevel version --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 53413b6d..b1d2962b 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,5 +1,5 @@ addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.8.0") addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3") -val sbtTypelevelVersion = "0.4.0" +val sbtTypelevelVersion = "0.4.3" addSbtPlugin("org.typelevel" % "sbt-typelevel" % sbtTypelevelVersion) addSbtPlugin("org.typelevel" % "sbt-typelevel-site" % sbtTypelevelVersion) From 76ef61b20a63071e10201f850c76aff1c6747efa Mon Sep 17 00:00:00 2001 From: danicheg Date: Fri, 28 Jan 2022 13:19:43 +0300 Subject: [PATCH 6/6] Regenerate ci.yml --- .github/workflows/ci.yml | 58 ++++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ccb0b2f9..51f9bcaa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -74,6 +74,7 @@ jobs: run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' 'project /' githubWorkflowCheck - name: Check headers and formatting + if: matrix.java == 'temurin@8' run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' headerCheckAll scalafmtCheckAll 'project /' scalafmtSbtCheck - name: fastOptJS @@ -84,21 +85,26 @@ jobs: run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' test - name: Check binary compatibility + if: matrix.java == 'temurin@8' run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' mimaReportBinaryIssues - name: Generate API documentation + if: matrix.java == 'temurin@8' run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' doc - name: Make target directories + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') run: mkdir -p testing/jvm/target noop/jvm/target target .js/target site/target core/js/target testing/js/target noop/js/target core/jvm/target .jvm/target .native/target slf4j/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 testing/jvm/target noop/jvm/target target .js/target site/target core/js/target testing/js/target noop/js/target core/jvm/target .jvm/target .native/target slf4j/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@v2 with: - name: target-${{ matrix.os }}-${{ matrix.scala }}-${{ matrix.java }} + name: target-${{ matrix.os }}-${{ matrix.java }}-${{ matrix.scala }}-${{ matrix.project }} path: targets.tar publish: @@ -143,32 +149,62 @@ jobs: ~/Library/Caches/Coursier/v1 key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - - name: Download target directories (2.13.8) + - name: Download target directories (2.13.8, rootJS) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.8-rootJS + + - name: Inflate target directories (2.13.8, rootJS) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (2.13.8, rootJVM) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.8-rootJVM + + - name: Inflate target directories (2.13.8, rootJVM) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (2.12.15, rootJS) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.15-rootJS + + - name: Inflate target directories (2.12.15, rootJS) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (2.12.15, rootJVM) uses: actions/download-artifact@v2 with: - name: target-${{ matrix.os }}-2.13.8-${{ matrix.java }} + name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.15-rootJVM - - name: Inflate target directories (2.13.8) + - name: Inflate target directories (2.12.15, rootJVM) run: | tar xf targets.tar rm targets.tar - - name: Download target directories (2.12.15) + - name: Download target directories (3.0.2, rootJS) uses: actions/download-artifact@v2 with: - name: target-${{ matrix.os }}-2.12.15-${{ matrix.java }} + name: target-${{ matrix.os }}-${{ matrix.java }}-3.0.2-rootJS - - name: Inflate target directories (2.12.15) + - name: Inflate target directories (3.0.2, rootJS) run: | tar xf targets.tar rm targets.tar - - name: Download target directories (3.0.2) + - name: Download target directories (3.0.2, rootJVM) uses: actions/download-artifact@v2 with: - name: target-${{ matrix.os }}-3.0.2-${{ matrix.java }} + name: target-${{ matrix.os }}-${{ matrix.java }}-3.0.2-rootJVM - - name: Inflate target directories (3.0.2) + - name: Inflate target directories (3.0.2, rootJVM) run: | tar xf targets.tar rm targets.tar @@ -228,7 +264,7 @@ jobs: key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - name: Generate site - run: sbt '++${{ matrix.scala }}' tlSite + run: sbt '++${{ matrix.scala }}' docs/tlSite - name: Publish site if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'