Skip to content

Commit 2255c5d

Browse files
committed
chore: ensure we use the current version of the auth library in the monorepo
current versions fix double annotation fix sdk-platform-java install scripts declare individual auth library versions auth library is required build fix downstream tests cleanup downstream tests fix common test fix path to downstream script fix setup maven mirror fix unmanaged dependency check fix showcase tests build: fix jar location fix jar location skip auth-library tests for bulk tests
1 parent a9198ee commit 2255c5d

File tree

16 files changed

+230
-131
lines changed

16 files changed

+230
-131
lines changed

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

Lines changed: 71 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ jobs:
3333
cache: maven
3434
- run: java -version
3535
- name: Unit Tests
36-
run: |
37-
mvn test --batch-mode --no-transfer-progress -Dcheckstyle.skip \
38-
-Dfmt.skip -DenableTestCoverage
39-
working-directory: sdk-platform-java
36+
shell: bash
37+
run: .kokoro/build.sh
38+
env:
39+
BUILD_SUBDIR: sdk-platform-java
40+
JOB_TYPE: test
4041
# The `envVarTest` profile runs tests that require an environment variable
4142
- name: Env Var Tests
4243
run: |
@@ -49,10 +50,12 @@ jobs:
4950
GOOGLE_SDK_JAVA_LOGGING: true
5051
working-directory: sdk-platform-java
5152
- run: bazelisk version
52-
- name: Install Maven modules
53-
run: |
54-
mvn install -B -ntp -DskipTests -Dclirr.skip -Dcheckstyle.skip -Dfmt.skip
55-
working-directory: sdk-platform-java
53+
- name: Install all modules using Java 11
54+
shell: bash
55+
run: .kokoro/build.sh
56+
env:
57+
BUILD_SUBDIR: sdk-platform-java
58+
JOB_TYPE: install
5659
- name: Integration Tests
5760
run: |
5861
bazelisk --batch test //sdk-platform-java/test/integration/...
@@ -89,26 +92,29 @@ jobs:
8992
cache: maven
9093
- run: java -version
9194
- name: Unit Tests
92-
run: |
93-
mvn test --batch-mode --no-transfer-progress -Dcheckstyle.skip \
94-
-Dfmt.skip -DenableTestCoverage
95-
working-directory: sdk-platform-java
95+
shell: bash
96+
run: .kokoro/build.sh
97+
env:
98+
BUILD_SUBDIR: sdk-platform-java
99+
JOB_TYPE: test
96100
# The `envVarTest` profile runs tests that require an environment variable
97101
- name: Env Var Tests
98-
run: |
99-
mvn test --batch-mode --no-transfer-progress -Dcheckstyle.skip \
100-
-Dfmt.skip -DenableTestCoverage -PenvVarTest
101-
# Set the Env Var for this step only
102+
shell: bash
103+
run: .kokoro/build.sh
102104
env:
105+
BUILD_SUBDIR: sdk-platform-java
106+
JOB_TYPE: test
107+
SUREFIRE_JVM_OPT: '-PenvVarTest'
103108
GOOGLE_CLOUD_UNIVERSE_DOMAIN: random.com
104109
GOOGLE_CLOUD_ENABLE_DIRECT_PATH_XDS: true
105110
GOOGLE_SDK_JAVA_LOGGING: true
106-
working-directory: sdk-platform-java
107111
- run: bazelisk version
108-
- name: Install Maven modules
109-
run: |
110-
mvn install -B -ntp -DskipTests -Dclirr.skip -Dcheckstyle.skip
111-
working-directory: sdk-platform-java
112+
- name: Install all modules using Java 11
113+
shell: bash
114+
run: .kokoro/build.sh
115+
env:
116+
BUILD_SUBDIR: sdk-platform-java
117+
JOB_TYPE: install
112118
- name: Integration Tests
113119
run: |
114120
bazelisk --batch test //sdk-platform-java/test/integration/...
@@ -127,26 +133,29 @@ jobs:
127133
cache: maven
128134
- run: java -version
129135
- name: Unit Tests
130-
run: |
131-
mvn test --batch-mode --no-transfer-progress -Dcheckstyle.skip \
132-
-Dfmt.skip -DenableTestCoverage
133-
working-directory: sdk-platform-java
136+
shell: bash
137+
run: .kokoro/build.sh
138+
env:
139+
BUILD_SUBDIR: sdk-platform-java
140+
JOB_TYPE: test
134141
# The `envVarTest` profile runs tests that require an environment variable
135142
- name: Env Var Tests
136-
run: |
137-
mvn test --batch-mode --no-transfer-progress -Dcheckstyle.skip \
138-
-Dfmt.skip -DenableTestCoverage -PenvVarTest
139-
# Set the Env Var for this step only
143+
shell: bash
144+
run: .kokoro/build.sh
140145
env:
146+
BUILD_SUBDIR: sdk-platform-java
147+
JOB_TYPE: test
148+
SUREFIRE_JVM_OPT: '-PenvVarTest'
141149
GOOGLE_CLOUD_UNIVERSE_DOMAIN: random.com
142150
GOOGLE_CLOUD_ENABLE_DIRECT_PATH_XDS: true
143151
GOOGLE_SDK_JAVA_LOGGING: true
144-
working-directory: sdk-platform-java
145152
- run: bazelisk version
146-
- name: Install Maven modules
147-
run: |
148-
mvn install -B -ntp -DskipTests -Dclirr.skip -Dcheckstyle.skip -Dfmt.skip
149-
working-directory: sdk-platform-java
153+
- name: Install all modules using Java 11
154+
shell: bash
155+
run: .kokoro/build.sh
156+
env:
157+
BUILD_SUBDIR: sdk-platform-java
158+
JOB_TYPE: install
150159
- name: Integration Tests
151160
# note need to set shouldInstallTestSecurityManager=false due to https://github.com/bazelbuild/bazel/issues/24354
152161
run: |
@@ -215,9 +224,10 @@ jobs:
215224
cache: maven
216225
- name: Install all modules using Java 11
217226
shell: bash
218-
run: |
219-
mvn -V -B -ntp clean install -DskipTests -Dfmt.skip -Dcheckstyle.skip
220-
working-directory: sdk-platform-java
227+
run: .kokoro/build.sh
228+
env:
229+
BUILD_SUBDIR: sdk-platform-java
230+
JOB_TYPE: install
221231
- uses: actions/setup-java@v3
222232
with:
223233
java-version: 8
@@ -265,9 +275,10 @@ jobs:
265275
cache: maven
266276
- name: Install all modules using Java 11
267277
shell: bash
268-
run: |
269-
mvn install -B -ntp -DskipTests -Dclirr.skip -Dcheckstyle.skip -Dfmt.skip
270-
working-directory: sdk-platform-java
278+
run: .kokoro/build.sh
279+
env:
280+
BUILD_SUBDIR: sdk-platform-java
281+
JOB_TYPE: install
271282
- uses: actions/setup-java@v3
272283
with:
273284
java-version: 8
@@ -339,9 +350,11 @@ jobs:
339350
distribution: temurin
340351
- run: mvn -version
341352
- name: Install Maven modules
342-
run: |
343-
mvn install -B -ntp -DskipTests -Dclirr.skip -Dcheckstyle.skip -Dfmt.skip
344-
working-directory: sdk-platform-java
353+
shell: bash
354+
run: .kokoro/build.sh
355+
env:
356+
BUILD_SUBDIR: sdk-platform-java
357+
JOB_TYPE: test
345358
- name: Showcase golden tests
346359
working-directory: sdk-platform-java/java-showcase
347360
run: |
@@ -418,9 +431,11 @@ jobs:
418431
distribution: temurin
419432
cache: maven
420433
- name: Install Maven modules
421-
run: |
422-
mvn install -B -ntp -DskipTests -Dclirr.skip -Dcheckstyle.skip -Dfmt.skip
423-
working-directory: sdk-platform-java
434+
shell: bash
435+
run: .kokoro/build.sh
436+
env:
437+
BUILD_SUBDIR: sdk-platform-java
438+
JOB_TYPE: install
424439
- name: Install showcase to local maven repository
425440
run: |
426441
mvn install -B -ntp -T 1C -DskipTests
@@ -454,20 +469,11 @@ jobs:
454469
distribution: temurin
455470
cache: maven
456471
- name: Install Maven modules to local Maven repository
457-
run: |
458-
mvn install \
459-
-B -ntp \
460-
-Dorg.slf4j.simpleLogger.showDateTime=true \
461-
-Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss:SSS \
462-
-DskipTests \
463-
-Dclirr.skip=true \
464-
-Denforcer.skip=true \
465-
-Dcheckstyle.skip=true \
466-
-Dflatten.skip=true \
467-
-Danimal.sniffer.skip=true \
468-
-Dmaven.wagon.http.retryHandler.count=5 \
469-
-T 1C
470-
working-directory: sdk-platform-java
472+
shell: bash
473+
run: .kokoro/build.sh
474+
env:
475+
BUILD_SUBDIR: sdk-platform-java
476+
JOB_TYPE: install
471477
- name: Validate gapic-generator-java-bom
472478
uses: googleapis/java-cloud-bom/tests/validate-bom@47ad868794c5d38ee7eb95d69371a7a79f84d890
473479
with:
@@ -491,9 +497,11 @@ jobs:
491497
mvn test --batch-mode --no-transfer-progress
492498
working-directory: sdk-platform-java/java-shared-dependencies/unmanaged-dependency-check
493499
- name: Install Maven modules
494-
run: |
495-
mvn install -B -ntp -DskipTests -Dclirr.skip -Dcheckstyle.skip -Dfmt.skip
496-
working-directory: sdk-platform-java
500+
shell: bash
501+
run: .kokoro/build.sh
502+
env:
503+
BUILD_SUBDIR: sdk-platform-java
504+
JOB_TYPE: test
497505
- name: Unmanaged dependency check
498506
uses: ./sdk-platform-java/java-shared-dependencies/unmanaged-dependency-check
499507
with:

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,9 @@ jobs:
3232
matrix:
3333
repo:
3434
- java-bigtable
35-
- java-bigquery
3635
- java-firestore
3736
- java-pubsub
3837
- java-pubsublite
39-
- java-spanner-jdbc
40-
- java-spanner
41-
- java-storage
42-
- java-storage-nio
4338
steps:
4439
- uses: actions/checkout@v3
4540
- uses: actions/setup-java@v3
@@ -52,9 +47,9 @@ jobs:
5247
sudo apt-get update
5348
sudo apt-get -y install libxml2-utils
5449
- name: Test helper scripts
55-
run: ./sdk-platform-java/.kokoro/presubmit/common_test.sh
50+
run: .kokoro/common_test.sh
5651
- name: Perform downstream compatibility testing
57-
run: REPOS_UNDER_TEST="${{ matrix.repo }}" ./sdk-platform-java/.kokoro/presubmit/downstream-compatibility.sh
52+
run: REPOS_UNDER_TEST="${{ matrix.repo }}" .kokoro/downstream-compatibility.sh
5853
downstream-compatibility-spring-generator:
5954
needs: filter
6055
if: ${{ needs.filter.outputs.library == 'true' }}
@@ -73,4 +68,4 @@ jobs:
7368
sudo apt-get update
7469
sudo apt-get -y install libxml2-utils
7570
- name: Perform downstream compatibility testing
76-
run: ./sdk-platform-java/.kokoro/presubmit/downstream-compatibility-spring.sh
71+
run: .kokoro/downstream-compatibility-spring.sh

