Skip to content
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

Partially fix #2844: force Gradle tests to run on JDK 9 in CI #2845

Merged
merged 9 commits into from
Mar 8, 2021
Merged
Show file tree
Hide file tree
Changes from 8 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
32 changes: 26 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,28 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 1.9

- name: Check Java version & path
run: |
which java
java -version
echo "Java home: $JAVA_HOME"
$JAVA_HOME/bin/java -version

- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: ./gradlew --full-stacktrace androidDependencies
run: ./gradlew --full-stacktrace androidDependencies -Dorg.gradle.java.home=$JAVA_HOME

- name: Check Gradle environment
run: ./gradlew -Dorg.gradle.java.home=$JAVA_HOME -v

- name: Build App
# We require 'sudo' to avoid an error of the existing android sdk. See https://github.com/actions/starter-workflows/issues/58
run: sudo ./gradlew --full-stacktrace assembleDebug
run: sudo ./gradlew --full-stacktrace assembleDebug -Dorg.gradle.java.home=$JAVA_HOME

- name: Utility tests
# We require 'sudo' to avoid an error of the existing android sdk. See https://github.com/actions/starter-workflows/issues/58
run: sudo ./gradlew --full-stacktrace :utility:testDebugUnitTest
run: sudo ./gradlew --full-stacktrace :utility:testDebugUnitTest -Dorg.gradle.java.home=$JAVA_HOME
- name: Upload Utility Test Reports
uses: actions/upload-artifact@v2
if: ${{ always() }} # IMPORTANT: Upload reports regardless of status
Expand All @@ -55,7 +65,7 @@ jobs:

- name: Domain tests
# We require 'sudo' to avoid an error of the existing android sdk. See https://github.com/actions/starter-workflows/issues/58
run: sudo ./gradlew --full-stacktrace :domain:testDebugUnitTest
run: sudo ./gradlew --full-stacktrace :domain:testDebugUnitTest -Dorg.gradle.java.home=$JAVA_HOME
- name: Upload Domain Test Reports
uses: actions/upload-artifact@v2
if: ${{ always() }} # IMPORTANT: Upload reports regardless of status
Expand All @@ -65,7 +75,7 @@ jobs:

- name: Testing tests
# We require 'sudo' to avoid an error of the existing android sdk. See https://github.com/actions/starter-workflows/issues/58
run: sudo ./gradlew --full-stacktrace :testing:testDebugUnitTest
run: sudo ./gradlew --full-stacktrace :testing:testDebugUnitTest -Dorg.gradle.java.home=$JAVA_HOME
- name: Upload Testing Test Reports
uses: actions/upload-artifact@v2
if: ${{ always() }} # IMPORTANT: Upload reports regardless of status
Expand All @@ -92,10 +102,20 @@ jobs:
with:
java-version: 1.9

- name: Check Java version & path
run: |
which java
java -version
echo "Java home: $JAVA_HOME"
$JAVA_HOME/bin/java -version

- name: Check Gradle environment
run: ./gradlew -Dorg.gradle.java.home=$JAVA_HOME -v

- name: Robolectric tests - App Module
# We require 'sudo' to avoid an error of the existing android sdk. See https://github.com/actions/starter-workflows/issues/58
run: |
sudo ./gradlew --full-stacktrace :app:testDebugUnitTest
sudo ./gradlew --full-stacktrace :app:testDebugUnitTest -Dorg.gradle.java.home=$JAVA_HOME
- name: Upload App Test Reports
uses: actions/upload-artifact@v2
if: ${{ always() }} # IMPORTANT: Upload reports regardless of status
Expand Down
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ dependencies {
'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.2.1',
'org.mockito:mockito-core:2.7.22',
)
compileOnly 'javax.annotation:javax.annotation-api:1.3.2'
BenHenning marked this conversation as resolved.
Show resolved Hide resolved
testImplementation(
'androidx.test:core:1.2.0',
'androidx.test.espresso:espresso-contrib:3.1.0',
Expand Down
19 changes: 0 additions & 19 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,3 @@ allprojects {
task clean(type: Delete) {
delete rootProject.buildDir
}

subprojects{
afterEvaluate {
// kapt doesn't propagate source version properly so even if we set JDK to be 9, if we
// have a local JDK version of 9+, we see a dagger bug in generating annotations
// that only occurs in JDK 9+, this is the workaround:
// (Lots of useful information here: https://github.com/google/dagger/issues/1449)
if (project.hasProperty('kapt')) {
// Reference for 'kapt' DSL: https://kotlinlang.org/docs/reference/kapt.html#java-compiler-options
kapt {
// we expect this closure to run over a org.jetbrains.kotlin.gradle.plugin.KaptExtension
javacOptions {
option("-source", "8")
option("-target", "8")
}
}
}
}
}
1 change: 1 addition & 0 deletions data/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ dependencies {
'com.squareup.moshi:moshi-kotlin:1.11.0',
'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.2.2',
)
compileOnly 'javax.annotation:javax.annotation-api:1.3.2'
BenHenning marked this conversation as resolved.
Show resolved Hide resolved
testImplementation(
'android.arch.core:core-testing:1.1.1',
'androidx.test.ext:junit:1.1.1',
Expand Down
1 change: 1 addition & 0 deletions domain/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ dependencies {
'com.google.firebase:firebase-crashlytics:17.0.0',
"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
)
compileOnly 'javax.annotation:javax.annotation-api:1.3.2'
BenHenning marked this conversation as resolved.
Show resolved Hide resolved
testImplementation(
'android.arch.core:core-testing:1.1.1',
'androidx.test.espresso:espresso-core:3.2.0',
Expand Down
1 change: 1 addition & 0 deletions testing/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ dependencies {
project(":domain"),
project(":utility"),
)
compileOnly 'javax.annotation:javax.annotation-api:1.3.2'
BenHenning marked this conversation as resolved.
Show resolved Hide resolved
testImplementation(
'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0-alpha03',
'androidx.test.ext:junit:1.1.1',
Expand Down
1 change: 1 addition & 0 deletions utility/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ dependencies {
'com.google.firebase:firebase-crashlytics:17.0.0',
"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version",
)
compileOnly 'javax.annotation:javax.annotation-api:1.3.2'
BenHenning marked this conversation as resolved.
Show resolved Hide resolved
testImplementation(
'androidx.test.ext:junit:1.1.1',
'com.google.dagger:dagger:2.24',
Expand Down