Skip to content

Commit 6374191

Browse files
authored
build: add docs configuration (#58)
1 parent 3c92303 commit 6374191

File tree

5 files changed

+159
-1
lines changed

5 files changed

+159
-1
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# Build logs will be here
4+
action {
5+
define_artifacts {
6+
regex: "**/*sponge_log.xml"
7+
}
8+
}
9+
10+
# Download trampoline resources.
11+
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
12+
13+
# Use the trampoline script to run in docker.
14+
build_file: "python-grpc-google-iam-v1/.kokoro/trampoline_v2.sh"
15+
16+
# Configure the docker image for kokoro-trampoline.
17+
env_vars: {
18+
key: "TRAMPOLINE_IMAGE"
19+
value: "gcr.io/cloud-devrel-kokoro-resources/python-lib-docs"
20+
}
21+
env_vars: {
22+
key: "TRAMPOLINE_BUILD_FILE"
23+
value: "github/python-grpc-google-iam-v1/.kokoro/publish-docs.sh"
24+
}
25+
26+
env_vars: {
27+
key: "STAGING_BUCKET"
28+
value: "docs-staging"
29+
}
30+
31+
env_vars: {
32+
key: "V2_STAGING_BUCKET"
33+
# Push non-cloud library docs to `docs-staging-v2-staging` instead of the
34+
# Cloud RAD bucket `docs-staging-v2`
35+
value: "docs-staging-v2-staging"
36+
}
37+
38+
# It will upload the docker image after successful builds.
39+
env_vars: {
40+
key: "TRAMPOLINE_IMAGE_UPLOAD"
41+
value: "true"
42+
}
43+
44+
# It will always build the docker image.
45+
env_vars: {
46+
key: "TRAMPOLINE_DOCKERFILE"
47+
value: ".kokoro/docker/docs/Dockerfile"
48+
}
49+
50+
# Fetch the token needed for reporting release status to GitHub
51+
before_action {
52+
fetch_keystore {
53+
keystore_resource {
54+
keystore_config_id: 73713
55+
keyname: "yoshi-automation-github-key"
56+
}
57+
}
58+
}
59+
60+
before_action {
61+
fetch_keystore {
62+
keystore_resource {
63+
keystore_config_id: 73713
64+
keyname: "docuploader_service_account"
65+
}
66+
}
67+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
env_vars: {
4+
key: "STAGING_BUCKET"
5+
value: "gcloud-python-test"
6+
}
7+
8+
env_vars: {
9+
key: "V2_STAGING_BUCKET"
10+
value: "gcloud-python-test"
11+
}
12+
13+
# We only upload the image in the main `docs` build.
14+
env_vars: {
15+
key: "TRAMPOLINE_IMAGE_UPLOAD"
16+
value: "false"
17+
}
18+
19+
env_vars: {
20+
key: "TRAMPOLINE_BUILD_FILE"
21+
value: "github/python-grpc-google-iam-v1/.kokoro/build.sh"
22+
}
23+
24+
# Only run this nox session.
25+
env_vars: {
26+
key: "NOX_SESSION"
27+
value: "docs docfx"
28+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
# Copyright 2023 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+
# https://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+
# Disable buffering, so that the logs stream through.
19+
export PYTHONUNBUFFERED=1
20+
21+
export PATH="${HOME}/.local/bin:${PATH}"
22+
23+
# Install nox
24+
python3 -m pip install --require-hashes -r .kokoro/requirements.txt
25+
python3 -m nox --version
26+
27+
# build docs
28+
nox -s docs
29+
30+
# create metadata
31+
python3 -m docuploader create-metadata \
32+
--name=$(jq --raw-output '.name // empty' .repo-metadata.json) \
33+
--version=$(python3 setup.py --version) \
34+
--language=$(jq --raw-output '.language // empty' .repo-metadata.json) \
35+
--distribution-name=$(python3 setup.py --name) \
36+
--product-page=$(jq --raw-output '.product_documentation // empty' .repo-metadata.json) \
37+
--github-repository=$(jq --raw-output '.repo // empty' .repo-metadata.json) \
38+
--issue-tracker=$(jq --raw-output '.issue_tracker // empty' .repo-metadata.json)
39+
40+
cat docs.metadata
41+
42+
# upload docs
43+
python3 -m docuploader upload docs/_build/html --metadata-file docs.metadata --staging-bucket "${STAGING_BUCKET}"
44+
45+
46+
# docfx yaml files
47+
nox -s docfx
48+
49+
# create metadata.
50+
python3 -m docuploader create-metadata \
51+
--name=$(jq --raw-output '.name // empty' .repo-metadata.json) \
52+
--version=$(python3 setup.py --version) \
53+
--language=$(jq --raw-output '.language // empty' .repo-metadata.json) \
54+
--distribution-name=$(python3 setup.py --name) \
55+
--product-page=$(jq --raw-output '.product_documentation // empty' .repo-metadata.json) \
56+
--github-repository=$(jq --raw-output '.repo // empty' .repo-metadata.json) \
57+
--issue-tracker=$(jq --raw-output '.issue_tracker // empty' .repo-metadata.json)
58+
59+
cat docs.metadata
60+
61+
# upload docs
62+
python3 -m docuploader upload docs/_build/html/docfx_yaml --metadata-file docs.metadata --destination-prefix docfx --staging-bucket "${V2_STAGING_BUCKET}"

packages/grpc-google-iam-v1/owlbot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
# ----------------------------------------------------------------------------
4444

4545
templated_files = gcp.CommonTemplates().py_library()
46-
s.move(templated_files / ".kokoro", excludes=["docs/**/*", "publish-docs.sh"])
46+
s.move(templated_files / ".kokoro")
4747
s.move(templated_files / "LICENSE")
4848
s.move(templated_files / "CONTRIBUTING.rst")
4949
s.move(templated_files / "*.md")

0 commit comments

Comments
 (0)