Skip to content

Commit

Permalink
Merge pull request #97 from danicheg/sbt-http4s-org
Browse files Browse the repository at this point in the history
Migrate to `sbt-http4s-org` plugin
  • Loading branch information
danicheg authored Mar 17, 2024
2 parents 486967d + 163282f commit 26d5a0a
Show file tree
Hide file tree
Showing 19 changed files with 566 additions and 349 deletions.
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# #97 Introduce sbt-http4s-org plugin
b92d1dbfcc29d3afcca0d2c143528f07b949dcd3
126 changes: 92 additions & 34 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,25 @@ jobs:
build:
name: Build and Test
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
scala: [2.13, 3]
java: [temurin@8]
java: [temurin@8, temurin@11, temurin@17]
project: [http4s-grpcJVM, http4s-grpcJS, http4s-grpcNative]
exclude:
- scala: 3
java: temurin@11
- scala: 3
java: temurin@17
- project: http4s-grpcJS
java: temurin@11
- project: http4s-grpcJS
java: temurin@17
- project: http4s-grpcNative
java: temurin@11
- project: http4s-grpcNative
java: temurin@17
runs-on: ${{ matrix.os }}
timeout-minutes: 60
steps:
Expand All @@ -52,9 +66,39 @@ jobs:
if: matrix.java == 'temurin@8' && steps.setup-java-temurin-8.outputs.cache-hit == 'false'
run: sbt +update

- name: Setup Java (temurin@11)
id: setup-java-temurin-11
if: matrix.java == 'temurin@11'
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11
cache: sbt

- name: sbt update
if: matrix.java == 'temurin@11' && steps.setup-java-temurin-11.outputs.cache-hit == 'false'
run: sbt +update

- name: Setup Java (temurin@17)
id: setup-java-temurin-17
if: matrix.java == 'temurin@17'
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
cache: sbt

- name: sbt update
if: matrix.java == 'temurin@17' && steps.setup-java-temurin-17.outputs.cache-hit == 'false'
run: sbt +update

- name: Check that workflows are up to date
run: sbt githubWorkflowCheck

- name: Check headers and formatting
if: matrix.java == 'temurin@8' && matrix.os == 'ubuntu-latest'
run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' headerCheckAll scalafmtCheckAll 'project /' scalafmtSbtCheck

- name: scalaJSLink
if: matrix.project == 'http4s-grpcJS'
run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' Test/scalaJSLinkerResult
Expand All @@ -74,6 +118,14 @@ jobs:
if: matrix.java == 'temurin@8' && matrix.os == 'ubuntu-latest'
run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' doc

- name: Check scalafix lints
if: matrix.java == 'temurin@8' && !startsWith(matrix.scala, '3')
run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' 'scalafixAll --check'

- name: Check unused compile dependencies
if: matrix.java == 'temurin@8'
run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' unusedCompileDependenciesTest

- name: Make target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
run: mkdir -p core/.native/target core/.js/target codegen/plugin/target core/.jvm/target codegen/generator/target project/target
Expand Down Expand Up @@ -117,6 +169,32 @@ jobs:
if: matrix.java == 'temurin@8' && steps.setup-java-temurin-8.outputs.cache-hit == 'false'
run: sbt +update

- name: Setup Java (temurin@11)
id: setup-java-temurin-11
if: matrix.java == 'temurin@11'
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11
cache: sbt

- name: sbt update
if: matrix.java == 'temurin@11' && steps.setup-java-temurin-11.outputs.cache-hit == 'false'
run: sbt +update

- name: Setup Java (temurin@17)
id: setup-java-temurin-17
if: matrix.java == 'temurin@17'
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
cache: sbt

- name: sbt update
if: matrix.java == 'temurin@17' && steps.setup-java-temurin-17.outputs.cache-hit == 'false'
run: sbt +update

- name: Download target directories (2.13, http4s-grpcJVM)
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -201,39 +279,6 @@ jobs:
SONATYPE_CREDENTIAL_HOST: ${{ secrets.SONATYPE_CREDENTIAL_HOST }}
run: sbt tlCiRelease

dependency-submission:
name: Submit Dependencies
if: github.event_name != 'pull_request'
strategy:
matrix:
os: [ubuntu-latest]
java: [temurin@8]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Java (temurin@8)
id: setup-java-temurin-8
if: matrix.java == 'temurin@8'
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 8
cache: sbt

- name: sbt update
if: matrix.java == 'temurin@8' && steps.setup-java-temurin-8.outputs.cache-hit == 'false'
run: sbt +update

