Skip to content

Commit ec5712a

Browse files
gcf-owl-bot[bot]losalexsuztomo
authored
chore: Java 8 unit test to build code in Java 17 and run tests on Java 8 (#1800) (#336)
* chore: Java 8 unit test to build code in Java 17 and run tests on Java 8 (#1800) * Our Java projects are configured to produce Java 8-compatible bytecode via https://github.com/googleapis/java-shared-config/blob/main/pom.xml#L848. This unit test change ensures this config is applied correctly. * This change also switches the JDK distribution of GitHub Actions to temurin from zulu. * For the repositories that mark "dependencies (8)" and "dependencies (11)" as required, they should point to only "dependencies (17)" via `.github/sync-repo-settings.yaml` and repo's Settings tab. Source-Link: googleapis/synthtool@cbe0100 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:32851debfefed2b66038e0141f1b5c2103bb59ba80b7475adbc10ef7abab3de7 * dependencies (17) --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: losalex <[email protected]> Co-authored-by: Tomo Suzuki <[email protected]>
1 parent eb5d0d7 commit ec5712a

File tree

4 files changed

+30
-7
lines changed

4 files changed

+30
-7
lines changed

.github/.OwlBot.lock.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
# limitations under the License.
1414
docker:
1515
image: gcr.io/cloud-devrel-public-resources/owlbot-java:latest
16-
digest: sha256:c33bd13e1eab022b0499a3afbfb4b93ae10cb8ad89d8203a6343a88b1b78400f
17-
# created: 2023-06-21T18:48:32.287298785Z
16+
digest: sha256:32851debfefed2b66038e0141f1b5c2103bb59ba80b7475adbc10ef7abab3de7
17+
# created: 2023-06-22T15:06:52.039318836Z
18+

.github/sync-repo-settings.yaml

Lines changed: 1 addition & 2 deletions
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
- clirr
1514
- units (8)

.github/workflows/ci.yaml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
strategy:
2626
fail-fast: false
2727
matrix:
28-
java: [8, 11, 17]
28+
java: [11, 17]
2929
steps:
3030
- uses: actions/checkout@v3
3131
- uses: actions/setup-java@v3
@@ -36,6 +36,28 @@ jobs:
3636
- run: .kokoro/build.sh
3737
env:
3838
JOB_TYPE: test
39+
units-java8:
40+
# Building using Java 17 and run the tests with Java 8 runtime
41+
name: "units (8)"
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v3
45+
- uses: actions/setup-java@v3
46+
with:
47+
java-version: 8
48+
distribution: zulu
49+
- name: "Set jvm system property environment variable for surefire plugin (unit tests)"
50+
# Maven surefire plugin (unit tests) allows us to specify JVM to run the tests.
51+
# https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#jvm
52+
run: echo "SUREFIRE_JVM_OPT=-Djvm=${JAVA_HOME}/bin/java" >> $GITHUB_ENV
53+
shell: bash
54+
- uses: actions/setup-java@v3
55+
with:
56+
java-version: 17
57+
distribution: zulu
58+
- run: .kokoro/build.sh
59+
env:
60+
JOB_TYPE: test
3961
windows:
4062
runs-on: windows-latest
4163
steps:
@@ -54,7 +76,7 @@ jobs:
5476
runs-on: ubuntu-latest
5577
strategy:
5678
matrix:
57-
java: [8, 11, 17]
79+
java: [17]
5880
steps:
5981
- uses: actions/checkout@v3
6082
- uses: actions/setup-java@v3

.kokoro/build.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ set +e
4747

4848
case ${JOB_TYPE} in
4949
test)
50-
mvn test -B -ntp -Dclirr.skip=true -Denforcer.skip=true
50+
echo "SUREFIRE_JVM_OPT: ${SUREFIRE_JVM_OPT}"
51+
mvn test -B -ntp -Dclirr.skip=true -Denforcer.skip=true ${SUREFIRE_JVM_OPT}
5152
RETURN_CODE=$?
5253
;;
5354
lint)

0 commit comments

Comments
 (0)