diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 83ef7f9c2cf..0ef324c71e3 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -25,7 +25,7 @@ jobs: strategy: fail-fast: false matrix: - java: [8, 11, 17] + java: [11, 17] steps: - uses: actions/checkout@v3 - uses: actions/setup-java@v3 @@ -36,14 +36,42 @@ jobs: - run: .kokoro/build.sh env: JOB_TYPE: test + units-java8: + name: "units (8)" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 + with: + java-version: 8 + distribution: zulu + - run: echo "JAVA8_HOME=${JAVA_HOME}" >> $GITHUB_ENV + shell: bash + - uses: actions/setup-java@v3 + with: + java-version: 11 + distribution: zulu + - run: echo "JAVA11_HOME=${JAVA_HOME}" >> $GITHUB_ENV + shell: bash + - run: .kokoro/build.sh + env: + JOB_TYPE: test windows: runs-on: windows-latest steps: - uses: actions/checkout@v3 - uses: actions/setup-java@v3 with: - distribution: zulu java-version: 8 + distribution: zulu + - run: echo "JAVA8_HOME=${JAVA_HOME}" >> $GITHUB_ENV + shell: bash + - uses: actions/setup-java@v3 + with: + java-version: 11 + distribution: zulu + - run: echo "JAVA11_HOME=${JAVA_HOME}" >> $GITHUB_ENV + shell: bash - run: java -version - run: .kokoro/build.bat env: diff --git a/.kokoro/build.sh b/.kokoro/build.sh index 56aa8c8f5c2..1b8cfc5620f 100755 --- a/.kokoro/build.sh +++ b/.kokoro/build.sh @@ -23,6 +23,17 @@ cd ${scriptDir}/.. # include common functions source ${scriptDir}/common.sh +function setJava() { + export JAVA_HOME=$1 + export PATH=${JAVA_HOME}/bin:$PATH +} + +# units-java8 uses both JDK 11 and JDK 8. GraalVM dependencies require JDK 11 to +# compile the classes touching GraalVM classes. +if [ ! -z "${JAVA11_HOME}" ]; then + setJava "${JAVA11_HOME}" +fi + # Print out Maven & Java version mvn -version echo ${JOB_TYPE} @@ -42,12 +53,19 @@ if [[ ! -z "${GOOGLE_APPLICATION_CREDENTIALS}" && "${GOOGLE_APPLICATION_CREDENTI export GOOGLE_APPLICATION_CREDENTIALS=$(realpath ${KOKORO_GFILE_DIR}/${GOOGLE_APPLICATION_CREDENTIALS}) fi +# units-java8 uses both JDK 11 and JDK 8. We ensure the generated class files +# are compatible with Java 8 when running tests. +if [ ! -z "${JAVA8_HOME}" ]; then + setJava "${JAVA8_HOME}" + mvn -version +fi + RETURN_CODE=0 set +e case ${JOB_TYPE} in test) - mvn test -B \ + mvn test -B -V \ -Dclirr.skip=true \ -Denforcer.skip=true \ -Djava.net.preferIPv4Stack=true diff --git a/.kokoro/release/common.cfg b/.kokoro/release/common.cfg index adffcbe4873..7872aea54d8 100644 --- a/.kokoro/release/common.cfg +++ b/.kokoro/release/common.cfg @@ -9,7 +9,7 @@ build_file: "java-spanner/.kokoro/trampoline.sh" # Configure the docker image for kokoro-trampoline. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java8" + value: "gcr.io/cloud-devrel-kokoro-resources/java11" } before_action { diff --git a/owlbot.py b/owlbot.py index c8e92761fcc..cb907a9878c 100644 --- a/owlbot.py +++ b/owlbot.py @@ -32,6 +32,7 @@ ".kokoro/presubmit/java8-samples.cfg", ".kokoro/presubmit/java11-samples.cfg", ".kokoro/presubmit/samples.cfg", + ".kokoro/release/common.cfg", "samples/install-without-bom/pom.xml", "samples/snapshot/pom.xml", "samples/snippets/pom.xml", @@ -40,6 +41,7 @@ ".github/release-please.yml", ".github/blunderbuss.yml", ".github/workflows/samples.yaml", + ".github/workflows/ci.yaml", ".kokoro/build.sh", ] ) diff --git a/pom.xml b/pom.xml index e99a461274b..8d2557a2579 100644 --- a/pom.xml +++ b/pom.xml @@ -224,4 +224,17 @@ + + + + compiler-release-8 + + [9,] + + + 8 + + +