Skip to content

Commit e1c7ae0

Browse files
authored
chore: update doclet test to use updated sdk-platform-java-config artifact (#755)
* chore: merge doclet test with rest of client-library-checks * add back in separate test * update script and permissions * update script * update permissions * update permissions * update permissions * rename file * update permissions * update script * replace cd with pushd and popd
1 parent b7e0bf2 commit e1c7ae0

File tree

3 files changed

+143
-64
lines changed

3 files changed

+143
-64
lines changed

.github/workflows/downstream-maven-plugins.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
- lint # fmt-maven-plugin and google-java-format
2424
- clirr # clirr-maven-plugin
2525
- javadoc # maven-javadoc-plugin
26+
- javadoc-with-doclet # test javadoc generation with doclet
2627
steps:
2728
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
2829
- uses: actions/setup-java@v3
@@ -45,8 +46,8 @@ jobs:
4546
- uses: actions/setup-java@v3
4647
with:
4748
distribution: temurin
48-
java-version: 11
49+
java-version: 17
4950
- run: java -version
5051
- run: sudo apt-get update -y
5152
- run: sudo apt-get install libxml2-utils
52-
- run: .kokoro/client-library-check-javadoc-with-doclet.sh ${{matrix.repo}}
53+
- run: .kokoro/client-library-check-doclet.sh ${{matrix.repo}}
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
#!/bin/bash
2+
# Copyright 2024 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# Presubmit to ensure the dependencies of the Google Libraries BOM, with the modification of change
17+
# in the PR, pick up the highest versions among transitive dependencies.
18+
# https://maven.apache.org/enforcer/enforcer-rules/requireUpperBoundDeps.html
19+
20+
set -eo pipefail
21+
# Display commands being run.
22+
set -x
23+
24+
function get_current_version_from_versions_txt() {
25+
versions=$1
26+
key=$2
27+
version=$(grep "$key:" "${versions}" | cut -d: -f3) # 3rd field is current
28+
echo "${version}"
29+
}
30+
31+
function get_released_version_from_versions_txt() {
32+
versions=$1
33+
key=$2
34+
version=$(grep "$key:" "${versions}" | cut -d: -f2) # 2nd field is release
35+
echo "${version}"
36+
}
37+
38+
function replace_java_shared_config_version() {
39+
version=$1
40+
# replace version
41+
xmllint --shell <(cat pom.xml) << EOF
42+
setns x=http://maven.apache.org/POM/4.0.0
43+
cd .//x:artifactId[text()="google-cloud-shared-config"]
44+
cd ../x:version
45+
set ${version}
46+
save pom.xml
47+
EOF
48+
}
49+
50+
function replace_java_shared_dependencies_version() {
51+
version=$1
52+
# replace version
53+
xmllint --shell <(cat pom.xml) << EOF
54+
setns x=http://maven.apache.org/POM/4.0.0
55+
cd .//x:properties/x:google-cloud-shared-dependencies.version
56+
set ${version}
57+
save pom.xml
58+
EOF
59+
}
60+
61+
function replace_sdk_platform_java_config_version() {
62+
version=$1
63+
# replace version
64+
xmllint --shell <(cat pom.xml) << EOF
65+
setns x=http://maven.apache.org/POM/4.0.0
66+
cd .//x:artifactId[text()="sdk-platform-java-config"]
67+
cd ../x:version
68+
set ${version}
69+
save pom.xml
70+
EOF
71+
}
72+
REPO=$1
73+
# Get the directory of the build script
74+
scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}"))
75+
## cd to the parent directory, i.e. the root of the git repo
76+
cd ${scriptDir}/..
77+
78+
# Make artifacts available for 'mvn validate' at the bottom
79+
mvn install -DskipTests=true -Dmaven.javadoc.skip=true -Dgcloud.download.skip=true -B -V -q
80+
81+
# Get version of doclet used to generate Cloud RAD for javadoc testing with the doclet below
82+
git clone https://github.com/googleapis/java-docfx-doclet.git
83+
pushd java-docfx-doclet/third_party/docfx-doclet-143274
84+
git checkout 1.9.0
85+
mvn package -Dmaven.test.skip=true
86+
87+
# work from the root directory
88+
popd
89+
docletPath=$(realpath "java-docfx-doclet/third_party/docfx-doclet-143274/target/docfx-doclet-1.0-SNAPSHOT-jar-with-dependencies.jar")
90+
echo "This is the doclet path: ${docletPath}"
91+
92+
# Read the current version of this BOM in the POM. Example version: '0.116.1-alpha-SNAPSHOT'
93+
VERSION_POM=java-shared-config/pom.xml
94+
# Namespace (xmlns) prevents xmllint from specifying tag names in XPath
95+
JAVA_SHARED_CONFIG_VERSION=`sed -e 's/xmlns=".*"//' ${VERSION_POM} | xmllint --xpath '/project/version/text()' -`
96+
97+
if [ -z "${JAVA_SHARED_CONFIG_VERSION}" ]; then
98+
echo "Version is not found in ${VERSION_POM}"
99+
exit 1
100+
fi
101+
echo "Version: ${JAVA_SHARED_CONFIG_VERSION}"
102+
103+
# Update java-shared-config in sdk-platform-java-config
104+
git clone "https://github.com/googleapis/sdk-platform-java.git" --depth=1
105+
pushd sdk-platform-java
106+
SDK_PLATFORM_JAVA_CONFIG_VERSION=$(get_current_version_from_versions_txt versions.txt "google-cloud-shared-dependencies")
107+
RELEASED_SHARED_DEPENDENCIES_VERSION=$(get_released_version_from_versions_txt versions.txt "google-cloud-shared-dependencies")
108+
echo "This is the SDK_PLATFORM_JAVA_CONFIG_VERSION: ${SDK_PLATFORM_JAVA_CONFIG_VERSION}"
109+
echo "This is the RELEASED_SHARED_DEPENDENCIES_VERSION: ${RELEASED_SHARED_DEPENDENCIES_VERSION}"
110+
pushd sdk-platform-java-config
111+
112+
# Use released version of google-cloud-shared-dependencies to avoid verifying SNAPSHOT changes.
113+
replace_java_shared_config_version "${JAVA_SHARED_CONFIG_VERSION}"
114+
replace_java_shared_dependencies_version "${RELEASED_SHARED_DEPENDENCIES_VERSION}"
115+
mvn install -DskipTests=true -Dmaven.javadoc.skip=true -Dgcloud.download.skip=true -B -V -q
116+
popd
117+
118+
# Check javadoc generation with the doclet
119+
git clone "https://github.com/googleapis/${REPO}.git" --depth=1
120+
121+
pushd ${REPO}
122+
replace_sdk_platform_java_config_version "${SDK_PLATFORM_JAVA_CONFIG_VERSION}"
123+
124+
mvn clean -B -ntp \
125+
-P docFX \
126+
-DdocletPath="${docletPath}" \
127+
-Dclirr.skip=true \
128+
-Denforcer.skip=true \
129+
-Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss:SSS \
130+
-Dcheckstyle.skip=true \
131+
-Dflatten.skip=true \
132+
-Danimal.sniffer.skip=true \
133+
javadoc:aggregate
134+
135+
RETURN_CODE=$?
136+
if [ "${RETURN_CODE}" == 0 ]; then
137+
echo "Javadocs generated successfully with doclet"
138+
else
139+
echo "Javadoc generation FAILED with doclet"
140+
fi

.kokoro/client-library-check-javadoc-with-doclet.sh

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

0 commit comments

Comments
 (0)