Skip to content

Commit ffed6ef

Browse files
authored
feat(server): add routing without '/binding' (#1494)
Part of #1492. It adds an alternative routing, without the `/binding` part, thanks to which the user-facing URL will be shorter and nicer.
1 parent 20d76fe commit ffed6ef

File tree

5 files changed

+67
-7
lines changed

5 files changed

+67
-7
lines changed

.github/workflows/bindings-server.main.kts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ workflow(
7676
}
7777
}
7878

79+
run(
80+
name = "Execute the script using the bindings from the serve - with /binding",
81+
command = """
82+
mv .github/workflows/test-script-consuming-jit-bindings-old.main.do-not-compile.kts .github/workflows/test-script-consuming-jit-bindings-old.main.kts
83+
.github/workflows/test-script-consuming-jit-bindings-old.main.kts
84+
""".trimIndent(),
85+
)
86+
7987
run(
8088
name = "Execute the script using the bindings from the server",
8189
command = """
@@ -85,13 +93,22 @@ workflow(
8593
)
8694

8795
run(
88-
name = "Fetch maven-metadata.xml for top-level action",
96+
name = "Fetch maven-metadata.xml for top-level action - with /binding",
8997
command = "curl --fail http://localhost:8080/binding/actions/checkout/maven-metadata.xml | grep '<version>v4</version>'",
9098
)
9199
run(
92-
name = "Fetch maven-metadata.xml for nested action",
100+
name = "Fetch maven-metadata.xml for nested action - with /binding",
93101
command = "curl --fail http://localhost:8080/binding/actions/cache__save/maven-metadata.xml | grep '<version>v4</version>'",
94102
)
103+
104+
run(
105+
name = "Fetch maven-metadata.xml for top-level action",
106+
command = "curl --fail http://localhost:8080/actions/checkout/maven-metadata.xml | grep '<version>v4</version>'",
107+
)
108+
run(
109+
name = "Fetch maven-metadata.xml for nested action",
110+
command = "curl --fail http://localhost:8080/actions/cache__save/maven-metadata.xml | grep '<version>v4</version>'",
111+
)
95112
}
96113

97114
job(

.github/workflows/bindings-server.yaml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,27 @@ jobs:
4343
GHWKT_GITHUB_CONTEXT_JSON: '${{ toJSON(github) }}'
4444
run: 'GHWKT_RUN_STEP=''end-to-end-test:step-3'' ''.github/workflows/bindings-server.main.kts'''
4545
- id: 'step-4'
46+
name: 'Execute the script using the bindings from the serve - with /binding'
47+
run: |-
48+
mv .github/workflows/test-script-consuming-jit-bindings-old.main.do-not-compile.kts .github/workflows/test-script-consuming-jit-bindings-old.main.kts
49+
.github/workflows/test-script-consuming-jit-bindings-old.main.kts
50+
- id: 'step-5'
4651
name: 'Execute the script using the bindings from the server'
4752
run: |-
4853
mv .github/workflows/test-script-consuming-jit-bindings.main.do-not-compile.kts .github/workflows/test-script-consuming-jit-bindings.main.kts
4954
.github/workflows/test-script-consuming-jit-bindings.main.kts
50-
- id: 'step-5'
51-
name: 'Fetch maven-metadata.xml for top-level action'
52-
run: 'curl --fail http://localhost:8080/binding/actions/checkout/maven-metadata.xml | grep ''<version>v4</version>'''
5355
- id: 'step-6'
54-
name: 'Fetch maven-metadata.xml for nested action'
56+
name: 'Fetch maven-metadata.xml for top-level action - with /binding'
57+
run: 'curl --fail http://localhost:8080/binding/actions/checkout/maven-metadata.xml | grep ''<version>v4</version>'''
58+
- id: 'step-7'
59+
name: 'Fetch maven-metadata.xml for nested action - with /binding'
5560
run: 'curl --fail http://localhost:8080/binding/actions/cache__save/maven-metadata.xml | grep ''<version>v4</version>'''
61+
- id: 'step-8'
62+
name: 'Fetch maven-metadata.xml for top-level action'
63+
run: 'curl --fail http://localhost:8080/actions/checkout/maven-metadata.xml | grep ''<version>v4</version>'''
64+
- id: 'step-9'
65+
name: 'Fetch maven-metadata.xml for nested action'
66+
run: 'curl --fail http://localhost:8080/actions/cache__save/maven-metadata.xml | grep ''<version>v4</version>'''
5667
deploy:
5768
name: 'Deploy to DockerHub'
5869
runs-on: 'ubuntu-latest'
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env kotlin
2+
@file:Repository("https://repo1.maven.org/maven2/")
3+
@file:DependsOn("io.github.typesafegithub:github-workflows-kt:1.13.0")
4+
5+
@file:Repository("http://localhost:8080/binding/")
6+
7+
// Regular, top-level action.
8+
@file:DependsOn("actions:checkout:v4")
9+
10+
// Nested action.
11+
@file:DependsOn("gradle:actions__setup-gradle:v3")
12+
13+
// Using specific version.
14+
@file:DependsOn("actions:cache:v3.3.3")
15+
16+
import io.github.typesafegithub.workflows.actions.actions.Cache
17+
import io.github.typesafegithub.workflows.actions.actions.Checkout
18+
import io.github.typesafegithub.workflows.actions.gradle.ActionsSetupGradle
19+
20+
println(Checkout())
21+
println(ActionsSetupGradle())
22+
println(Cache(path = listOf("some-path"), key = "some-key"))

.github/workflows/test-script-consuming-jit-bindings.main.do-not-compile.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
@file:Repository("https://repo1.maven.org/maven2/")
33
@file:DependsOn("io.github.typesafegithub:github-workflows-kt:1.13.0")
44

5-
@file:Repository("http://localhost:8080/binding/")
5+
@file:Repository("http://localhost:8080")
66

77
// Regular, top-level action.
88
@file:DependsOn("actions:checkout:v4")

jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/Main.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ fun main() {
3131

3232
embeddedServer(Netty, port = 8080) {
3333
routing {
34+
// TODO: remove this route once known clients are migrated
35+
// See https://github.com/typesafegithub/github-workflows-kt/issues/1492
3436
route("/binding") {
3537
route("{owner}/{name}/{version}/{file}") {
3638
artifact(bindingsCache)
@@ -41,6 +43,14 @@ fun main() {
4143
}
4244
}
4345

46+
route("{owner}/{name}/{version}/{file}") {
47+
artifact(bindingsCache)
48+
}
49+
50+
route("{owner}/{name}/{file}") {
51+
metadata()
52+
}
53+
4454
get("/status") {
4555
call.respondText("OK")
4656
}

0 commit comments

Comments
 (0)