- name: Submit Dependencies
uses: scalacenter/sbt-dependency-submission@v2
with:
modules-ignore: http4s-grpcjvm_2.13 http4s-grpcjvm_3 codegeneratortesting_native0.4_2.13 codegeneratortesting_native0.4_3 codegeneratortesting_sjs1_2.13 codegeneratortesting_sjs1_3 site_2.13 site_3 http4s-grpcjs_2.13 http4s-grpcjs_3 http4s-grpcnative_2.13 http4s-grpcnative_3 codegeneratortesting_2.13 codegeneratortesting_3
configs-ignore: test scala-tool scala-doc-tool test-internal

site:
name: Generate Site
strategy:
Expand Down Expand Up @@ -273,6 +318,19 @@ jobs:
if: matrix.java == 'temurin@11' && steps.setup-java-temurin-11.outputs.cache-hit == 'false'
run: sbt +update

- name: Setup Java (temurin@17)
id: setup-java-temurin-17
if: matrix.java == 'temurin@17'
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
cache: sbt

- name: sbt update
if: matrix.java == 'temurin@17' && steps.setup-java-temurin-17.outputs.cache-hit == 'false'
run: sbt +update

- name: Generate site
run: sbt site/tlSite

Expand Down
15 changes: 15 additions & 0 deletions .scalafix.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
rules = [
Http4sFs2Linters
Http4sGeneralLinters
Http4sUseLiteralsSyntax
LeakingImplicitClassVal
ExplicitResultTypes
OrganizeImports
]

triggered.rules = [
Http4sFs2Linters
Http4sGeneralLinters
Http4sUseLiteralsSyntax
LeakingImplicitClassVal
]
38 changes: 38 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
version = 3.8.0

style = default

maxColumn = 100

// Docstring wrapping breaks doctests
docstrings.wrap = false

// Vertical alignment is pretty, but leads to bigger diffs
align.preset = none

danglingParentheses.preset = true

rewrite.rules = [
AvoidInfix
RedundantBraces
RedundantParens
PreferCurlyFors
SortModifiers
]

rewrite.sortModifiers.order = [
override, implicit, private, protected, final, sealed, abstract, lazy
]

rewrite.trailingCommas.style = multiple

runner.dialect = scala212

fileOverride {
"glob:**/scala-3/**/*.scala" {
runner.dialect = scala3
}
"glob:**/scala-2.13/**/*.scala" {
runner.dialect = scala213
}
}
93 changes: 56 additions & 37 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
ThisBuild / tlBaseVersion := "0.0" // your current series x.y
import explicitdeps.ExplicitDepsPlugin.autoImport.moduleFilterRemoveValue

ThisBuild / tlBaseVersion := "0.1"

ThisBuild / organization := "io.chrisdavenport"
ThisBuild / organizationName := "Christopher Davenport"
ThisBuild / licenses := Seq(License.MIT)
ThisBuild / developers := List(
tlGitHubDev("christopherdavenport", "Christopher Davenport")
)
ThisBuild / tlCiReleaseBranches := Seq("main")
ThisBuild / tlSonatypeUseLegacyHost := true
ThisBuild / tlSonatypeUseLegacyHost := false

ThisBuild / tlMimaPreviousVersions := Set()

Expand All @@ -17,6 +17,12 @@ val Scala213 = "2.13.12"
ThisBuild / crossScalaVersions := Seq(Scala213, "3.3.1")
ThisBuild / scalaVersion := Scala213

// disable sbt-header plugin until we are not aligned on the license
ThisBuild / headerCheckAll := Nil

// temporarily disable dependency submissions in CI
ThisBuild / tlCiDependencyGraphJob := false

val catsV = "2.10.0"
val catsEffectV = "3.5.4"
val fs2V = "3.9.2"
Expand All @@ -27,41 +33,47 @@ import scalapb.compiler.Version.scalapbVersion
// Projects
lazy val `http4s-grpc` = tlCrossRootProject
.aggregate(core, codeGenerator, codeGeneratorTesting, codeGeneratorPlugin)
.settings(
unusedCompileDependenciesFilter -= moduleFilter()
)
.disablePlugins(HeaderPlugin)

