Skip to content

Commit 15e6cc5

Browse files
authored
chore: refactor ci workflows (#974)
1 parent 031b50c commit 15e6cc5

File tree

5 files changed

+120
-76
lines changed

5 files changed

+120
-76
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 82 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -4,87 +4,104 @@ on:
44
push:
55
branches: [ main ]
66
pull_request:
7-
branches:
8-
- main
9-
- 'feat-*'
107
workflow_dispatch:
118

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+
1214
env:
13-
BUILDER_VERSION: v0.8.22
14-
BUILDER_SOURCE: releases
15-
# host owned by CRT team to host aws-crt-builder releases. Contact their on-call with any issues
16-
BUILDER_HOST: https://d19elf31gohf1l.cloudfront.net
17-
PACKAGE_NAME: smithy-kotlin
18-
LINUX_BASE_IMAGE: ubuntu-16-x64
1915
RUN: ${{ github.run_id }}-${{ github.run_number }}
16+
GRADLE_OPTS: "-Dorg.gradle.daemon=false -Dkotlin.incremental=false"
2017

2118
jobs:
22-
linux-compat:
19+
jvm:
2320
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
2431
steps:
25-
- name: Checkout sources
26-
uses: actions/checkout@v2
27-
- uses: actions/cache@v2
28-
with:
29-
path: |
30-
~/.gradle/caches
31-
~/.gradle/wrapper
32-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
33-
restore-keys: |
34-
${{ runner.os }}-gradle-
35-
- name: Build and Test ${{ env.PACKAGE_NAME }}
36-
run: |
37-
python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')"
38-
chmod a+x builder.pyz
39-
echo "kotlinWarningsAsErrors=true" >> $GITHUB_WORKSPACE/local.properties
40-
./builder.pyz build -p ${{ env.PACKAGE_NAME }}
41-
42-
macos-compat:
43-
runs-on: macos-latest
44-
steps:
45-
- name: Checkout sources
46-
uses: actions/checkout@v2
47-
- uses: actions/cache@v2
48-
with:
49-
path: |
50-
~/.gradle/caches
51-
~/.gradle/wrapper
52-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
53-
restore-keys: |
54-
${{ runner.os }}-gradle-
55-
- name: Build and Test ${{ env.PACKAGE_NAME }}
56-
run: |
57-
python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')"
58-
chmod a+x builder.pyz
59-
echo "kotlinWarningsAsErrors=true" >> $GITHUB_WORKSPACE/local.properties
60-
./builder.pyz build -p ${{ env.PACKAGE_NAME }}
32+
- name: Checkout sources
33+
uses: actions/checkout@v4
34+
- name: Configure JDK
35+
uses: actions/setup-java@v3
36+
with:
37+
distribution: 'corretto'
38+
java-version: 17
39+
cache: 'gradle'
40+
- name: Test
41+
shell: bash
42+
run: |
43+
./gradlew -Ptest.java.version=${{ matrix.java-version }} jvmTest --stacktrace
6144
62-
windows-compat:
63-
runs-on: windows-latest
45+
all-platforms:
46+
runs-on: ${{ matrix.os }}
47+
strategy:
48+
fail-fast: false
49+
matrix:
50+
os: [ ubuntu-latest, macos-latest, windows-latest ]
6451
steps:
6552
- name: Checkout sources
66-
uses: actions/checkout@v2
67-
- name: Build and Test ${{ env.PACKAGE_NAME }}
53+
uses: actions/checkout@v4
54+
- name: Configure JDK
55+
uses: actions/setup-java@v3
56+
with:
57+
distribution: 'corretto'
58+
java-version: 17
59+
cache: 'gradle'
60+
- name: Test
61+
shell: bash
6862
run: |
69-
python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')"
70-
python3 builder.pyz build -p ${{ env.PACKAGE_NAME }}
63+
echo "kotlinWarningsAsErrors=true" >> $GITHUB_WORKSPACE/local.properties
64+
./gradlew apiCheck
65+
./gradlew test allTests
66+
- name: Save Test Reports
67+
if: failure()
68+
uses: actions/upload-artifact@v3
69+
with:
70+
name: test-reports
71+
path: '**/build/reports'
7172

7273
downstream:
7374
runs-on: ubuntu-latest
7475
steps:
7576
- name: Checkout sources
76-
uses: actions/checkout@v2
77-
- uses: actions/cache@v2
77+
uses: actions/checkout@v4
78+
with:
79+
path: 'smithy-kotlin'
80+
- name: Checkout tools
81+
uses: actions/checkout@v4
82+
with:
83+
path: 'aws-kotlin-repo-tools'
84+
repository: 'awslabs/aws-kotlin-repo-tools'
85+
ref: '0.2.3'
86+
sparse-checkout: |
87+
.github
88+
- name: Checkout aws-sdk-kotlin
89+
uses: ./aws-kotlin-repo-tools/.github/actions/checkout-head
90+
with:
91+
# smithy-kotlin is checked out as a sibling dir which will automatically make it an included build
92+
path: 'aws-sdk-kotlin'
93+
repository: 'awslabs/aws-sdk-kotlin'
94+
- name: Configure JDK
95+
uses: actions/setup-java@v3
7896
with:
79-
path: |
80-
~/.gradle/caches
81-
~/.gradle/wrapper
82-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
83-
restore-keys: |
84-
${{ runner.os }}-gradle-
85-
- name: Build and Test ${{ env.PACKAGE_NAME }} Downstream Consumers
97+
distribution: 'corretto'
98+
java-version: 17
99+
cache: 'gradle'
100+
- name: Build and Test aws-sdk-kotlin downstream
86101
run: |
87-
python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder')"
88-
chmod a+x builder
89-
echo "kotlinWarningsAsErrors=true" >> $GITHUB_WORKSPACE/local.properties
90-
./builder build -p ${{ env.PACKAGE_NAME }} --spec downstream
102+
# TODO - JVM only
103+
cd $GITHUB_WORKSPACE/smithy-kotlin
104+
./gradlew --parallel publishToMavenLocal
105+
cd $GITHUB_WORKSPACE/aws-sdk-kotlin
106+
./gradlew --parallel publishToMavenLocal
107+
./gradlew testAllProtocols

build.gradle.kts

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ plugins {
3030
// configures (KMP) subprojects with our own KMP conventions and some default dependencies
3131
apply(plugin = "aws.sdk.kotlin.kmp")
3232

33-
allprojects {
34-
repositories {
35-
mavenLocal()
36-
mavenCentral()
37-
google()
38-
}
33+
val testJavaVersion = typedProp<String>("test.java.version")?.let {
34+
JavaLanguageVersion.of(it)
35+
}?.also {
36+
println("configuring tests to run with jdk $it")
37+
}
3938

39+
allprojects {
4040
tasks.withType<org.jetbrains.dokka.gradle.AbstractDokkaTask>().configureEach {
4141
val sdkVersion: String by project
4242
moduleVersion.set(sdkVersion)
@@ -61,14 +61,25 @@ allprojects {
6161
)
6262
pluginsMapConfiguration.set(pluginConfigMap)
6363
}
64-
}
6564

66-
if (project.typedProp<Boolean>("kotlinWarningsAsErrors") == true) {
67-
subprojects {
65+
if (rootProject.typedProp<Boolean>("kotlinWarningsAsErrors") == true) {
6866
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
6967
kotlinOptions.allWarningsAsErrors = true
7068
}
7169
}
70+
71+
if (testJavaVersion != null) {
72+
tasks.withType<Test> {
73+
// JDK8 tests fail with out of memory sometimes, not sure why...
74+
maxHeapSize = "2g"
75+
val toolchains = project.extensions.getByType<JavaToolchainService>()
76+
javaLauncher.set(
77+
toolchains.launcherFor {
78+
languageVersion.set(testJavaVersion)
79+
},
80+
)
81+
}
82+
}
7283
}
7384

7485
// configure the root multimodule docs

runtime/auth/aws-signing-tests/jvm/src/aws/smithy/kotlin/runtime/auth/awssigning/tests/SigningSuiteTestBaseJVM.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ import org.junit.jupiter.params.provider.MethodSource
3737
import java.nio.file.FileSystems
3838
import java.nio.file.Files
3939
import java.nio.file.Path
40+
import java.util.stream.Collectors
4041
import kotlin.io.path.exists
4142
import kotlin.io.path.isDirectory
4243
import kotlin.io.path.name
4344
import kotlin.io.path.readText
44-
import kotlin.streams.toList
4545
import kotlin.test.*
4646
import kotlin.time.Duration.Companion.seconds
4747

@@ -94,7 +94,9 @@ public actual abstract class SigningSuiteTestBase : HasSigner {
9494
private val testDirPaths: List<Path> by lazy {
9595
Files
9696
.walk(testSuitePath)
97-
.toList()
97+
// Due to https://youtrack.jetbrains.com/issue/KT-47039 setting jvmTarget compatibility isn't enough
98+
// ignore the toList() extension in-favor of something that should work JDK8+ even if we compile with JDK17+
99+
.collect(Collectors.toList())
98100
.filter { !it.isDirectory() && it.name == "request.txt" }
99101
.filterNot { it.parent.name in disabledTests }
100102
.map { it.parent }

runtime/build.gradle.kts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,10 @@ subprojects {
6363
dependencies {
6464
dokkaPlugin(project(":dokka-smithy"))
6565
}
66+
67+
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
68+
kotlinOptions {
69+
jvmTarget = "1.8"
70+
}
71+
}
6672
}

settings.gradle.kts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ pluginManagement {
2020
}
2121
}
2222

23+
dependencyResolutionManagement {
24+
repositories {
25+
mavenLocal()
26+
mavenCentral()
27+
google()
28+
}
29+
}
30+
2331
sourceControl {
2432
gitRepository(java.net.URI("https://github.com/awslabs/aws-kotlin-repo-tools.git")) {
2533
producesModule("aws.sdk.kotlin:build-plugins")

0 commit comments

Comments
 (0)