Skip to content

Commit 37a58c0

Browse files
committed
build: use matrix for split unit tests
1 parent 1ce1bc5 commit 37a58c0

File tree

10 files changed

+179
-153
lines changed

10 files changed

+179
-153
lines changed

.github/workflows/ci.yaml

Lines changed: 99 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,108 @@ jobs:
6666
key: ${{ runner.os }}-maven-unified-${{ steps.date.outputs.week_of_year }}
6767
- name: Install all modules using Java 11
6868
shell: bash
69-
run: |
70-
mvn -V -B -ntp clean install -DskipTests -Dfmt.skip -Dclirr.skip -Denforcer.skip -Dcheckstyle.skip -Dflatten.skip -Danimal-sniffer.skip -Djacoco.skip
71-
working-directory: sdk-platform-java
69+
run: .kokoro/build.sh
70+
env:
71+
JOB_TYPE: install
7272
- uses: actions/setup-java@v4
7373
with:
7474
java-version: 8
7575
distribution: temurin
7676
- run: java -version
7777
- name: Run tests in Java 8 with the source compiled in Java 11
78+
run: |
79+
mvn test \
80+
-B -ntp \
81+
-PbulkTests \
82+
-Dorg.slf4j.simpleLogger.showDateTime=true \
83+
-Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss:SSS \
84+
-Dclirr.skip=true \
85+
-Denforcer.skip=true \
86+
-Dcheckstyle.skip=true \
87+
-Dflatten.skip=true \
88+
-Danimal.sniffer.skip=true \
89+
-Dmaven.wagon.http.retryHandler.count=5 \
90+
--also-make
91+
env:
92+
JOB_TYPE: test
93+
JOB_NAME: units-8-runtime-${{matrix.java}}
94+
# detect which libraries have changed
95+
changes:
96+
runs-on: ubuntu-latest
97+
permissions:
98+
pull-requests: read
99+
outputs:
100+
packages: ${{ steps.filter.outputs.changes }}
101+
steps:
102+
- uses: dorny/paths-filter@v4
103+
id: filter
104+
with:
105+
filters: |
106+
java-bigquery: java-bigquery/**
107+
java-bigquerystorage: java-bigquerystorage/**
108+
java-datastore: java-datastore/**
109+
java-logging: java-logging/**
110+
java-logging-logback: java-logging-logback/**
111+
sdk-platform-java: sdk-platform-java/**
112+
split-units:
113+
runs-on: ubuntu-latest
114+
needs: changes
115+
strategy:
116+
fail-fast: false
117+
matrix:
118+
package: ${{ fromJSON(needs.changes.outputs.packages) }}
119+
java: [11, 17, 21, 25]
120+
steps:
121+
- name: Get current week within the year
122+
id: date
123+
run: echo "::set-output name=week_of_year::$(date +'%W' --utc)"
124+
- uses: actions/checkout@v4
125+
- uses: actions/setup-java@v4
126+
with:
127+
distribution: temurin
128+
java-version: ${{matrix.java}}
129+
- run: .kokoro/build.sh
130+
env:
131+
BUILD_SUBDIR: ${{matrix.package}}
132+
JOB_TYPE: test
133+
JOB_NAME: units-${{matrix.package}}-${{matrix.java}}
134+
split-units-8:
135+
runs-on: ubuntu-latest
136+
name: "split-units"
137+
needs: changes
138+
strategy:
139+
fail-fast: false
140+
matrix:
141+
package: ${{ fromJSON(needs.changes.outputs.packages) }}
142+
java: [8]
143+
steps:
144+
- name: Get current week within the year
145+
id: date
146+
run: echo "::set-output name=week_of_year::$(date +'%W' --utc)"
147+
- uses: actions/checkout@v4
148+
- uses: actions/setup-java@v4
149+
with:
150+
java-version: 11
151+
distribution: temurin
152+
cache: maven
153+
- run: java -version
154+
- uses: actions/cache@v4
155+
id: mvn-cache
156+
with:
157+
path: ~/.m2/repository
158+
key: ${{ runner.os }}-maven-unified-${{ steps.date.outputs.week_of_year }}
159+
- name: Install all modules using Java 11
160+
shell: bash
161+
run: .kokoro/build.sh
162+
env:
163+
BUILD_SUBDIR: ${{matrix.package}}
164+
JOB_TYPE: install
165+
- uses: actions/setup-java@v4
166+
with:
167+
java-version: ${{matrix.java}}
168+
distribution: temurin
169+
- run: java -version
170+
- name: Run tests in Java ${{matrix.java}} with the source compiled in Java 11
78171
run: |
79172
mvn test \
80173
-B -ntp \
@@ -86,11 +179,13 @@ jobs:
86179
-Dflatten.skip=true \
87180
-Danimal.sniffer.skip=true \
88181
-Dmaven.wagon.http.retryHandler.count=5 \
182+
--also-make \
89183
-T 1C
90184
env:
185+
BUILD_SUBDIR: ${{matrix.package}}
91186
JOB_TYPE: test
92187
JOB_NAME: units-8-runtime-${{matrix.java}}
93-
working-directory: sdk-platform-java
188+
working-directory: ${{matrix.package}}
94189
windows:
95190
runs-on: windows-latest
96191
steps:

.github/workflows/java-bigquery-ci.yaml

Lines changed: 0 additions & 143 deletions
This file was deleted.

.github/workflows/sdk-platform-java-ci.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,11 @@ jobs:
430430
- name: Checkout sdk-platform-java @ PR merge commit
431431
uses: actions/checkout@v3
432432
- name: Install sdk-platform-java @ PR merge commit
433-
run: mvn install -B -ntp -T 1C -DskipTests
434-
working-directory: sdk-platform-java
433+
shell: bash
434+
run: .kokoro/build.sh
435+
env:
436+
JOB_TYPE: install
437+
BUILD_SUBDIR: sdk-platform-java
435438
# Showcase golden test ensures that src changes are already reflected in the PR.
436439
- name: Clirr check
437440
working-directory: sdk-platform-java/java-showcase

.kokoro/build.sh

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ case ${JOB_TYPE} in
4343
install_modules "${BUILD_SUBDIR}"
4444
echo "Running in subdir: ${BUILD_SUBDIR}"
4545
pushd "${BUILD_SUBDIR}"
46+
EXTRA_PROFILE_OPTS=()
4647
else
48+
EXTRA_PROFILE_OPTS=("-PbulkTests")
4749
install_modules "sdk-platform-java"
4850
fi
4951
echo "SUREFIRE_JVM_OPT: ${SUREFIRE_JVM_OPT}"
@@ -59,7 +61,7 @@ case ${JOB_TYPE} in
5961
-Danimal.sniffer.skip=true \
6062
-Dmaven.wagon.http.retryHandler.count=5 \
6163
--also-make \
62-
${SUREFIRE_JVM_OPT}
64+
${SUREFIRE_JVM_OPT} "${EXTRA_PROFILE_OPTS[@]}"
6365
RETURN_CODE=$?
6466

6567
if [[ -n "${BUILD_SUBDIR}" ]]
@@ -69,6 +71,26 @@ case ${JOB_TYPE} in
6971
fi
7072
echo "Finished running unit tests"
7173
;;
74+
install)
75+
if [[ -n "${BUILD_SUBDIR}" ]]
76+
then
77+
echo "Compiling and building all modules for ${BUILD_SUBDIR}"
78+
install_modules "${BUILD_SUBDIR}"
79+
else
80+
mvn install \
81+
-B -ntp \
82+
-Dorg.slf4j.simpleLogger.showDateTime=true \
83+
-Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss:SSS \
84+
-Dclirr.skip=true \
85+
-Denforcer.skip=true \
86+
-Dcheckstyle.skip=true \
87+
-Dflatten.skip=true \
88+
-Danimal.sniffer.skip=true \
89+
-Dmaven.wagon.http.retryHandler.count=5 \
90+
-DskipTests=true \
91+
-T 1C
92+
fi
93+
;;
7294
integration)
7395
generate_modified_modules_list
7496
if [[ "$(release_please_snapshot_pull_request)" == "true" ]]; then

java-bigquery/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,5 +162,12 @@
162162
<module>benchmark</module>
163163
</modules>
164164
</profile>
165+
<!-- skip tests if bulkTests profile is enabled (when testing the rest of the monorepo) -->
166+
<profile>
167+
<id>bulkTests</id>
168+
<properties>
169+
<skipTests>true</skipTests>
170+
</properties>
171+
</profile>
165172
</profiles>
166173
</project>

java-bigquerystorage/pom.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,14 @@
202202
<module>google-cloud-bigquerystorage-bom</module>
203203
</modules>
204204

205-
</project>
205+
<profiles>
206+
<!-- skip tests if bulkTests profile is enabled (when testing the rest of the monorepo) -->
207+
<profile>
208+
<id>bulkTests</id>
209+
<properties>
210+
<skipTests>true</skipTests>
211+
</properties>
212+
</profile>
213+
</profiles>
214+
215+
</project>

java-datastore/pom.xml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,4 +232,13 @@
232232
<module>google-cloud-datastore-utils</module>
233233
</modules>
234234

235-
</project>
235+
<profiles>
236+
<!-- skip tests if bulkTests profile is enabled (when testing the rest of the monorepo) -->
237+
<profile>
238+
<id>bulkTests</id>
239+
<properties>
240+
<skipTests>true</skipTests>
241+
</properties>
242+
</profile>
243+
</profiles>
244+
</project>

java-logging-logback/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,5 +168,12 @@
168168
<test>!LoggingAppenderTest</test>
169169
</properties>
170170
</profile>
171+
<!-- skip tests if bulkTests profile is enabled (when testing the rest of the monorepo) -->
172+
<profile>
173+
<id>bulkTests</id>
174+
<properties>
175+
<skipTests>true</skipTests>
176+
</properties>
177+
</profile>
171178
</profiles>
172179
</project>

0 commit comments

Comments
 (0)