lazy val core = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("core"))
.settings(
name := "http4s-grpc",

libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-core" % catsV,
"org.typelevel" %%% "cats-effect" % catsEffectV,

"co.fs2" %%% "fs2-core" % fs2V,
"co.fs2" %%% "fs2-io" % fs2V,
"co.fs2" %%% "fs2-scodec" % fs2V,

"org.http4s" %%% "http4s-dsl" % http4sV,
"org.http4s" %%% "http4s-ember-server" % http4sV,
"org.http4s" %%% "http4s-ember-client" % http4sV,

"org.typelevel" %%% "munit-cats-effect" % munitCatsEffectV % Test,

"org.typelevel" %%% "cats-core" % catsV,
"org.typelevel" %%% "cats-effect" % catsEffectV,
"co.fs2" %%% "fs2-core" % fs2V,
"co.fs2" %%% "fs2-io" % fs2V,
"co.fs2" %%% "fs2-scodec" % fs2V,
"org.http4s" %%% "http4s-dsl" % http4sV,
"org.http4s" %%% "http4s-ember-server" % http4sV,
"org.http4s" %%% "http4s-ember-client" % http4sV,
"org.typelevel" %%% "munit-cats-effect" % munitCatsEffectV % Test,
"com.thesamet.scalapb" %%% "scalapb-runtime" % scalapbVersion,

)
).jsSettings(
scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.CommonJSModule)},
),
unusedCompileDependenciesFilter -= moduleFilter(),
)

lazy val codeGenerator = project.in(file("codegen/generator")).settings(
name := "http4s-grpc-generator",
crossScalaVersions := Seq(Scala212),
libraryDependencies ++= Seq(
"com.thesamet.scalapb" %% "compilerplugin" % scalapbVersion
.jsSettings(
scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.CommonJSModule) }
)
)
.disablePlugins(HeaderPlugin)

lazy val codeGenerator =
project
.in(file("codegen/generator"))
.settings(
name := "http4s-grpc-generator",
crossScalaVersions := Seq(Scala212),
libraryDependencies ++= Seq(
"com.thesamet.scalapb" %% "compilerplugin" % scalapbVersion
),
unusedCompileDependenciesFilter -= moduleFilter(),
)
.disablePlugins(HeaderPlugin, ScalafixPlugin)

lazy val codegenFullName =
"org.http4s.grpc.generator.Http4sGrpcCodeGenerator"
Expand All @@ -86,35 +98,42 @@ lazy val codeGeneratorPlugin = project
"com.thesamet.scalapb" %% "compilerplugin" % scalapbVersion
),
addSbtPlugin("com.thesamet" % "sbt-protoc" % "1.0.7"),
addSbtPlugin("org.portable-scala" % "sbt-platform-deps" % "1.0.2")
addSbtPlugin("org.portable-scala" % "sbt-platform-deps" % "1.0.2"),
unusedCompileDependenciesFilter -= moduleFilter(),
)
.disablePlugins(HeaderPlugin, ScalafixPlugin)

lazy val codeGeneratorTesting = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("codegen/testing"))
.enablePlugins(LocalCodeGenPlugin, BuildInfoPlugin, NoPublishPlugin)
.dependsOn(core)
.settings(
tlFatalWarnings := false,
codeGenClasspath := (codeGenerator / Compile / fullClasspath).value,
Compile / PB.targets := Seq(
scalapb.gen(grpc = false) -> (Compile / sourceManaged).value / "scalapb",
genModule(codegenFullName + "$") -> (Compile / sourceManaged).value / "http4s-grpc"
genModule(codegenFullName + "$") -> (Compile / sourceManaged).value / "http4s-grpc",
),
Compile / PB.protoSources += baseDirectory.value.getParentFile / "src" / "main" / "protobuf",
libraryDependencies ++= Seq(
"com.thesamet.scalapb" %%% "scalapb-runtime" % scalapbVersion % "protobuf",
"org.typelevel" %%% "munit-cats-effect" % munitCatsEffectV % Test,
"org.typelevel" %%% "scalacheck-effect-munit" % "2.0.0-M2" % Test
"org.typelevel" %%% "scalacheck-effect-munit" % "2.0.0-M2" % Test,
),
buildInfoPackage := "org.http4s.grpc.e2e.buildinfo",
buildInfoKeys := Seq[BuildInfoKey]("sourceManaged" -> (Compile / sourceManaged).value / "http4s-grpc"),
githubWorkflowArtifactUpload := false
buildInfoKeys := Seq[BuildInfoKey](
"sourceManaged" -> (Compile / sourceManaged).value / "http4s-grpc"
),
githubWorkflowArtifactUpload := false,
unusedCompileDependenciesFilter -= moduleFilter(),
)
.disablePlugins(HeaderPlugin, ScalafixPlugin)


lazy val site = project.in(file("site"))
lazy val site = project
.in(file("site"))
.enablePlugins(TypelevelSitePlugin)
.dependsOn(core.jvm)
.settings(
tlSiteIsTypelevelProject := Some(TypelevelProject.Affiliate),
tlSiteIsTypelevelProject := Some(TypelevelProject.Affiliate)
)
Loading

0 comments on commit 26d5a0a

Please sign in to comment.