Skip to content

Commit

Permalink
Merge branch 'main' into sbt-gen-issue-3180-add-sbt-plugin-to-generat…
Browse files Browse the repository at this point in the history
…e-code-from-openapi
  • Loading branch information
987Nabil authored Dec 14, 2024
2 parents 4310523 + e82ca17 commit 5e24f44
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ jobs:
cache: sbt

- uses: coursier/setup-action@v1
with:
apps: sbt

- name: Check formatting
if: matrix.scala == '2.13.14'
Expand All @@ -90,6 +92,8 @@ jobs:
run: sbt '++ ${{ matrix.scala }}' test

- uses: coursier/setup-action@v1
with:
apps: sbt

- name: Test sbt plugin
if: ${{ github.event_name == 'pull_request' }} && matrix.scala == '2.12.19'
Expand Down Expand Up @@ -244,6 +248,8 @@ jobs:
fetch-depth: 0

- uses: coursier/setup-action@v1
with:
apps: sbt

- name: Setup Java (temurin@21)
if: matrix.java == 'temurin@21'
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
with:
fetch-depth: '0'
- uses: coursier/setup-action@v1
with:
apps: 'sbt'
- name: Setup Scala
uses: actions/[email protected]
with:
Expand All @@ -50,6 +52,8 @@ jobs:
java-version: 17
check-latest: true
- uses: coursier/setup-action@v1
with:
apps: 'sbt'
- name: Setup NodeJs
uses: actions/setup-node@v3
with:
Expand All @@ -70,6 +74,8 @@ jobs:
with:
fetch-depth: '0'
- uses: coursier/setup-action@v1
with:
apps: 'sbt'
- name: Install libuv
run: sudo apt-get update && sudo apt-get install -y libuv1-dev
- name: Setup Scala
Expand Down
15 changes: 11 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@ ThisBuild / githubWorkflowPREventTypes := Seq(
PREventType.Edited,
PREventType.Labeled,
)
ThisBuild / githubWorkflowAddedJobs :=

val coursierSetup =
WorkflowStep.Use(
UseRef.Public("coursier", "setup-action", "v1"),
params = Map("apps" -> "sbt"),
)

ThisBuild / githubWorkflowAddedJobs :=
Seq(
WorkflowJob(
id = "update_release_draft",
Expand All @@ -40,7 +47,7 @@ ThisBuild / githubWorkflowAddedJobs :=
name = "Mima Check",
steps = List(
WorkflowStep.Use(UseRef.Public("actions", "checkout", "v4"), Map("fetch-depth" -> "0")),
WorkflowStep.Use(UseRef.Public("coursier", "setup-action", "v1")),
coursierSetup,
) ++ 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 @@ -78,7 +85,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")),
coursierSetup,
WorkflowStep.Run(
name = Some("Check formatting"),
commands = List(s"sbt ++${Scala213} fmtCheck"),
Expand Down Expand Up @@ -107,7 +114,7 @@ ThisBuild / githubWorkflowBuildPostamble :=
"checkDocGeneration",
"Check doc generation",
List(
WorkflowStep.Use(UseRef.Public("coursier", "setup-action", "v1")),
coursierSetup,
WorkflowStep.Run(
commands = List(s"sbt ++${Scala213} doc"),
name = Some("Check doc generation"),
Expand Down
10 changes: 10 additions & 0 deletions zio-http/jvm/src/test/scala/zio/http/ClientSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ object ClientSpec extends RoutesRunnableSpec {
app.deploy(Request(headers = Headers(Header.Authorization.Unparsed("", "my-token")))).flatMap(_.body.asString)
assertZIO(responseContent)(equalTo("my-token"))
} @@ timeout(5.seconds),
test("URL and path manipulation on client level") {
for {
baseURL <- DynamicServer.httpURL
_ <-
Handler.ok.toRoutes.deployAndRequest { c =>
(c.updatePath(_ / "my-service") @@ ZClientAspect.requestLogging()).batched.get("/hello")
}.runZIO(())
loggedUrl <- ZTestLogger.logOutput.map(_.collectFirst { case m => m.annotations("url") }.mkString)
} yield assertTrue(loggedUrl == baseURL + "/my-service/hello")
},
)

override def spec = {
Expand Down
8 changes: 6 additions & 2 deletions zio-http/shared/src/main/scala/zio/http/ZClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,10 @@ final case class ZClient[-Env, ReqEnv, -In, +Err, +Out](

def path(path: String): ZClient[Env, ReqEnv, In, Err, Out] = self.path(Path(path))

def path(path: Path): ZClient[Env, ReqEnv, In, Err, Out] =
copy(url = url.copy(path = path))
def path(path: Path): ZClient[Env, ReqEnv, In, Err, Out] = updatePath(_ => path)

def updatePath(f: Path => Path): ZClient[Env, ReqEnv, In, Err, Out] =
copy(url = url.copy(path = f(url.path)))

def patch(suffix: String)(implicit ev: Body <:< In, trace: Trace): ZIO[Env & ReqEnv, Err, Out] =
request(Method.PATCH, suffix)(ev(Body.empty))
Expand Down Expand Up @@ -263,6 +265,8 @@ final case class ZClient[-Env, ReqEnv, -In, +Err, +Out](
def uri(uri: URI): ZClient[Env, ReqEnv, In, Err, Out] = url(URL.fromURI(uri).getOrElse(URL.empty))

def url(url: URL): ZClient[Env, ReqEnv, In, Err, Out] = copy(url = url)

def updateURL(f: URL => URL): ZClient[Env, ReqEnv, In, Err, Out] = copy(url = f(url))
}

object ZClient extends ZClientPlatformSpecific {
Expand Down

0 comments on commit 5e24f44

Please sign in to comment.