Skip to content

Commit b756808

Browse files
authored
test: simplifying Java 8 test via jvm property (#2440)
* test: simplifying Java 8 test via jvm property * fix template typo * removed unnecessary multiple dependencies checks (only need one)
1 parent 941388f commit b756808

File tree

4 files changed

+22
-38
lines changed

4 files changed

+22
-38
lines changed

.github/sync-repo-settings.yaml

+1-5
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ branchProtectionRules:
88
requiresCodeOwnerReviews: true
99
requiresStrictStatusChecks: false
1010
requiredStatusCheckContexts:
11-
- dependencies (8)
12-
- dependencies (11)
11+
- dependencies (17)
1312
- lint
1413
- units (8)
1514
- units (11)
@@ -27,7 +26,6 @@ branchProtectionRules:
2726
requiresCodeOwnerReviews: true
2827
requiresStrictStatusChecks: false
2928
requiredStatusCheckContexts:
30-
- dependencies (8)
3129
- dependencies (11)
3230
- lint
3331
- units (7)
@@ -42,7 +40,6 @@ branchProtectionRules:
4240
requiresCodeOwnerReviews: true
4341
requiresStrictStatusChecks: false
4442
requiredStatusCheckContexts:
45-
- dependencies (8)
4643
- dependencies (11)
4744
- lint
4845
- units (7)
@@ -57,7 +54,6 @@ branchProtectionRules:
5754
requiresCodeOwnerReviews: true
5855
requiresStrictStatusChecks: false
5956
requiredStatusCheckContexts:
60-
- dependencies (8)
6157
- dependencies (11)
6258
- lint
6359
- units (7)

.github/workflows/ci.yaml

+6-19
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
env:
3838
JOB_TYPE: test
3939
units-java8:
40+
# Building using Java 17 and run the tests with Java 8 runtime
4041
name: "units (8)"
4142
runs-on: ubuntu-latest
4243
steps:
@@ -45,14 +46,12 @@ jobs:
4546
with:
4647
java-version: 8
4748
distribution: zulu
48-
- run: echo "JAVA8_HOME=${JAVA_HOME}" >> $GITHUB_ENV
49+
- run: echo "SUREFIRE_JVM_OPT=-Djvm=${JAVA_HOME}/bin/java" >> $GITHUB_ENV
4950
shell: bash
5051
- uses: actions/setup-java@v3
5152
with:
52-
java-version: 11
53+
java-version: 17
5354
distribution: zulu
54-
- run: echo "JAVA11_HOME=${JAVA_HOME}" >> $GITHUB_ENV
55-
shell: bash
5655
- run: .kokoro/build.sh
5756
env:
5857
JOB_TYPE: test
@@ -80,25 +79,13 @@ jobs:
8079
runs-on: ubuntu-latest
8180
strategy:
8281
matrix:
83-
java: [8, 11, 17]
82+
java: [17]
8483
steps:
8584
- uses: actions/checkout@v3
86-
# For Java 8 tests, use JDK 11 to compile
87-
- if: ${{matrix.java}} == '8'
88-
uses: actions/setup-java@v3
89-
with:
90-
java-version: 11
91-
distribution: zulu
92-
- if: ${{matrix.java}} == '8'
93-
run: echo "JAVA11_HOME=${JAVA_HOME}" >> $GITHUB_ENV
94-
shell: bash
9585
- uses: actions/setup-java@v3
9686
with:
9787
distribution: zulu
9888
java-version: ${{matrix.java}}
99-
- if: ${{matrix.java}} == '8'
100-
run: echo "JAVA8_HOME=${JAVA_HOME}" >> $GITHUB_ENV
101-
shell: bash
10289
- run: java -version
10390
- run: .kokoro/dependencies.sh
10491
lint:
@@ -108,7 +95,7 @@ jobs:
10895
- uses: actions/setup-java@v3
10996
with:
11097
distribution: zulu
111-
java-version: 11
98+
java-version: 17
11299
- run: java -version
113100
- run: .kokoro/build.sh
114101
env:
@@ -120,7 +107,7 @@ jobs:
120107
- uses: actions/setup-java@v3
121108
with:
122109
distribution: zulu
123-
java-version: 11
110+
java-version: 17
124111
- run: java -version
125112
- run: .kokoro/build.sh
126113
env:

.github/workflows/integration-tests-against-emulator.yaml

+3-8
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,15 @@ jobs:
2525
with:
2626
java-version: 11
2727
distribution: zulu
28-
- run: echo "JAVA11_HOME=${JAVA_HOME}" >> $GITHUB_ENV
29-
shell: bash
28+
- name: Compiling main library
29+
run: .kokoro/build.sh
3030
- uses: actions/setup-java@v3
3131
with:
3232
java-version: 8
3333
distribution: zulu
34-
- run: echo "JAVA8_HOME=${JAVA_HOME}" >> $GITHUB_ENV
35-
shell: bash
36-
- run: java -version
37-
- name: Compiling main library
38-
run: .kokoro/build.sh
3934
- name: Running tests
4035
run: |
41-
mvn -B -Dspanner.testenv.instance="" -Penable-integration-tests \
36+
mvn -V -B -Dspanner.testenv.instance="" -Penable-integration-tests \
4237
-DtrimStackTrace=false -Dclirr.skip=true -Denforcer.skip=true \
4338
-Dmaven.main.skip=true -fae verify
4439
env:

.kokoro/build.sh

+12-6
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ cd ${scriptDir}/..
2323
# include common functions
2424
source ${scriptDir}/common.sh
2525

26-
# units-java8 uses both JDK 11 and JDK 8. GraalVM dependencies require JDK 11 to
27-
# compile the classes touching GraalVM classes.
28-
if [ ! -z "${JAVA11_HOME}" ]; then
26+
# Kokoro integration test uses both JDK 11 and JDK 8. GraalVM dependencies
27+
# require JDK 11 to compile the classes touching GraalVM classes.
28+
if [ -n "${JAVA11_HOME}" ]; then
2929
setJava "${JAVA11_HOME}"
3030
fi
3131

@@ -48,9 +48,9 @@ if [[ ! -z "${GOOGLE_APPLICATION_CREDENTIALS}" && "${GOOGLE_APPLICATION_CREDENTI
4848
export GOOGLE_APPLICATION_CREDENTIALS=$(realpath ${KOKORO_GFILE_DIR}/${GOOGLE_APPLICATION_CREDENTIALS})
4949
fi
5050

51-
# units-java8 uses both JDK 11 and JDK 8. We ensure the generated class files
51+
# Kokoro integration test uses both JDK 11 and JDK 8. We ensure the generated class files
5252
# are compatible with Java 8 when running tests.
53-
if [ ! -z "${JAVA8_HOME}" ]; then
53+
if [ -n "${JAVA8_HOME}" ]; then
5454
setJava "${JAVA8_HOME}"
5555
fi
5656

@@ -59,10 +59,16 @@ set +e
5959

6060
case ${JOB_TYPE} in
6161
test)
62+
# Maven surefire plugin (unit tests) allows us to specify JVM to run the tests.
63+
# https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#jvm
64+
# If we rely on certain things only available in newer JVM than Java 8, this
65+
# tests detect the usage.
66+
echo "SUREFIRE_JVM_OPT: ${SUREFIRE_JVM_OPT}"
6267
mvn test -B -V \
6368
-Dclirr.skip=true \
6469
-Denforcer.skip=true \
65-
-Djava.net.preferIPv4Stack=true
70+
-Djava.net.preferIPv4Stack=true \
71+
${SUREFIRE_JVM_OPT}
6672
RETURN_CODE=$?
6773
;;
6874
lint)

0 commit comments

Comments
 (0)