diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6d018e86..c997c678 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -96,6 +96,10 @@ jobs: if: matrix.java == 'temurin@8' run: 'sbt ''++${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.jsenv }}'' doc' + - name: Monitor artifact size + if: matrix.jsenv == 'Chrome' + run: 'sbt ''++${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.jsenv }}'' artifactSizeTest/bundleMon' + - name: Check scalafix lints if: matrix.java == 'temurin@8' && !startsWith(matrix.scala, '3.') run: 'sbt ''++${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.jsenv }}'' ''scalafixAll --check''' @@ -106,11 +110,11 @@ jobs: - name: Make target directories if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') - run: mkdir -p target site/target tests/target dom/target tests-nodejs/target jsdocs/target project/target + run: mkdir -p target site/target tests/target dom/target artifact-size-test/target tests-nodejs/target jsdocs/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 target site/target tests/target dom/target tests-nodejs/target jsdocs/target project/target + run: tar cf targets.tar target site/target tests/target dom/target artifact-size-test/target tests-nodejs/target jsdocs/target project/target - name: Upload target directories if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') diff --git a/.scalafmt.conf b/.scalafmt.conf index e1c3a6dd..e3c928ea 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,4 @@ -version = 3.5.8 +version = 3.5.9 runner.dialect = Scala213Source3 diff --git a/artifact-size-test/src/main/scala/Main.scala b/artifact-size-test/src/main/scala/Main.scala new file mode 100644 index 00000000..9af81f92 --- /dev/null +++ b/artifact-size-test/src/main/scala/Main.scala @@ -0,0 +1,29 @@ +/* + * Copyright 2021 http4s.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import cats.effect._ +import cats.effect.unsafe.implicits._ +import io.circe._ +import org.http4s.circe._ +import org.http4s.client._ +import org.http4s.dom._ + +object Main { + val client: Client[IO] = FetchClientBuilder[IO].create + + def main(args: Array[String]): Unit = + client.expect[Json]("https://api.github.com/repos/http4s/http4s").unsafeRunAndForget() +} diff --git a/build.sbt b/build.sbt index 3cc16ac1..51d40260 100644 --- a/build.sbt +++ b/build.sbt @@ -63,16 +63,18 @@ Global / fileServicePort := { import cats.data.Kleisli import cats.effect.IO import cats.effect.unsafe.implicits.global + import com.comcast.ip4s._ import org.http4s._ import org.http4s.dsl.io._ - import org.http4s.blaze.server.BlazeServerBuilder + import org.http4s.ember.server.EmberServerBuilder import org.http4s.server.staticcontent._ import java.net.InetSocketAddress (for { deferredPort <- IO.deferred[Int] - _ <- BlazeServerBuilder[IO] - .bindSocketAddress(new InetSocketAddress("localhost", 0)) + _ <- EmberServerBuilder + .default[IO] + .withPort(port"0") .withHttpWebSocketApp { wsb => HttpRoutes .of[IO] { @@ -91,7 +93,7 @@ Global / fileServicePort := { } .orNotFound } - .resource + .build .map(_.address.getPort) .evalTap(deferredPort.complete(_)) .useForever @@ -120,16 +122,18 @@ ThisBuild / Test / jsEnv := { } } -val catsEffectVersion = "3.3.13" -val fs2Version = "3.2.9" +val catsEffectVersion = "3.3.14" +val fs2Version = "3.2.12" val http4sVersion = "1.0.0-M34" val scalaJSDomVersion = "2.2.0" val circeVersion = "0.14.2" val munitVersion = "0.7.29" val munitCEVersion = "1.0.7" -lazy val root = - project.in(file(".")).aggregate(dom, tests, nodeJSTests).enablePlugins(NoPublishPlugin) +lazy val root = project + .in(file(".")) + .aggregate(dom, tests, nodeJSTests, artifactSizeTest) + .enablePlugins(NoPublishPlugin) lazy val dom = project .in(file("dom")) @@ -194,6 +198,27 @@ lazy val nodeJSTests = project .dependsOn(dom) .enablePlugins(ScalaJSPlugin, NoPublishPlugin) +lazy val artifactSizeTest = project + .in(file("artifact-size-test")) + .settings( + scalaJSUseMainModuleInitializer := true, + libraryDependencies ++= Seq( + "org.http4s" %%% "http4s-circe" % http4sVersion + ), + bundleMonCheckRun := true, + bundleMonCommitStatus := false, + bundleMonPrComment := false + ) + .dependsOn(dom) + .enablePlugins(BundleMonPlugin, NoPublishPlugin) + +ThisBuild / githubWorkflowBuild += + WorkflowStep.Sbt( + List("artifactSizeTest/bundleMon"), + name = Some("Monitor artifact size"), + cond = Some("matrix.jsenv == 'Chrome'") + ) + lazy val jsdocs = project .dependsOn(dom) diff --git a/project/build.properties b/project/build.properties index c8fcab54..22af2628 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.6.2 +sbt.version=1.7.1 diff --git a/project/plugins.sbt b/project/plugins.sbt index b838f0b8..af3c22a9 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,13 +1,14 @@ -val http4sVersion = "0.23.13" +val http4sVersion = "0.23.15" enablePlugins(BuildInfoPlugin) buildInfoKeys += "http4sVersion" -> http4sVersion libraryDependencies += "org.scala-js" %% "scalajs-env-selenium" % "1.1.1" libraryDependencies += "org.http4s" %% "http4s-dsl" % http4sVersion -libraryDependencies += "org.http4s" %% "http4s-blaze-server" % "0.23.12" +libraryDependencies += "org.http4s" %% "http4s-ember-server" % http4sVersion -addSbtPlugin("org.http4s" % "sbt-http4s-org" % "0.14.3") -addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.2") +addSbtPlugin("org.http4s" % "sbt-http4s-org" % "0.14.4") +addSbtPlugin("com.armanbilge" % "sbt-bundlemon" % "0.1.3") +addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.3") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.1") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")