Skip to content

Commit

Permalink
test: simplifying Java 8 test via jvm property (#2440)
Browse files Browse the repository at this point in the history
* test: simplifying Java 8 test via jvm property

* fix template typo

* removed unnecessary multiple dependencies checks (only need one)
  • Loading branch information
suztomo committed May 19, 2023
1 parent 941388f commit b756808
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 38 deletions.
6 changes: 1 addition & 5 deletions .github/sync-repo-settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ branchProtectionRules:
requiresCodeOwnerReviews: true
requiresStrictStatusChecks: false
requiredStatusCheckContexts:
- dependencies (8)
- dependencies (11)
- dependencies (17)
- lint
- units (8)
- units (11)
Expand All @@ -27,7 +26,6 @@ branchProtectionRules:
requiresCodeOwnerReviews: true
requiresStrictStatusChecks: false
requiredStatusCheckContexts:
- dependencies (8)
- dependencies (11)
- lint
- units (7)
Expand All @@ -42,7 +40,6 @@ branchProtectionRules:
requiresCodeOwnerReviews: true
requiresStrictStatusChecks: false
requiredStatusCheckContexts:
- dependencies (8)
- dependencies (11)
- lint
- units (7)
Expand All @@ -57,7 +54,6 @@ branchProtectionRules:
requiresCodeOwnerReviews: true
requiresStrictStatusChecks: false
requiredStatusCheckContexts:
- dependencies (8)
- dependencies (11)
- lint
- units (7)
Expand Down
25 changes: 6 additions & 19 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
env:
JOB_TYPE: test
units-java8:
# Building using Java 17 and run the tests with Java 8 runtime
name: "units (8)"
runs-on: ubuntu-latest
steps:
Expand All @@ -45,14 +46,12 @@ jobs:
with:
java-version: 8
distribution: zulu
- run: echo "JAVA8_HOME=${JAVA_HOME}" >> $GITHUB_ENV
- run: echo "SUREFIRE_JVM_OPT=-Djvm=${JAVA_HOME}/bin/java" >> $GITHUB_ENV
shell: bash
- uses: actions/setup-java@v3
with:
java-version: 11
java-version: 17
distribution: zulu
- run: echo "JAVA11_HOME=${JAVA_HOME}" >> $GITHUB_ENV
shell: bash
- run: .kokoro/build.sh
env:
JOB_TYPE: test
Expand Down Expand Up @@ -80,25 +79,13 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java: [8, 11, 17]
java: [17]
steps:
- uses: actions/checkout@v3
# For Java 8 tests, use JDK 11 to compile
- if: ${{matrix.java}} == '8'
uses: actions/setup-java@v3
with:
java-version: 11
distribution: zulu
- if: ${{matrix.java}} == '8'
run: echo "JAVA11_HOME=${JAVA_HOME}" >> $GITHUB_ENV
shell: bash
- uses: actions/setup-java@v3
with:
distribution: zulu
java-version: ${{matrix.java}}
- if: ${{matrix.java}} == '8'
run: echo "JAVA8_HOME=${JAVA_HOME}" >> $GITHUB_ENV
shell: bash
- run: java -version
- run: .kokoro/dependencies.sh
lint:
Expand All @@ -108,7 +95,7 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 11
java-version: 17
- run: java -version
- run: .kokoro/build.sh
env:
Expand All @@ -120,7 +107,7 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 11
java-version: 17
- run: java -version
- run: .kokoro/build.sh
env:
Expand Down
11 changes: 3 additions & 8 deletions .github/workflows/integration-tests-against-emulator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,15 @@ jobs:
with:
java-version: 11
distribution: zulu
- run: echo "JAVA11_HOME=${JAVA_HOME}" >> $GITHUB_ENV
shell: bash
- name: Compiling main library
run: .kokoro/build.sh
- uses: actions/setup-java@v3
with:
java-version: 8
distribution: zulu
- run: echo "JAVA8_HOME=${JAVA_HOME}" >> $GITHUB_ENV
shell: bash
- run: java -version
- name: Compiling main library
run: .kokoro/build.sh
- name: Running tests
run: |
mvn -B -Dspanner.testenv.instance="" -Penable-integration-tests \
mvn -V -B -Dspanner.testenv.instance="" -Penable-integration-tests \
-DtrimStackTrace=false -Dclirr.skip=true -Denforcer.skip=true \
-Dmaven.main.skip=true -fae verify
env:
Expand Down
18 changes: 12 additions & 6 deletions .kokoro/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ cd ${scriptDir}/..
# include common functions
source ${scriptDir}/common.sh

# 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
# Kokoro integration test uses both JDK 11 and JDK 8. GraalVM dependencies
# require JDK 11 to compile the classes touching GraalVM classes.
if [ -n "${JAVA11_HOME}" ]; then
setJava "${JAVA11_HOME}"
fi

Expand All @@ -48,9 +48,9 @@ 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
# Kokoro integration test 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
if [ -n "${JAVA8_HOME}" ]; then
setJava "${JAVA8_HOME}"
fi

Expand All @@ -59,10 +59,16 @@ set +e

case ${JOB_TYPE} in
test)
# Maven surefire plugin (unit tests) allows us to specify JVM to run the tests.
# https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#jvm
# If we rely on certain things only available in newer JVM than Java 8, this
# tests detect the usage.
echo "SUREFIRE_JVM_OPT: ${SUREFIRE_JVM_OPT}"
mvn test -B -V \
-Dclirr.skip=true \
-Denforcer.skip=true \
-Djava.net.preferIPv4Stack=true
-Djava.net.preferIPv4Stack=true \
${SUREFIRE_JVM_OPT}
RETURN_CODE=$?
;;
lint)
Expand Down

0 comments on commit b756808

Please sign in to comment.