Skip to content

Commit 2d192e8

Browse files
authored
add js platforms (#102)
1 parent 5598b26 commit 2d192e8

File tree

28 files changed

+2431
-373
lines changed

28 files changed

+2431
-373
lines changed

.github/actions/setup/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ runs:
1313
build-scan-publish: true
1414
build-scan-terms-of-use-url: "https://gradle.com/terms-of-service"
1515
build-scan-terms-of-use-agree: "yes"
16+
- uses: extractions/setup-just@v3

.github/workflows/ci.yml

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,40 @@ on:
99
jobs:
1010
test:
1111
strategy:
12+
fail-fast: false
1213
matrix:
1314
include:
14-
- runner: ubuntu-latest
15-
target: jvm
16-
- runner: macos-latest
17-
target: macosArm64
18-
- runner: ubuntu-latest
19-
target: linuxX64
20-
- runner: windows-latest
21-
target: mingwX64
22-
runs-on: "${{ matrix.runner }}"
15+
- target: jvm
16+
os: ubuntu
17+
- target: jsBrowser
18+
os: ubuntu
19+
- target: jsNode
20+
os: ubuntu
21+
# TODO: wasmJs times out on bulk tests
22+
# - target: wasmJsBrowser
23+
# os: ubuntu
24+
- target: wasmJsNode
25+
os: ubuntu
26+
- target: linuxX64
27+
os: ubuntu
28+
- target: macosArm64
29+
os: macos
30+
- target: mingwX64
31+
os: windows
32+
- target: iosSimulatorArm64
33+
os: macos
34+
- target: tvosSimulatorArm64
35+
os: macos
36+
- target: watchosSimulatorArm64
37+
os: macos
38+
runs-on: "${{ matrix.os }}-latest"
2339
name: "test (${{ matrix.target }})"
2440
steps:
2541
- uses: "actions/checkout@v4"
2642
with:
2743
fetch-depth: 0
2844
- uses: "./.github/actions/setup"
45+
- run: "just test-server-background"
2946
- run: "./gradlew ${{ matrix.target }}Test"
3047

3148
build-docs:

README.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@ Maintainer: [@sargunv](https://github.com/sargunv)
1111
This is a [Kotlin](https://kotlinlang.org/) client for
1212
[PokeApi](https://github.com/PokeAPI/pokeapi).
1313

14-
| Platform | Status |
15-
| -------- | ------------------ |
16-
| JVM | :white_check_mark: |
17-
| Native | :x: |
18-
| JS | :x: |
19-
| WASM | :x: |
20-
2114
## Installation
2215

2316
Since v2.5.0, the library is published to Maven Central.

build.gradle.kts

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
@file:OptIn(ExperimentalWasmDsl::class)
2+
13
import com.vanniktech.maven.publish.SonatypeHost
24
import fr.brouillard.oss.jgitver.Strategies
5+
import kotlin.time.Duration.Companion.seconds
6+
import kotlin.time.toJavaDuration
7+
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
8+
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsSubTargetDsl
39

410
plugins {
511
alias(libs.plugins.kotlin.multiplatform)
@@ -28,6 +34,30 @@ kotlin {
2834

2935
jvm()
3036

37+
fun KotlinJsSubTargetDsl.configureWithKarma() {
38+
testTask {
39+
useKarma {
40+
useChromeHeadless()
41+
timeout = 60.seconds.toJavaDuration()
42+
}
43+
}
44+
}
45+
46+
fun KotlinJsSubTargetDsl.configureWithMocha() {
47+
testTask { useMocha { timeout = "60s" } }
48+
}
49+
50+
js(IR) {
51+
browser { configureWithMocha() }
52+
nodejs { configureWithMocha() }
53+
}
54+
55+
wasmJs {
56+
browser { configureWithMocha() }
57+
nodejs { configureWithMocha() }
58+
d8 {}
59+
}
60+
3161
// native tier 1
3262
macosX64()
3363
macosArm64()
@@ -50,12 +80,6 @@ kotlin {
5080
mingwX64()
5181
watchosDeviceArm64()
5282

53-
// native tier 3 - but no suitable Ktor engine available
54-
// androidNativeArm32()
55-
// androidNativeArm64()
56-
// androidNativeX86()
57-
// androidNativeX64()
58-
5983
applyDefaultHierarchyTemplate()
6084

6185
sourceSets {
@@ -71,6 +95,8 @@ kotlin {
7195
appleMain.dependencies { implementation(libs.ktor.client.darwin) }
7296
linuxMain.dependencies { implementation(libs.ktor.client.curl) }
7397
mingwMain.dependencies { implementation(libs.ktor.client.winhttp) }
98+
jsMain.dependencies { implementation(libs.ktor.client.js) }
99+
wasmJsMain.dependencies { implementation(libs.ktor.client.js) }
74100

75101
commonTest.dependencies {
76102
implementation(kotlin("test"))

gradle/libs.versions.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ ktorfit = { module = "de.jensklingenberg.ktorfit:ktorfit-lib", version.ref = "gr
2424
ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" }
2525
ktor-client-darwin = { module = "io.ktor:ktor-client-darwin", version.ref = "ktor" }
2626
ktor-client-winhttp = { module = "io.ktor:ktor-client-winhttp", version.ref = "ktor" }
27-
ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" }
2827
ktor-client-curl = { module = "io.ktor:ktor-client-curl", version.ref = "ktor" }
2928
ktor-client-js = { module = "io.ktor:ktor-client-js", version.ref = "ktor" }
3029
ktor-client-mock = { module = "io.ktor:ktor-client-mock", version.ref = "ktor" }

justfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
set windows-shell := ["C:\\Program Files\\Git\\bin\\sh.exe", "-c"]
2+
3+
_default:
4+
just --list
5+
6+
test-server:
7+
npx -y http-server src/commonTest/resources/data -e json -p 8080 --cors
8+
9+
test-server-background:
10+
npx -y http-server src/commonTest/resources/data -e json -p 8080 --cors &

0 commit comments

Comments
 (0)