Skip to content

Commit

Permalink
Merge pull request #828 from danicheg/merge-series/0.23-into-main
Browse files Browse the repository at this point in the history
Merge series/0.23 into main
  • Loading branch information
danicheg authored Sep 9, 2023
2 parents 1ca0d2d + 7dacae4 commit 75f4a93
Show file tree
Hide file tree
Showing 16 changed files with 114 additions and 91 deletions.
139 changes: 81 additions & 58 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,56 +15,42 @@ on:
tags: [v*]

env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_CREDENTIAL_HOST: ${{ secrets.SONATYPE_CREDENTIAL_HOST }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


concurrency:
group: ${{ github.workflow }} @ ${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build and Test
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
scala: [3.3.0, 2.13.11]
scala: [3, 2.13]
java: [temurin@8]
runs-on: ${{ matrix.os }}
timeout-minutes: 60
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Download Java (temurin@8)
id: download-java-temurin-8
if: matrix.java == 'temurin@8'
uses: typelevel/download-java@v2
with:
distribution: temurin
java-version: 8

- name: Setup Java (temurin@8)
id: setup-java-temurin-8
if: matrix.java == 'temurin@8'
uses: actions/setup-java@v3
with:
distribution: jdkfile
distribution: temurin
java-version: 8
jdkFile: ${{ steps.download-java-temurin-8.outputs.jdkFile }}
cache: sbt

- name: Cache sbt
uses: actions/cache@v3
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: sbt update
if: matrix.java == 'temurin@8' && steps.setup-java-temurin-8.outputs.cache-hit == 'false'
run: sbt +update

- name: Check that workflows are up to date
run: sbt githubWorkflowCheck
Expand All @@ -88,7 +74,7 @@ jobs:
run: sbt '++ ${{ matrix.scala }}' '${{ matrix.ci }}' javafmtCheckAll

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

- name: Check unused compile dependencies
Expand All @@ -97,11 +83,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 blaze-client/target target blaze-server/target examples/target http/target core/target blaze-core/target testkit/target project/target
run: mkdir -p blaze-client/target blaze-server/target http/target core/target blaze-core/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 blaze-client/target target blaze-server/target examples/target http/target core/target blaze-core/target testkit/target project/target
run: tar cf targets.tar blaze-client/target blaze-server/target http/target core/target blaze-core/target project/target

- name: Upload target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
Expand All @@ -125,78 +111,115 @@ jobs:
with:
fetch-depth: 0

- name: Download Java (temurin@8)
id: download-java-temurin-8
if: matrix.java == 'temurin@8'
uses: typelevel/download-java@v2
with:
distribution: temurin
java-version: 8

- name: Setup Java (temurin@8)
id: setup-java-temurin-8
if: matrix.java == 'temurin@8'
uses: actions/setup-java@v3
with:
distribution: jdkfile
distribution: temurin
java-version: 8
jdkFile: ${{ steps.download-java-temurin-8.outputs.jdkFile }}
cache: sbt

- name: Cache sbt
uses: actions/cache@v3
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: Download target directories (3.3.0)
- name: sbt update
if: matrix.java == 'temurin@8' && steps.setup-java-temurin-8.outputs.cache-hit == 'false'
run: sbt +update

- name: Download target directories (3)
uses: actions/download-artifact@v3
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-3.3.0
name: target-${{ matrix.os }}-${{ matrix.java }}-3

- name: Inflate target directories (3.3.0)
- name: Inflate target directories (3)
run: |
tar xf targets.tar
rm targets.tar
- name: Download target directories (2.13.11)
- name: Download target directories (2.13)
uses: actions/download-artifact@v3
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.11
name: target-${{ matrix.os }}-${{ matrix.java }}-2.13

- name: Inflate target directories (2.13.11)
- name: Inflate target directories (2.13)
run: |
tar xf targets.tar
rm targets.tar
- name: Import signing key
if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE == ''
env:
PGP_SECRET: ${{ secrets.PGP_SECRET }}
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
run: echo $PGP_SECRET | base64 -di | gpg --import

- name: Import signing key and strip passphrase
if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE != ''
env:
PGP_SECRET: ${{ secrets.PGP_SECRET }}
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
run: |
echo "$PGP_SECRET" | base64 -di > /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: Publish
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
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@v3
with:
fetch-depth: 0

- name: Setup Java (temurin@8)
id: setup-java-temurin-8
if: matrix.java == 'temurin@8'
uses: actions/setup-java@v3
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: blaze_3 blaze_2.13 blaze-examples_3 blaze-examples_2.13 sbt-http4s-org-scalafix-internal_3 sbt-http4s-org-scalafix-internal_2.13 blaze-testkit_3 blaze-testkit_2.13
configs-ignore: test scala-tool scala-doc-tool test-internal

validate-steward:
name: Validate Steward Config
strategy:
matrix:
os: [ubuntu-latest]
java: [temurin@11]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (fast)
uses: actions/checkout@v3

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

- uses: coursier/setup-action@v1
with:
apps: scala-steward
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ object BlazeClient {
dispatcher,
)
if (retries > 0)
Retry(retryPolicy(retries))(base)
Retry(retryPolicy[F](retries))(base)
else
base
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class BlazeClient213Suite extends BlazeClientBase {
}

val allRequests = for {
_ <- failedRequests.handleErrorWith(_ => IO.unit).replicateA(5)
_ <- failedRequests.recoverWith(_ => IO.pure(List.empty[String])).replicateA(5)
r <- successfulRequests
} yield r

Expand Down Expand Up @@ -134,7 +134,7 @@ class BlazeClient213Suite extends BlazeClientBase {
}.parSequence

val allRequests = for {
_ <- failedRequests.handleErrorWith(_ => IO.unit).replicateA(5)
_ <- failedRequests.recoverWith(_ => IO.pure(List.empty[String])).replicateA(5)
r <- successRequests
} yield r

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class Http1ClientStageSuite extends CatsEffectSuite with DispatcherIOFixture {

dispatcher.test("Submit a request line with a query".flaky) { dispatcher =>
val uri = "/huh?foo=bar"
val Right(parsed) = Uri.fromString("http://www.foo.test" + uri)
val Right(parsed) = Uri.fromString("http://www.foo.test" + uri): @unchecked
val req = Request[IO](uri = parsed)

getSubmission(req, resp, dispatcher).map { case (request, response) =>
Expand Down
6 changes: 3 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Dependencies._

val Scala213 = "2.13.11"
val Scala3 = "3.3.0"
val Scala3 = "3.3.1"
val http4sVersion = "1.0.0-M40"
val munitCatsEffectVersion = "2.0.0-M3"

Expand All @@ -11,7 +11,7 @@ ThisBuild / resolvers +=
ThisBuild / crossScalaVersions := Seq(Scala3, Scala213)
ThisBuild / scalaVersion := crossScalaVersions.value.filter(_.startsWith("2.")).last
ThisBuild / tlBaseVersion := "1.0"
ThisBuild / tlFatalWarningsInCi := !tlIsScala3.value // See SSLStage
ThisBuild / tlFatalWarnings := !tlIsScala3.value // See SSLStage

// 11 and 17 blocked by https://github.com/http4s/blaze/issues/376
ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.temurin("8"))
Expand Down Expand Up @@ -145,7 +145,7 @@ lazy val examples = Project("blaze-examples", file("examples"))
libraryDependencies ++= Seq(
"org.http4s" %% "http4s-dsl" % http4sVersion,
"org.http4s" %% "http4s-circe" % http4sVersion,
"io.circe" %% "circe-generic" % "0.14.5",
"io.circe" %% "circe-generic" % "0.14.6",
),
Test / scalafixConfig := Some(file(".scalafix.test.conf")),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ object BufferTools {
def joinBuffers(buffers: collection.Seq[ByteBuffer]): ByteBuffer =
buffers match {
case Seq() => emptyBuffer
case Seq(b) => b
case Seq(b: ByteBuffer) => b
case _ =>
val sz = buffers.foldLeft(0)((sz, o) => sz + o.remaining())
val b = allocate(sz)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class ExampleService[F[_]](implicit F: Async[F]) extends Http4sDsl[F] {
case None => BadRequest("Invalid data: " + data)
}
}
.handleErrorWith { // We can handle errors using effect methods
.recoverWith { // We can handle errors using effect methods
case e: NumberFormatException => BadRequest("Not an int: " + e.getMessage)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class Module[F[_]: Async: Compression: Files: LoggerFactory](client: Client[F])
private val gitHubService = new GitHubService[F](client)

def middleware: HttpMiddleware[F] = { (routes: HttpRoutes[F]) =>
GZip(routes)
}.compose(routes => AutoSlash(routes))
AutoSlash(GZip(routes))
}

val fileHttpEndpoint: HttpRoutes[F] =
new FileHttpEndpoint[F](fileService).service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private final class ConnectionImpl(
private[this] var currentState: Connection.State = Connection.Running
private[this] var sentGoAway = false

override val serialExecutor = new SerialExecutionContext(parentExecutor) {
override val serialExecutor: SerialExecutionContext = new SerialExecutionContext(parentExecutor) {
override def reportFailure(cause: Throwable): Unit =
invokeShutdownWithError(Some(cause), "SerialExecutor")
}
Expand All @@ -75,7 +75,7 @@ private final class ConnectionImpl(
new FrameEncoder(remoteSettings, new HeaderEncoder(remoteSettings.maxHeaderListSize))

override val idManager: StreamIdManager = StreamIdManager(isClient)
override val writeController =
override val writeController: WriteControllerImpl =
new WriteControllerImpl(this, 64 * 1024, tailStage)
override val pingManager: PingManager = new PingManager(this)
override val sessionFlowControl: SessionFlowControl =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ object FlowStrategy {
}

/** Representation of the flow window increments to send to the remote peer */
final case class Increment private (session: Int, stream: Int)
final case class Increment private[FlowStrategy] (session: Int, stream: Int)

// Cached version for avoiding allocations in the common case

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class PingManagerSuite extends BlazeTestSuite {
val buffer1 = BufferTools.joinBuffers(tools.writeController.observedWrites.toList)
tools.writeController.observedWrites.clear()

val ProtocolFrame.Ping(false, pingData1) = ProtocolFrameDecoder.decode(buffer1)
val ProtocolFrame.Ping(false, pingData1) = ProtocolFrameDecoder.decode(buffer1): @unchecked
tools.pingManager.pingAckReceived(pingData1)

f1.value match {
Expand All @@ -45,7 +45,7 @@ class PingManagerSuite extends BlazeTestSuite {
val f2 = tools.pingManager.ping()
val buffer2 = BufferTools.joinBuffers(tools.writeController.observedWrites.toList)

val ProtocolFrame.Ping(false, pingData2) = ProtocolFrameDecoder.decode(buffer2)
val ProtocolFrame.Ping(false, pingData2) = ProtocolFrameDecoder.decode(buffer2): @unchecked
tools.pingManager.pingAckReceived(pingData2)

f2.value match {
Expand All @@ -72,7 +72,7 @@ class PingManagerSuite extends BlazeTestSuite {
val buffer1 = BufferTools.joinBuffers(tools.writeController.observedWrites.toList)
tools.writeController.observedWrites.clear()

val ProtocolFrame.Ping(false, pingData) = ProtocolFrameDecoder.decode(buffer1)
val ProtocolFrame.Ping(false, pingData) = ProtocolFrameDecoder.decode(buffer1): @unchecked
tools.pingManager.pingAckReceived(pingData)

f1.value match {
Expand Down
Loading

0 comments on commit 75f4a93

Please sign in to comment.