Skip to content

Commit b79d37b

Browse files
committed
misc: Set up Kotlin/Native build (#1174)
1 parent 7085c8a commit b79d37b

File tree

59 files changed

+347
-174
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+347
-174
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Setup Build
2+
description: >
3+
Checkout repositories and build dependencies
4+
5+
runs:
6+
using: composite
7+
steps:
8+
- name: Checkout tools
9+
uses: actions/checkout@v4
10+
with:
11+
path: 'aws-kotlin-repo-tools'
12+
repository: 'awslabs/aws-kotlin-repo-tools'
13+
sparse-checkout: |
14+
.github
15+
16+
- name: Checkout aws-crt-kotlin
17+
uses: ./aws-kotlin-repo-tools/.github/actions/checkout-head
18+
with:
19+
# checkout aws-crt-kotlin as a sibling which will automatically make it an included build
20+
path: 'aws-crt-kotlin'
21+
repository: 'awslabs/aws-crt-kotlin'
22+
23+
# Cache the Kotlin/Native toolchain based on the input Kotlin version from version catalog
24+
# see https://kotlinlang.org/docs/native-improving-compilation-time.html
25+
- name: Cache Kotlin Native toolchain
26+
uses: actions/cache@v4
27+
with:
28+
path: |
29+
~/.konan
30+
key: ${{ runner.os }}-konan-${{ hashFiles('gradle/libs.versions.toml') }}
31+
restore-keys: |
32+
${{ runner.os }}-konan-
33+
34+
- name: Configure JDK
35+
uses: actions/setup-java@v3
36+
with:
37+
distribution: 'corretto'
38+
java-version: 17
39+
cache: 'gradle'

.github/workflows/ci.yml

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
workflow_dispatch:
8+
9+
# Allow one instance of this workflow per pull request, and cancel older runs when new changes are pushed
10+
concurrency:
11+
group: ci-pr-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
env:
15+
RUN: ${{ github.run_id }}-${{ github.run_number }}
16+
GRADLE_OPTS: "-Dorg.gradle.daemon=false -Dkotlin.incremental=false"
17+
18+
jobs:
19+
jvm:
20+
runs-on: ubuntu-latest
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
# we build with a specific JDK version but source/target compatibility should ensure the jar is usable by
25+
# the target versions we want to support
26+
java-version:
27+
- 8
28+
- 11
29+
- 17
30+
- 21
31+
steps:
32+
- name: Checkout sources
33+
uses: actions/checkout@v4
34+
with:
35+
path: 'smithy-kotlin'
36+
37+
- name: Setup build
38+
uses: ./smithy-kotlin/.github/actions/setup-build
39+
40+
- name: Build and Test on JVM
41+
working-directory: ./smithy-kotlin
42+
shell: bash
43+
run: |
44+
./gradlew -Paws.kotlin.native=false -Ptest.java.version=${{ matrix.java-version }} jvmTest --stacktrace
45+
46+
# macos-14 build and test for targets: jvm, macoArm64, iosSimulatorArm64, watchosSimulatorArm65, tvosSimulatorArm64
47+
# macos-13 build and test for targets: jvm, macoX64, iosX64, tvosX64, watchosX64
48+
macos:
49+
strategy:
50+
fail-fast: false
51+
matrix:
52+
os: [macos-14, macos-13]
53+
runs-on: ${{ matrix.os }}
54+
steps:
55+
- name: Checkout sources
56+
uses: actions/checkout@v4
57+
with:
58+
path: 'smithy-kotlin'
59+
60+
- name: Setup build
61+
uses: ./smithy-kotlin/.github/actions/setup-build
62+
63+
- name: Build and Test on Apple platforms
64+
working-directory: ./smithy-kotlin
65+
shell: bash
66+
run: |
67+
# FIXME K2. Re-enable warnings as errors after this warning is removed: https://youtrack.jetbrains.com/issue/KT-68532
68+
# echo "kotlinWarningsAsErrors=true" >> $GITHUB_WORKSPACE/local.properties
69+
./gradlew apiCheck
70+
./gradlew -Paws.sdk.kotlin.crt.disableCrossCompile=true build
71+
72+
- name: Save Test Reports
73+
if: failure()
74+
uses: actions/upload-artifact@v3
75+
with:
76+
name: test-reports-${{ matrix.os }}
77+
path: '**/build/reports'
78+
79+
# build and test for targets: jvm, linuxX64
80+
# cross compile for: linuxX64, linuxArm64
81+
# TODO - add mingw as cross compile target
82+
linux:
83+
runs-on: ubuntu-latest
84+
steps:
85+
- name: Checkout sources
86+
uses: actions/checkout@v4
87+
with:
88+
path: 'smithy-kotlin'
89+
90+
- name: Setup build
91+
uses: ./smithy-kotlin/.github/actions/setup-build
92+
93+
- name: Configure CRT Docker Images
94+
run: |
95+
./aws-crt-kotlin/docker-images/build-all.sh
96+
97+
- name: Build and Test on Linux with Cross-Compile
98+
working-directory: ./smithy-kotlin
99+
shell: bash
100+
run: |
101+
# FIXME K2. Re-enable warnings as errors after this warning is removed: https://youtrack.jetbrains.com/issue/KT-68532
102+
# echo "kotlinWarningsAsErrors=true" >> $GITHUB_WORKSPACE/local.properties
103+
./gradlew apiCheck
104+
./gradlew build
105+
106+
- name: Save Test Reports
107+
if: failure()
108+
uses: actions/upload-artifact@v3
109+
with:
110+
name: test-reports-${{ matrix.os }}
111+
path: '**/build/reports'
112+
113+
# windows JVM
114+
windows:
115+
runs-on: windows-2022
116+
steps:
117+
- name: Checkout sources
118+
uses: actions/checkout@v4
119+
with:
120+
path: 'smithy-kotlin'
121+
122+
- name: Setup build
123+
uses: ./smithy-kotlin/.github/actions/setup-build
124+
125+
- name: Build and Test on Windows JVM
126+
working-directory: ./smithy-kotlin
127+
run: |
128+
./gradlew apiCheck
129+
./gradlew -P"aws.sdk.kotlin.crt.disableCrossCompile"=true build
130+
131+
- name: Save Test Reports
132+
if: failure()
133+
uses: actions/upload-artifact@v4
134+
with:
135+
name: test-reports-windows
136+
path: '**/build/reports'
137+
138+
protocol-tests:
139+
runs-on: ubuntu-latest
140+
steps:
141+
- name: Checkout sources
142+
uses: actions/checkout@v4
143+
with:
144+
path: 'smithy-kotlin'
145+
146+
- name: Setup build
147+
uses: ./smithy-kotlin/.github/actions/setup-build
148+
149+
- name: Test
150+
working-directory: ./smithy-kotlin
151+
shell: bash
152+
run: |
153+
./gradlew -Paws.kotlin.native=false publishToMavenLocal
154+
./gradlew -Paws.kotlin.native=false testAllProtocols
155+
156+
downstream:
157+
runs-on: ubuntu-latest
158+
steps:
159+
- name: Checkout sources
160+
uses: actions/checkout@v4
161+
with:
162+
path: 'smithy-kotlin'
163+
164+
- name: Setup build
165+
uses: ./smithy-kotlin/.github/actions/setup-build
166+
167+
- name: Checkout aws-sdk-kotlin
168+
uses: ./aws-kotlin-repo-tools/.github/actions/checkout-head
169+
with:
170+
# smithy-kotlin is checked out as a sibling dir which will automatically make it an included build
171+
path: 'aws-sdk-kotlin'
172+
repository: 'awslabs/aws-sdk-kotlin'
173+
174+
- name: Build and Test aws-sdk-kotlin downstream
175+
working-directory: ./smithy-kotlin
176+
run: |
177+
# TODO - JVM only
178+
cd $GITHUB_WORKSPACE/smithy-kotlin
179+
./gradlew --parallel -Paws.kotlin.native=false publishToMavenLocal
180+
SMITHY_KOTLIN_RUNTIME_VERSION=$(grep sdkVersion= gradle.properties | cut -d = -f 2)
181+
SMITHY_KOTLIN_CODEGEN_VERSION=$(grep codegenVersion= gradle.properties | cut -d = -f 2)
182+
cd $GITHUB_WORKSPACE/aws-sdk-kotlin
183+
# replace smithy-kotlin-runtime-version and smithy-kotlin-codegen-version to be
184+
# whatever we are testing such that the protocol test projects don't fail with a
185+
# version that doesn't exist locally or in maven central. Otherwise the generated
186+
# protocol test projects will use whatever the SDK thinks the version of
187+
# smithy-kotlin should be
188+
sed -i "s/smithy-kotlin-runtime-version = .*$/smithy-kotlin-runtime-version = \"$SMITHY_KOTLIN_RUNTIME_VERSION\"/" gradle/libs.versions.toml
189+
sed -i "s/smithy-kotlin-codegen-version = .*$/smithy-kotlin-codegen-version = \"$SMITHY_KOTLIN_CODEGEN_VERSION\"/" gradle/libs.versions.toml
190+
./gradlew --parallel -Paws.kotlin.native=false publishToMavenLocal
191+
./gradlew -Paws.kotlin.native=false test jvmTest
192+
./gradlew -Paws.kotlin.native=false testAllProtocols

.github/workflows/continuous-integration.yml

Lines changed: 0 additions & 135 deletions
This file was deleted.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,5 @@ gradle-app.setting
4747

4848
# MacOS
4949
.DS_Store
50+
51+
*.cinteropLibraries.json

gradle/libs.versions.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
kotlin-version = "2.0.21"
33
dokka-version = "1.9.10"
44

5-
aws-kotlin-repo-tools-version = "0.4.16"
5+
aws-kotlin-repo-tools-version = "0.4.15-kn"
66

77
# libs
88
coroutines-version = "1.9.0"
@@ -91,6 +91,7 @@ docker-transport-zerodep = { module = "com.github.docker-java:docker-java-transp
9191
ktor-http-cio = { module = "io.ktor:ktor-http-cio", version.ref = "ktor-version" }
9292
ktor-utils = { module = "io.ktor:ktor-utils", version.ref = "ktor-version" }
9393
ktor-io = { module = "io.ktor:ktor-io", version.ref = "ktor-version" }
94+
ktor-server-core = { module = "io.ktor:ktor-server-core", version.ref = "ktor-version" }
9495
ktor-server-netty = { module = "io.ktor:ktor-server-netty", version.ref = "ktor-version" }
9596
ktor-server-jetty-jakarta = { module = "io.ktor:ktor-server-jetty-jakarta", version.ref = "ktor-version" }
9697
ktor-server-cio = { module = "io.ktor:ktor-server-cio", version.ref = "ktor-version" }

0 commit comments

Comments
 (0)