-
Notifications
You must be signed in to change notification settings - Fork 123
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
ci: using JDK 11+ to compile and JDK 8 to run junit (8) #1870
Conversation
Warning: This pull request is touching the following templated files:
|
<profile> | ||
<!-- JDK 9+ has the "release" option to ensure the generated bytecode is | ||
compatible with Java 8. --> | ||
<id>compiler-release-8</id> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This profile may be appropriate to be defined in the google-cloud-shared-config (the parent pom of this file).
The google-cloud-shared-config defines compiler option:
<source>1.8</source>
<target>1.8</target>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added todo: googleapis/java-shared-config#477
We may need to address windows build but that's feasible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rajatbhatta : Please check this PR for nightly tests.
We seem to be switching to java11 from java8 at a couple of places, so we need to ensure existing builds around java8 are working allright.
@@ -25,7 +25,7 @@ jobs: | |||
strategy: | |||
fail-fast: false | |||
matrix: | |||
java: [8, 11, 17] | |||
java: [11, 17] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this impact any of the existing test runs against java8? units-java8
job should cover the unit tests, but on fusion, I can see java8-samples
as another job.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Kokoro builds, I have modified java8 container to have JAVA11_HOME environment variable in googleapis/testing-infra-docker#211.
suztomo@suztomo:~$ docker run --rm -it --entrypoint bash gcr.io/cloud-devrel-kokoro-resources/java8
Unable to find image 'gcr.io/cloud-devrel-kokoro-resources/java8:latest' locally
latest: Pulling from cloud-devrel-kokoro-resources/java8
...
Digest: sha256:86a9e70f109b5efd16204dea51cf30aa2295bbbd4e980d2fd2172d2f7b2382e4
Status: Downloaded newer image for gcr.io/cloud-devrel-kokoro-resources/java8:latest
root@c4a6f4994f6c:/workspace#
root@c4a6f4994f6c:/workspace# printenv
PYENV_SHELL=bash
HOSTNAME=c4a6f4994f6c
JAVA_HOME=/usr/local/openjdk-8
JAVA8_HOME=/usr/local/openjdk-8
...
JAVA11_HOME=/usr/lib/jvm/java-11-openjdk-amd64
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@suztomo We specify the docker image version for java8-samples here: https://github.com/googleapis/java-spanner/blob/main/.kokoro/nightly/java8-samples.cfg#L6
I think this will be alright, but double checking if we set the correct ENV variables in this container as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thiagotnunes Thank you for the info. Yes, that line value: "gcr.io/cloud-devrel-kokoro-resources/java8"
matches the container image URL I have modified. It has JAVA8_HOME
and JAVA11_HOME
now. (I added the docker command invocation to my comment above)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the info LGTM
RETURN_CODE=0 | ||
set +e | ||
|
||
case ${JOB_TYPE} in | ||
test) | ||
mvn test -B \ | ||
mvn test -B -V \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do we need the version of mvn for - does it tie to native image compilation in some way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This clarifies which versions of JDK it's running. We're running JDK 11 to compile and JDK 8 to run tests. (It's nice-to-have)
if [ ! -z "${JAVA11_HOME}" ]; then | ||
setJava "${JAVA11_HOME}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JAVA11_HOME is now available in the container image for Kokoro:
if [ ! -z "${JAVA8_HOME}" ]; then | ||
setJava "${JAVA8_HOME}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JAVA8_HOME is now available in the container image for Kokoro:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
My ad-hoc invocation of the Java 8 job http://sponge2/132d68b4-9667-43b0-9d7c-49a2b3f12571 shows good. The "Build Log" tab shows that first it compiled the project with JDK 11:
and then it ran tests with JDK 8:
|
Upgrading JDK setting to compile the code in Java 11 and run the tests in Java 8.
Background: this helps to let the latest GraalVM-related code inside this repository while keeping the support of Java 8. GraalVM 21.1.0 (latest) started Java8-incompatible bytecode.
TODO: discuss this idea with Spanner team (and schedule appropriate time slot that avoids important milestones). -> The milestone has been done.