Skip to content

Commit

Permalink
Merge branch 'main' into oom
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlar authored Nov 4, 2024
2 parents 2caf4cf + df186d4 commit d14a04d
Show file tree
Hide file tree
Showing 9 changed files with 156 additions and 85 deletions.
174 changes: 115 additions & 59 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion .github/workflows/site.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was autogenerated using `zio-sbt-website` via `sbt generateGithubWorkflow`
# This file was autogenerated using `zio-sbt-website` via `sbt generateGithubWorkflow`
# task and should be included in the git repository. Please do not edit it manually.

name: Website
Expand All @@ -23,6 +23,7 @@ jobs:
uses: actions/checkout@v3.3.0
with:
fetch-depth: '0'
- uses: coursier/setup-action@v1
- name: Setup Scala
uses: actions/setup-java@v3.9.0
with:
Expand All @@ -48,6 +49,7 @@ jobs:
distribution: temurin
java-version: 17
check-latest: true
- uses: coursier/setup-action@v1
- name: Setup NodeJs
uses: actions/setup-node@v3
with:
Expand All @@ -67,6 +69,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: '0'
- uses: coursier/setup-action@v1
- name: Install libuv
run: sudo apt-get update && sudo apt-get install -y libuv1-dev
- name: Setup Scala
Expand Down
7 changes: 6 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ ThisBuild / githubWorkflowAddedJobs :=
WorkflowJob(
id = "mima_check",
name = "Mima Check",
steps = WorkflowStep.CheckoutFull +: WorkflowStep.SetupJava(List(JavaSpec.temurin("21"))) :+ WorkflowStep.Sbt(List("mimaChecks")),
steps = List(
WorkflowStep.Use(UseRef.Public("actions", "checkout", "v4"), Map("fetch-depth" -> "0")),
WorkflowStep.Use(UseRef.Public("coursier", "setup-action", "v1")),
) ++ WorkflowStep.SetupJava(List(JavaSpec.temurin("21"))) :+ WorkflowStep.Sbt(List("mimaChecks")),
cond = Option("${{ github.event_name == 'pull_request' }}"),
javas = List(JavaSpec.temurin("21")),
),
Expand Down Expand Up @@ -75,6 +78,7 @@ ThisBuild / githubWorkflowPublish :=
//scala fix isn't available for scala 3 so ensure we only run the fmt check
//using the latest scala 2.13
ThisBuild / githubWorkflowBuildPreamble := Seq(
WorkflowStep.Use(UseRef.Public("coursier", "setup-action", "v1")),
WorkflowStep.Run(
name = Some("Check formatting"),
commands = List(s"sbt ++${Scala213} fmtCheck"),
Expand All @@ -87,6 +91,7 @@ ThisBuild / githubWorkflowBuildPostamble :=
"checkDocGeneration",
"Check doc generation",
List(
WorkflowStep.Use(UseRef.Public("coursier", "setup-action", "v1")),
WorkflowStep.Run(
commands = List(s"sbt ++${Scala213} doc"),
name = Some("Check doc generation"),
Expand Down
6 changes: 2 additions & 4 deletions docs/guides/testing-http-apps.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,10 @@ object TestServerExampleSpec extends ZIOSpecDefault {
fallbackResponse <- client.batched(Request.get(testRequest.url / "any"))
fallbackBody <- fallbackResponse.body.asString
} yield assertTrue(helloBody == "Hey there!", fallbackBody == "fallback")
}.provideSome[Client with Driver](TestServer.layer)
}
}.provide(
ZLayer.succeed(Server.Config.default.onAnyOpenPort),
TestServer.default,
Client.default,
NettyDriver.customized,
ZLayer.succeed(NettyConfig.defaultWithFastShutdown),
)
}
```
6 changes: 3 additions & 3 deletions project/BenchmarkWorkFlow.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ object BenchmarkWorkFlow {
commands = List("sudo rm -rf *"),
),
WorkflowStep.Use(
UseRef.Public("actions", "checkout", s"v2"),
UseRef.Public("actions", "checkout", s"v4"),
Map(
"path" -> "zio-http",
),
),
WorkflowStep.Use(
UseRef.Public("actions", "checkout", s"v2"),
UseRef.Public("actions", "checkout", s"v4"),
Map(
"repository" -> "khajavi/FrameworkBenchmarks",
"path" -> "FrameworkBenchMarks",
Expand Down Expand Up @@ -103,7 +103,7 @@ object BenchmarkWorkFlow {
|if (( REQUESTS_PER_SECOND > PERFORMANCE_FLOOR )); then
| echo "Woohoo! Performance is good! $REQUESTS_PER_SECOND requests/sec exceeds the performance floor of $PERFORMANCE_FLOOR requests/sec."
|else
|else
| echo "Performance benchmark failed with $REQUESTS_PER_SECOND req/sec! Performance must exceed $PERFORMANCE_FLOOR req/sec."
| exit 1
|fi""".stripMargin,
Expand Down
13 changes: 7 additions & 6 deletions project/JmhBenchmarkWorkflow.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ object JmhBenchmarkWorkflow {
Glob("zio-http-benchmarks/src/main/scala-2.13/**"),
Glob("zio-http-benchmarks/src/main/scala/**")),scalaSources
)

/**
* Get zioHttpBenchmark file names
*/
Expand Down Expand Up @@ -45,7 +45,7 @@ object JmhBenchmarkWorkflow {
def downloadArtifacts(branch: String, batchSize: Int) = groupedBenchmarks(batchSize).flatMap(l => {
Seq(
WorkflowStep.Use(
ref = UseRef.Public("actions", "download-artifact", "v3"),
ref = UseRef.Public("actions", "download-artifact", "v4"),
Map(
"name" -> s"Jmh_${branch}_${l.head}",
),
Expand Down Expand Up @@ -84,7 +84,7 @@ object JmhBenchmarkWorkflow {
steps = downloadArtifacts("Main", batchSize) ++
Seq(
WorkflowStep.Use(
UseRef.Public("actions", "checkout", "v2"),
UseRef.Public("actions", "checkout", "v4"),
Map(
"path" -> "zio-http"
)
Expand Down Expand Up @@ -113,14 +113,15 @@ object JmhBenchmarkWorkflow {
),
scalas = List(Scala213),
steps = List(
WorkflowStep.Use(UseRef.Public("coursier", "setup-action","v1"), Map("apps" -> "sbt")),
WorkflowStep.Use(
UseRef.Public("actions", "checkout", "v2"),
UseRef.Public("actions", "checkout", "v4"),
Map(
"path" -> "zio-http",
),
),
WorkflowStep.Use(
UseRef.Public("actions", "setup-java", "v2"),
UseRef.Public("actions", "setup-java", "v4"),
Map(
"distribution" -> "temurin",
"java-version" -> "11",
Expand All @@ -137,7 +138,7 @@ object JmhBenchmarkWorkflow {
name = Some("Benchmark_Main"),
),
WorkflowStep.Use(
UseRef.Public("actions", "upload-artifact", "v3"),
UseRef.Public("actions", "upload-artifact", "v4"),
Map(
"name" -> s"Jmh_Main_${l.head}",
"path" -> s"Main_${l.head}.txt",
Expand Down
5 changes: 3 additions & 2 deletions project/ScoverageWorkFlow.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import BuildHelper.{Scala213, ScoverageVersion}
import sbtghactions.GenerativePlugin.autoImport.{WorkflowJob, WorkflowStep}
import sbtghactions.GenerativePlugin.autoImport.{UseRef, WorkflowJob, WorkflowStep}

object ScoverageWorkFlow {
// TODO move plugins to plugins.sbt after scoverage's support for Scala 3
Expand All @@ -15,7 +15,8 @@ object ScoverageWorkFlow {
name = "Unsafe Scoverage",
scalas = List(Scala213),
steps = List(
WorkflowStep.CheckoutFull,
WorkflowStep.Use(UseRef.Public("actions", "checkout", "v4"), Map("fetch-depth" -> "0")),
WorkflowStep.Use(UseRef.Public("coursier", "setup-action","v1"), Map("apps" -> "sbt")),
WorkflowStep.Run(
commands = List(s"sed -i -e '$$a${scoveragePlugin}' project/plugins.sbt"),
id = Some("add_plugin"),
Expand Down
10 changes: 10 additions & 0 deletions zio-http-testkit/src/main/scala/zio/http/TestServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package zio.http

import zio._

import zio.http.netty.NettyConfig
import zio.http.netty.server.NettyDriver

/**
* Enables tests that make calls against "localhost" with user-specified
* Behavior/Responses.
Expand Down Expand Up @@ -136,4 +139,11 @@ object TestServer {
} yield TestServer(driver, result.port)
}

val default: ZLayer[Any, Nothing, Server with TestServer] = ZLayer.make[Server with TestServer][Nothing](
TestServer.layer.orDie,
ZLayer.succeed(Server.Config.default.onAnyOpenPort),
NettyDriver.customized.orDie,
ZLayer.succeed(NettyConfig.defaultWithFastShutdown),
)

}
15 changes: 6 additions & 9 deletions zio-http-testkit/src/test/scala/zio/http/TestServerSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ object TestServerSpec extends ZIOHttpSpec {
)
} yield assertTrue(status(response1) == Status.Ok) &&
assertTrue(status(response2) == Status.InternalServerError)
}.provideSome[Client with Driver](
TestServer.layer,
}.provideSome[Client](
TestServer.default,
Scope.default,
),
suite("Exact Request=>Response version")(
Expand Down Expand Up @@ -83,8 +83,8 @@ object TestServerSpec extends ZIOHttpSpec {
} yield assertTrue(status(finalResponse) == Status.NotFound)
},
)
.provideSome[Client with Driver](
TestServer.layer,
.provideSome[Client](
TestServer.default,
Scope.default,
),
test("add routes to the server") {
Expand All @@ -102,15 +102,12 @@ object TestServerSpec extends ZIOHttpSpec {
fallbackResponse <- client(Request.get(testRequest.url / "any"))
fallbackBody <- fallbackResponse.body.asString
} yield assertTrue(helloBody == "Hey there!", fallbackBody == "fallback")
}.provideSome[Client with Driver](
TestServer.layer,
}.provideSome[Client](
TestServer.default,
Scope.default,
),
).provide(
ZLayer.succeed(Server.Config.default.onAnyOpenPort),
Client.default,
NettyDriver.customized,
ZLayer.succeed(NettyConfig.defaultWithFastShutdown),
)

private def requestToCorrectPort =
Expand Down

0 comments on commit d14a04d

Please sign in to comment.