Skip to content

Commit

Permalink
misc: Set up Kotlin/Native build (#1174)
Browse files Browse the repository at this point in the history
  • Loading branch information
lauzadis authored Nov 14, 2024
1 parent 03cdfb4 commit 9d9faf3
Show file tree
Hide file tree
Showing 59 changed files with 347 additions and 174 deletions.
39 changes: 39 additions & 0 deletions .github/actions/setup-build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Setup Build
description: >
Checkout repositories and build dependencies
runs:
using: composite
steps:
- name: Checkout tools
uses: actions/checkout@v4
with:
path: 'aws-kotlin-repo-tools'
repository: 'awslabs/aws-kotlin-repo-tools'
sparse-checkout: |
.github
- name: Checkout aws-crt-kotlin
uses: ./aws-kotlin-repo-tools/.github/actions/checkout-head
with:
# checkout aws-crt-kotlin as a sibling which will automatically make it an included build
path: 'aws-crt-kotlin'
repository: 'awslabs/aws-crt-kotlin'

# Cache the Kotlin/Native toolchain based on the input Kotlin version from version catalog
# see https://kotlinlang.org/docs/native-improving-compilation-time.html
- name: Cache Kotlin Native toolchain
uses: actions/cache@v4
with:
path: |
~/.konan
key: ${{ runner.os }}-konan-${{ hashFiles('gradle/libs.versions.toml') }}
restore-keys: |
${{ runner.os }}-konan-
- name: Configure JDK
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: 17
cache: 'gradle'
192 changes: 192 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
workflow_dispatch:

# Allow one instance of this workflow per pull request, and cancel older runs when new changes are pushed
concurrency:
group: ci-pr-${{ github.ref }}
cancel-in-progress: true

env:
RUN: ${{ github.run_id }}-${{ github.run_number }}
GRADLE_OPTS: "-Dorg.gradle.daemon=false -Dkotlin.incremental=false"

jobs:
jvm:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# we build with a specific JDK version but source/target compatibility should ensure the jar is usable by
# the target versions we want to support
java-version:
- 8
- 11
- 17
- 21
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
path: 'smithy-kotlin'

- name: Setup build
uses: ./smithy-kotlin/.github/actions/setup-build

- name: Build and Test on JVM
working-directory: ./smithy-kotlin
shell: bash
run: |
./gradlew -Paws.kotlin.native=false -Ptest.java.version=${{ matrix.java-version }} jvmTest --stacktrace
# macos-14 build and test for targets: jvm, macoArm64, iosSimulatorArm64, watchosSimulatorArm65, tvosSimulatorArm64
# macos-13 build and test for targets: jvm, macoX64, iosX64, tvosX64, watchosX64
macos:
strategy:
fail-fast: false
matrix:
os: [macos-14, macos-13]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
path: 'smithy-kotlin'

- name: Setup build
uses: ./smithy-kotlin/.github/actions/setup-build

- name: Build and Test on Apple platforms
working-directory: ./smithy-kotlin
shell: bash
run: |
# FIXME K2. Re-enable warnings as errors after this warning is removed: https://youtrack.jetbrains.com/issue/KT-68532
# echo "kotlinWarningsAsErrors=true" >> $GITHUB_WORKSPACE/local.properties
./gradlew apiCheck
./gradlew -Paws.sdk.kotlin.crt.disableCrossCompile=true build
- name: Save Test Reports
if: failure()
uses: actions/upload-artifact@v3
with:
name: test-reports-${{ matrix.os }}
path: '**/build/reports'

# build and test for targets: jvm, linuxX64
# cross compile for: linuxX64, linuxArm64
# TODO - add mingw as cross compile target
linux:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
path: 'smithy-kotlin'

- name: Setup build
uses: ./smithy-kotlin/.github/actions/setup-build

- name: Configure CRT Docker Images
run: |
./aws-crt-kotlin/docker-images/build-all.sh
- name: Build and Test on Linux with Cross-Compile
working-directory: ./smithy-kotlin
shell: bash
run: |
# FIXME K2. Re-enable warnings as errors after this warning is removed: https://youtrack.jetbrains.com/issue/KT-68532
# echo "kotlinWarningsAsErrors=true" >> $GITHUB_WORKSPACE/local.properties
./gradlew apiCheck
./gradlew build
- name: Save Test Reports
if: failure()
uses: actions/upload-artifact@v3
with:
name: test-reports-${{ matrix.os }}
path: '**/build/reports'

# windows JVM
windows:
runs-on: windows-2022
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
path: 'smithy-kotlin'

- name: Setup build
uses: ./smithy-kotlin/.github/actions/setup-build

- name: Build and Test on Windows JVM
working-directory: ./smithy-kotlin
run: |
./gradlew apiCheck
./gradlew -P"aws.sdk.kotlin.crt.disableCrossCompile"=true build
- name: Save Test Reports
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-reports-windows
path: '**/build/reports'

protocol-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
path: 'smithy-kotlin'

- name: Setup build
uses: ./smithy-kotlin/.github/actions/setup-build

- name: Test
working-directory: ./smithy-kotlin
shell: bash
run: |
./gradlew -Paws.kotlin.native=false publishToMavenLocal
./gradlew -Paws.kotlin.native=false testAllProtocols
downstream:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
path: 'smithy-kotlin'

- name: Setup build
uses: ./smithy-kotlin/.github/actions/setup-build

- name: Checkout aws-sdk-kotlin
uses: ./aws-kotlin-repo-tools/.github/actions/checkout-head
with:
# smithy-kotlin is checked out as a sibling dir which will automatically make it an included build
path: 'aws-sdk-kotlin'
repository: 'awslabs/aws-sdk-kotlin'

- name: Build and Test aws-sdk-kotlin downstream
working-directory: ./smithy-kotlin
run: |
# TODO - JVM only
cd $GITHUB_WORKSPACE/smithy-kotlin
./gradlew --parallel -Paws.kotlin.native=false publishToMavenLocal
SMITHY_KOTLIN_RUNTIME_VERSION=$(grep sdkVersion= gradle.properties | cut -d = -f 2)
SMITHY_KOTLIN_CODEGEN_VERSION=$(grep codegenVersion= gradle.properties | cut -d = -f 2)
cd $GITHUB_WORKSPACE/aws-sdk-kotlin
# replace smithy-kotlin-runtime-version and smithy-kotlin-codegen-version to be
# whatever we are testing such that the protocol test projects don't fail with a
# version that doesn't exist locally or in maven central. Otherwise the generated
# protocol test projects will use whatever the SDK thinks the version of
# smithy-kotlin should be
sed -i "s/smithy-kotlin-runtime-version = .*$/smithy-kotlin-runtime-version = \"$SMITHY_KOTLIN_RUNTIME_VERSION\"/" gradle/libs.versions.toml
sed -i "s/smithy-kotlin-codegen-version = .*$/smithy-kotlin-codegen-version = \"$SMITHY_KOTLIN_CODEGEN_VERSION\"/" gradle/libs.versions.toml
./gradlew --parallel -Paws.kotlin.native=false publishToMavenLocal
./gradlew -Paws.kotlin.native=false test jvmTest
./gradlew -Paws.kotlin.native=false testAllProtocols
135 changes: 0 additions & 135 deletions .github/workflows/continuous-integration.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,5 @@ gradle-app.setting

# MacOS
.DS_Store

*.cinteropLibraries.json
3 changes: 2 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
kotlin-version = "2.0.21"
dokka-version = "1.9.10"

aws-kotlin-repo-tools-version = "0.4.13"
aws-kotlin-repo-tools-version = "0.4.15-kn"

# libs
coroutines-version = "1.9.0"
Expand Down Expand Up @@ -91,6 +91,7 @@ docker-transport-zerodep = { module = "com.github.docker-java:docker-java-transp
ktor-http-cio = { module = "io.ktor:ktor-http-cio", version.ref = "ktor-version" }
ktor-utils = { module = "io.ktor:ktor-utils", version.ref = "ktor-version" }
ktor-io = { module = "io.ktor:ktor-io", version.ref = "ktor-version" }
ktor-server-core = { module = "io.ktor:ktor-server-core", version.ref = "ktor-version" }
ktor-server-netty = { module = "io.ktor:ktor-server-netty", version.ref = "ktor-version" }
ktor-server-jetty-jakarta = { module = "io.ktor:ktor-server-jetty-jakarta", version.ref = "ktor-version" }
ktor-server-cio = { module = "io.ktor:ktor-server-cio", version.ref = "ktor-version" }
Expand Down
Loading

0 comments on commit 9d9faf3

Please sign in to comment.