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

Conversation

BenHenning
Copy link
Member

@BenHenning BenHenning commented Mar 6, 2021

Fixes part of #2844.

This aims to fix the OpenJDK flakes happening for Gradle tests (per #2844) by forcing the CI environment to use JDK 9 instead of JDK 8 for runtime, since it seems that JDK 8 may have an issue where the JVM can crash when managing many forks (we updated Gradle tests to use forks a while back). However, making the CI environment properly use JDK 9 for Gradle involved a few steps:

  • Adding additional steps to add environment diagnostics to ensure that Gradle is actually using JDK 9 (since it seems to use JDK 8 as configured by settings despite 9 being setup). Unfortunately, setup-java doesn't yet seem to support this directly: Log the version of JDK installed actions/setup-java#92, and it's important to verify that Gradle itself is using the correct version.
  • Note that moving to JDK 9+ requires a compile-time only dependency for some of the annotations needed by Dagger: error: cannot find symbol @Generated( ^ google/dagger#1449 (comment). It's not clear to me why this wasn't an issue in the JDK 8 world.
  • Similarly, JDK 9+ deprecate and eventually remove (JDK 11+) some Java EE libraries that Gradle itself seems to depend on. More compile-only dependencies resolve this issue: https://stackoverflow.com/a/43574427.

Some things to note:

  • The build still sets source/target compatibility versions to Java 8 since we don't actually want to use Java 9+ dependencies, we just want to be able to use JDK 9+ to build and run the tests
  • I haven't verified this locally to still work with JDK 8, but I'm not expecting there to be issues since the changes are mostly just adding redundancy
  • I removed the workaround for the kapt bug since per error: cannot find symbol @Generated( ^ google/dagger#1449 (comment) this should be fixed in the version of Kotlin that we're now using (though the other fixes above regarding the compile-time dependencies were discovered shortly after & are necessary to make everything work as expected)

We will not actually be able to verify if the issue is fixed until we see no new instances of the crash crop up over the next few weeks. Given that the issue seems to only reproduce occasionally when running the whole batch of tests, it's difficult to make the issue commonplace enough to gain certainty it's been fixed. Given the low volume of the flake, though, waiting a few weeks to ensure it's gone should be reasonable.

Remove kapt workaround since per google/dagger#1449 (comment) this should be fixed in the version of Kotlin that we're now using.
Add check for Java versions for Gradle CI workflows.
Add more diagnostics for verifying Java environment, and try further to force Gradle to use the one that's installed.
Add explicit javax annotations dependency per google/dagger#1449 (comment).
Add explicit javax annotations dependency per google/dagger#1449 (comment).
Add explicit javax annotations dependency per google/dagger#1449 (comment).
Add explicit javax annotations dependency per google/dagger#1449 (comment).
Add explicit javax annotations dependency per google/dagger#1449 (comment).
app/build.gradle Outdated Show resolved Hide resolved
data/build.gradle Outdated Show resolved Hide resolved
domain/build.gradle Outdated Show resolved Hide resolved
testing/build.gradle Outdated Show resolved Hide resolved
utility/build.gradle Outdated Show resolved Hide resolved
Add additional dependencies due to Java EE libraries being deprecated/removed JDK 9+ per: https://stackoverflow.com/a/43574427.
@BenHenning BenHenning changed the title Update build.gradle Partially fix #2844: force Gradle tests to run on JDK 9 in CI Mar 6, 2021
@BenHenning BenHenning marked this pull request as ready for review March 6, 2021 22:35
@vinitamurthi vinitamurthi removed their assignment Mar 8, 2021
Copy link
Contributor

@anandwana001 anandwana001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@BenHenning
Copy link
Member Author

Thanks!

@BenHenning BenHenning merged commit 80b2e02 into develop Mar 8, 2021
@BenHenning BenHenning deleted the move-ci-to-java-9 branch March 8, 2021 17:55
techjd pushed a commit to techjd/oppia-android that referenced this pull request Mar 9, 2021
…ppia#2845)

* Update build.gradle

Remove kapt workaround since per google/dagger#1449 (comment) this should be fixed in the version of Kotlin that we're now using.

* Update main.yml

Add check for Java versions for Gradle CI workflows.

* Update main.yml

Add more diagnostics for verifying Java environment, and try further to force Gradle to use the one that's installed.

* Update app/build.gradle

Add explicit javax annotations dependency per google/dagger#1449 (comment).

* Update data/build.gradle

Add explicit javax annotations dependency per google/dagger#1449 (comment).

* Update domain/build.gradle

Add explicit javax annotations dependency per google/dagger#1449 (comment).

* Update testing/build.gradle

Add explicit javax annotations dependency per google/dagger#1449 (comment).

* Update utility/build.gradle

Add explicit javax annotations dependency per google/dagger#1449 (comment).

* Apply suggestions from code review

Add additional dependencies due to Java EE libraries being deprecated/removed JDK 9+ per: https://stackoverflow.com/a/43574427.
techjd added a commit to techjd/oppia-android that referenced this pull request Mar 9, 2021
techjd added a commit to techjd/oppia-android that referenced this pull request Mar 9, 2021
techjd pushed a commit to techjd/oppia-android that referenced this pull request Mar 9, 2021
…ppia#2845)

* Update build.gradle

Remove kapt workaround since per google/dagger#1449 (comment) this should be fixed in the version of Kotlin that we're now using.

* Update main.yml

Add check for Java versions for Gradle CI workflows.

* Update main.yml

Add more diagnostics for verifying Java environment, and try further to force Gradle to use the one that's installed.

* Update app/build.gradle

Add explicit javax annotations dependency per google/dagger#1449 (comment).

* Update data/build.gradle

Add explicit javax annotations dependency per google/dagger#1449 (comment).

* Update domain/build.gradle

Add explicit javax annotations dependency per google/dagger#1449 (comment).

* Update testing/build.gradle

Add explicit javax annotations dependency per google/dagger#1449 (comment).

* Update utility/build.gradle

Add explicit javax annotations dependency per google/dagger#1449 (comment).

* Apply suggestions from code review

Add additional dependencies due to Java EE libraries being deprecated/removed JDK 9+ per: https://stackoverflow.com/a/43574427.
@BenHenning
Copy link
Member Author

Just hit this issue again in #2871. :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants