Skip to content

Fix CI tests #136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

# Everything here was cribbed from or inspired by
# https://github.com/oflynned/android-version-bump/blob/b9f6de7f8bdf25de3f695843265debf7c3919272.
Expand Down
88 changes: 65 additions & 23 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ jobs:

steps:
# Checks-out your repository under $GITHUB_WORKSPACE for the job.
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Gradle test
run: |
./gradlew -p plugin generateTestTasksJson

- id: setup-matrix
run: echo "::set-output name=matrix::$(cat plugin/build/build-resources/androidTestTasks.json)"
run: echo "matrix=$(cat plugin/build/build-resources/androidTestTasks.json)" >> $GITHUB_OUTPUT

- name: debug
run: echo ${{ steps.setup-matrix.outputs.matrix }}
Expand All @@ -44,17 +44,31 @@ jobs:

steps:
# Checks-out your repository under $GITHUB_WORKSPACE for the job.
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup Rust
- name: Setup Rust stable
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-linux-android,x86_64-unknown-linux-gnu,aarch64-linux-android

- name: Setup Rust 1.67
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.67
targets: x86_64-linux-android,x86_64-unknown-linux-gnu,aarch64-linux-android

- name: Setup NDK
env:
SDKMANAGER: /cmdline-tools/latest/bin/sdkmanager
run: |
rustup toolchain install stable
rustup target add x86_64-linux-android
rustup target add x86_64-unknown-linux-gnu
rustup target add aarch64-linux-android
if [[ "${{ runner.os }}" == "Windows" ]]; then
SDKMANAGER=$(echo $SDKMANAGER | tr '/' '\').bat
fi
${ANDROID_HOME}${SDKMANAGER} --install 'ndk;21.4.7075529' 'ndk;23.1.7779620'
shell: bash

- name: Setup Java 11
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 11
Expand Down Expand Up @@ -87,18 +101,32 @@ jobs:

steps:
# Checks-out your repository under $GITHUB_WORKSPACE for the job.
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup Rust stable
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-linux-android,x86_64-unknown-linux-gnu,aarch64-linux-android

- name: Setup Rust
- name: Setup Rust 1.67
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.67
targets: x86_64-linux-android,x86_64-unknown-linux-gnu,aarch64-linux-android

- name: Setup NDK
env:
SDKMANAGER: /cmdline-tools/latest/bin/sdkmanager
run: |
rustup toolchain install stable
rustup target add x86_64-linux-android
rustup target add x86_64-unknown-linux-gnu
rustup target add aarch64-linux-android
if [[ "${{ runner.os }}" == "Windows" ]]; then
SDKMANAGER=$(echo $SDKMANAGER | tr '/' '\').bat
fi
${ANDROID_HOME}${SDKMANAGER} --install 'ndk;21.4.7075529' 'ndk;23.1.7779620'
shell: bash

# Use Java 8
- name: Setup Java 8
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 8
Expand Down Expand Up @@ -135,18 +163,32 @@ jobs:
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup Rust
- name: Setup NDK
env:
SDKMANAGER: /cmdline-tools/latest/bin/sdkmanager
run: |
rustup toolchain install stable
rustup target add x86_64-linux-android
rustup target add x86_64-unknown-linux-gnu
rustup target add aarch64-linux-android
if [[ "${{ runner.os }}" == "Windows" ]]; then
SDKMANAGER=$(echo $SDKMANAGER | tr '/' '\').bat
fi
${ANDROID_HOME}${SDKMANAGER} --install 'ndk;21.4.7075529' 'ndk;23.1.7779620'
shell: bash

- name: Setup Rust stable
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-linux-android,x86_64-unknown-linux-gnu,aarch64-linux-android

- name: Setup Rust 1.67
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.67
targets: x86_64-linux-android,x86_64-unknown-linux-gnu,aarch64-linux-android

# Use Java 8
- name: Setup Java 8
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 8
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up JDK 8
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
java-version: '8'
distribution: 'temurin'
Expand Down
7 changes: 7 additions & 0 deletions plugin/src/test/groovy/com/nishtahir/CargoTargetTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,23 @@ class CargoTargetTest extends AbstractTest {
def "cargoBuild produces #location for target #target"() {
given:
def androidVersion = TestVersions.latestAndroidVersionForCurrentJDK()
def ndkVersion = "21.4.7075529"
def ndkVersionMajor = ndkVersion.split('\\.')[0] as int
// Toolchain 1.68 or later versions are not compatible to old NDK prior to r23
// https://blog.rust-lang.org/2023/01/09/android-ndk-update-r25.html
def channel = ndkVersionMajor >= 23 ? "stable" : "1.67"

SimpleAndroidApp.builder(temporaryFolder.root, cacheDir)
.withAndroidVersion(androidVersion)
.withNdkVersion(ndkVersion)
.withKotlinDisabled()
// TODO: .withCargo(...)
.build()
.writeProject()

SimpleCargoProject.builder(temporaryFolder.root)
.withTargets([target])
.withChannel(channel)
.build()
.writeProject()

Expand Down
14 changes: 11 additions & 3 deletions plugin/src/test/groovy/com/nishtahir/NdkVersionTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ class NdkVersionTest extends AbstractTest {
def androidVersion = TestVersions.latestAndroidVersionForCurrentJDK()
def target = "x86_64"
def location = "android/x86_64/librust.so"
def ndkVersionMajor = ndkVersion.split('\\.')[0] as int
// Toolchain 1.68 or later versions are not compatible to old NDK prior to r23
// https://blog.rust-lang.org/2023/01/09/android-ndk-update-r25.html
def channel = ndkVersionMajor >= 23 ? "stable" : "1.67"

SimpleAndroidApp.builder(temporaryFolder.root, cacheDir)
.withAndroidVersion(androidVersion)
Expand All @@ -24,6 +28,7 @@ class NdkVersionTest extends AbstractTest {

SimpleCargoProject.builder(temporaryFolder.root)
.withTargets([target])
.withChannel(channel)
.build()
.writeProject()

Expand Down Expand Up @@ -55,11 +60,14 @@ class NdkVersionTest extends AbstractTest {

where:
ndkVersion << [
// NDK versions supported by Github Actions, per
// https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md.
// Old LTS NDKs need to be installed manually
"21.4.7075529",
"22.1.7171670",
"23.1.7779620",
// NDK versions supported by Github Actions, per
// https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2004-Readme.md#android
"24.0.8215888",
"25.2.9519653",
"26.1.10909125",
]
}
}
11 changes: 5 additions & 6 deletions plugin/src/test/groovy/com/nishtahir/SimpleAndroidApp.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,7 @@ class SimpleAndroidApp {
}

private String getMaybeNdkVersion() {
def isAndroid34x = androidVersion >= android("3.4.0")
if (isAndroid34x) {
if (ndkVersion != null) {
return """ndkVersion '${ndkVersion}'"""
} else {
return ""
Expand Down Expand Up @@ -275,7 +274,7 @@ class SimpleAndroidApp {
boolean kaptWorkersEnabled = true

VersionNumber androidVersion = Versions.latestAndroidVersion()
VersionNumber ndkVersion = Versions.latestAndroidVersion() >= android("3.4.0") ? VersionNumber.parse("21.4.7075529") : null
VersionNumber ndkVersion = null

VersionNumber kotlinVersion = VersionNumber.parse("1.3.72")
File projectDir
Expand Down Expand Up @@ -303,9 +302,6 @@ class SimpleAndroidApp {

Builder withAndroidVersion(VersionNumber androidVersion) {
this.androidVersion = androidVersion
if (this.androidVersion < android("3.4.0")) {
this.ndkVersion = null
}
return this
}

Expand Down Expand Up @@ -333,6 +329,9 @@ class SimpleAndroidApp {
}

SimpleAndroidApp build() {
if (ndkVersion == null && androidVersion >= android("3.4.0")) {
ndkVersion = VersionNumber.parse("21.4.7075529")
}
return new SimpleAndroidApp(projectDir, cacheDir, androidVersion, ndkVersion, kotlinVersion, kotlinEnabled, kaptWorkersEnabled)
}
}
Expand Down
18 changes: 16 additions & 2 deletions plugin/src/test/groovy/com/nishtahir/SimpleCargoProject.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ package com.nishtahir
class SimpleCargoProject {
File projectDir
List<String> targets
String channel

SimpleCargoProject(File projectDir, List<String> targets) {
SimpleCargoProject(File projectDir, List<String> targets, String channel) {
this.projectDir = projectDir
this.targets = targets
this.channel = channel
}

static class Builder {
File projectDir
List<String> targets
String channel

Builder(File projectDir) {
this.projectDir = projectDir
Expand All @@ -22,11 +25,16 @@ class SimpleCargoProject {
return this
}

def withChannel(channel) {
this.channel = channel
return this
}

def build() {
if (targets.isEmpty()) {
throw new IllegalStateException("No targets provided")
}
return new SimpleCargoProject(this.projectDir, this.targets)
return new SimpleCargoProject(this.projectDir, this.targets, this.channel)
}
}

Expand Down Expand Up @@ -70,5 +78,11 @@ class SimpleCargoProject {
libname = "rust"
}
""".stripIndent()

if (channel != null) {
file('local.properties') << """
rust.rustupChannel=${channel}
""".stripIndent()
}
}
}