.kokoro/common.sh

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16+
commonScriptDir=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
1617
excluded_modules=(
1718
'gapic-libraries-bom'
1819
'google-cloud-jar-parent'
@@ -32,6 +33,7 @@ excluded_modules=(
3233
'java-spanner'
3334
'java-spanner-jdbc'
3435
'google-auth-library-java'
36+
'google-auth-library-java/oauth2_http'
3537
'java-storage'
3638
'java-storage-nio'
3739
)
@@ -305,6 +307,7 @@ function run_integration_tests() {
305307
${INTEGRATION_TEST_ARGS} \
306308
-B -ntp -fae \
307309
--also-make \
310+
-PbulkTests \
308311
-DtrimStackTrace=false \
309312
-Dclirr.skip=true \
310313
-Denforcer.skip=true \
@@ -419,6 +422,10 @@ function install_modules() {
419422
printf "Installing submodules:\n%s\n" "$all_submodules"
420423

421424
always_install_deps_list=(
425+
'google-auth-library-java/appengine'
426+
'google-auth-library-java/bom'
427+
'google-auth-library-java/credentials'
428+
'google-auth-library-java/oauth2_http'
422429
'sdk-platform-java/java-shared-dependencies'
423430
'sdk-platform-java/java-shared-dependencies/first-party-dependencies'
424431
'sdk-platform-java/java-shared-dependencies/third-party-dependencies'
@@ -478,3 +485,100 @@ function install_modules() {
478485
-T 1C
479486
fi
480487
}
488+
489+
490+
# In the given directory ($1),
491+
# update the pom.xml's dependency on the given artifact ($2) to the given version ($3)
492+
# ex: update_dependency google-cloud-java/google-cloud-jar-parent google-cloud-shared-dependencies 1.2.3
493+
function update_pom_dependency {
494+
pushd "$1" || exit 1
495+
xmllint --shell pom.xml &>/dev/null <<EOF
496+
setns x=http://maven.apache.org/POM/4.0.0
497+
cd .//x:artifactId[text()="$2"]
498+
cd ../x:version
499+
set $3
500+
save pom.xml
501+
EOF
502+
popd || exit 1
503+
}
504+
505+
# Find all pom.xml files that declare a specific version for the given artifact ($1)
506+
function find_all_poms_with_versioned_dependency {
507+
poms=($(find . -name pom.xml))
508+
for pom in "${poms[@]}"; do
509+
if xmllint --xpath "//*[local-name()='artifactId' and text()='$1']/following-sibling::*[local-name()='version']" "$pom" &>/dev/null; then
510+
found+=("$pom")
511+
fi
512+
done
513+
POMS=(${found[@]})
514+
unset found
515+
export POMS
516+
}
517+
518+
# In the given directory ($1),
519+
# find and update all pom.xmls' dependencies on the given artifact ($2) to the given version ($3)
520+
# ex: update_all_poms_dependency google-cloud-java google-cloud-shared-dependencies 1.2.3
521+
function update_all_poms_dependency {
522+
pushd "$1" || exit 1
523+
find_all_poms_with_versioned_dependency "$2"
524+
for pom in $POMS; do
525+
update_pom_dependency "$(dirname "$pom")" "$2" "$3"
526+
done
527+
git diff
528+
popd || exit 1
529+
}
530+
531+
# Parse the version of the pom.xml file in the given directory ($1)
532+
# ex: VERSION=$(parse_pom_version java-shared-dependencies)
533+
function parse_pom_version {
534+
# Namespace (xmlns) prevents xmllint from specifying tag names in XPath
535+
result=$(sed -e 's/xmlns=".*"//' "$1/pom.xml" | xmllint --xpath '/project/version/text()' -)
536+
537+
if [ -z "${result}" ]; then
538+
echo "Version is not found in $1"
539+
exit 1
540+
fi
541+
echo "$result"
542+
}
543+
544+
# ex: find_last_release_version java-bigtable
545+
# ex: find_last_release_version java-storage 2.22.x
546+
function find_last_release_version {
547+
repo=$1
548+
branch=${2-"main"} # Default to using main branch
549+
org=${3-"googleapis"}
550+
curl -s -o "versions_${repo}.txt" "https://raw.githubusercontent.com/${org}/${repo}/${branch}/versions.txt"
551+
552+
# First check to see if there's an entry for the overall repo. Used for google-cloud-java.
553+
primary_artifact=$(grep -E "^${repo}" "versions_${repo}.txt" | head -n 1)
554+
if [ -z "${primary_artifact}" ]; then
555+
# Otherwise, use the first google-cloud-* artifact's version.
556+
primary_artifact=$(grep -E "^google-cloud-" "versions_$1.txt" | head -n 1)
557+
fi
558+
if [ -z "${primary_artifact}" ]; then
559+
echo "Unable to identify primary artifact for $1"
560+
exit 1
561+
fi
562+
563+
parts=($(echo "$primary_artifact" | tr ":" "\n"))
564+
echo "${parts[1]}"
565+
}
566+
567+
# copies settings.xml from the root of sdk-platform-java into Maven's home
568+
# folder
569+
function setup_maven_mirror {
570+
echo "Setup maven mirror"
571+
mkdir -p "${HOME}/.m2"
572+
cp "${commonScriptDir}/../settings.xml" "${HOME}/.m2"
573+
}
574+
575+
function install_repo_modules {
576+
target_projects="$1"
577+
projects_arg=""
578+
if [ -n "${target_projects}" ]; then
579+
projects_arg="--projects ${target_projects}"
580+
fi
581+
echo "Installing this repo's modules to local maven."
582+
mvn -q -B -ntp install ${projects_arg} \
583+
-Dcheckstyle.skip -Dfmt.skip -DskipTests -T 1C
584+
}

0 commit comments

Comments
 (0)