Skip to content
This repository was archived by the owner on May 14, 2026. It is now read-only.

Commit b6ab999

Browse files
authored
chore: Cloud RAD setup (#1210)
* chore: Cloud RAD setup
1 parent 0fb58e0 commit b6ab999

2 files changed

Lines changed: 174 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# cloud-rad production
4+
env_vars: {
5+
key: "STAGING_BUCKET_V2"
6+
value: "docs-staging-v2-dev"
7+
}
8+
9+
# Configure the docker image for kokoro-trampoline
10+
env_vars: {
11+
key: "TRAMPOLINE_IMAGE"
12+
value: "gcr.io/cloud-devrel-kokoro-resources/java11"
13+
}
14+
15+
env_vars: {
16+
key: "TRAMPOLINE_BUILD_FILE"
17+
value: "github/gapic-generator-java/.kokoro/release/publish_javadoc11.sh"
18+
}
19+
20+
before_action {
21+
fetch_keystore {
22+
keystore_resource {
23+
keystore_config_id: 73713
24+
keyname: "docuploader_service_account"
25+
}
26+
}
27+
}
28+
29+
# Downloads docfx doclet resource. This will be in ${KOKORO_GFILE_DIR}/<doclet name>
30+
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/docfx"
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
#!/bin/bash
2+
# Copyright 2022 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+
set -eo pipefail
17+
18+
if [[ -z "${CREDENTIALS}" ]]; then
19+
CREDENTIALS=${KOKORO_KEYSTORE_DIR}/73713_docuploader_service_account
20+
fi
21+
22+
if [[ -z "${STAGING_BUCKET_V2}" ]]; then
23+
echo "Need to set STAGING_BUCKET_V2 environment variable"
24+
exit 1
25+
fi
26+
27+
#work from the git root directory
28+
pushd $(dirname "$0")/../../
29+
30+
root_dir=$(pwd)
31+
32+
python3 --version
33+
34+
# install docuploader package
35+
python3 -m pip install --require-hashes -r .kokoro/requirements.txt
36+
37+
# If DOCLET_VERSION is passed in (overriding version in shared-config)
38+
if [ -n "${DOCLET_VERSION}" ]; then
39+
doclet_name="java-docfx-doclet-${DOCLET_VERSION}.jar"
40+
fi
41+
42+
mvn -B -ntp \
43+
-DtrimStackTrace=false \
44+
-Dclirr.skip=true \
45+
-Denforcer.skip=true \
46+
-Dcheckstyle.skip=true \
47+
-Dflatten.skip=true \
48+
-Danimal.sniffer.skip=true \
49+
-DskipTests=true \
50+
-Djacoco.skip=true \
51+
-T 1C \
52+
install
53+
54+
if [[ -z "${MODULE_LIST}" ]]; then
55+
# Retrieve list of modules from aggregator pom
56+
modules=($(mvn help:evaluate -Dexpression=project.modules | grep '<.*>.*</.*>' | sed -e 's/<.*>\(.*\)<\/.*>/\1/g'))
57+
else
58+
modules=($(echo "${MODULE_LIST}" | tr ',' ' '))
59+
fi
60+
61+
excluded_modules=('gapic-generator-java-pom-parent' 'gapic-generator-java' 'gapic-generator-java-bom' )
62+
failed_modules=()
63+
64+
declare -A cloud_rad_module_name
65+
cloud_rad_module_name+=( ["gax-java"]=gax ["api-common-java"]=api-common ["java-common-protos"]=proto-google-common-protos ["java-iam"]=proto-google-iam-v1 )
66+
67+
for module in "${modules[@]}"; do
68+
# Proceed if module is not excluded
69+
# Spaces are intentionally added -- Query is regex and array elements are space separated
70+
# It tries to match the *exact* `module` text
71+
if [[ ! " ${excluded_modules[*]} " =~ " ${module} " ]]; then
72+
pushd $module
73+
74+
NAME=${cloud_rad_module_name[${module}]}
75+
# Extract (current) version from root `versions.txt` file and remove `-SNAPSHOT`
76+
VERSION=$(grep "^${NAME}:" "${root_dir}/versions.txt" | cut -d: -f3 | sed -e 's/-SNAPSHOT//g')
77+
echo "Running for ${NAME}-${VERSION}"
78+
79+
# Cloud RAD generation
80+
if [ -z "${doclet_name}" ]; then
81+
mvn clean -B -ntp \
82+
-P docFX \
83+
-Dclirr.skip=true \
84+
-Denforcer.skip=true \
85+
-Dcheckstyle.skip=true \
86+
-Dflatten.skip=true \
87+
-Danimal.sniffer.skip=true \
88+
javadoc:aggregate
89+
else
90+
mvn clean -B -ntp \
91+
-P docFX \
92+
-DdocletPath=${KOKORO_GFILE_DIR}/${doclet_name} \
93+
-Dclirr.skip=true \
94+
-Denforcer.skip=true \
95+
-Dcheckstyle.skip=true \
96+
-Dflatten.skip=true \
97+
-Danimal.sniffer.skip=true \
98+
javadoc:aggregate
99+
fi
100+
101+
if [ "$?" -ne "0" ]; then
102+
failed_modules+=("${module}")
103+
continue
104+
fi
105+
# include CHANGELOG if exists
106+
if [ -e CHANGELOG.md ]; then
107+
cp CHANGELOG.md target/docfx-yml/history.md
108+
fi
109+
pushd target/docfx-yml
110+
111+
echo "Creating metadata for ${module}..."
112+
# create metadata
113+
python3 -m docuploader create-metadata \
114+
--name ${NAME} \
115+
--version ${VERSION} \
116+
--xrefs devsite://java/gax \
117+
--xrefs devsite://java/google-cloud-core \
118+
--xrefs devsite://java/api-common \
119+
--xrefs devsite://java/proto-google-common-protos \
120+
--xrefs devsite://java/google-api-client \
121+
--xrefs devsite://java/google-http-client \
122+
--xrefs devsite://java/protobuf \
123+
--language java
124+
125+
echo "Uploading tarball for ${module}..."
126+
# upload yml to production bucket
127+
python3 -m docuploader upload . \
128+
--credentials ${CREDENTIALS} \
129+
--staging-bucket ${STAGING_BUCKET_V2} \
130+
--destination-prefix docfx
131+
132+
echo "Uploaded tarball for ${module}"
133+
134+
popd # out of target/docfx-yml
135+
popd # out of $module
136+
fi
137+
done
138+
139+
if [ ${#failed_modules[@]} -eq 0 ]; then
140+
echo "All modules uploaded to CloudRAD"
141+
else
142+
echo "These modules failed: ${failed_modules[*]}"
143+
exit 1
144+
fi

0 commit comments

Comments
 (0)