Skip to content

Commit 00370d6

Browse files
authored
chore: Add kokoro automation config and scripts. (#13)
* fix!: Improve PyPI package name. * chore: Add kokoro automation config and scripts. * fix: Update publish docs config to use the correct package name. * fix: Update kokoro release config and script to use newer version of token keystore. * fix: Update release please config with the correct package name.
1 parent cd95f3e commit 00370d6

17 files changed

+1528
-2
lines changed

.github/release-please.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
# limitations under the License.
1414

1515
handleGHRelease: true
16-
packageName: genai-toolbox-langchain-python
17-
releaseType: python
16+
packageName: toolbox-langchain
17+
releaseType: python

.kokoro/build.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
# Copyright 2025 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+
if [[ -z "${PROJECT_ROOT:-}" ]]; then
19+
PROJECT_ROOT="github/genai-toolbox-langchain-python"
20+
fi
21+
22+
cd "${PROJECT_ROOT}"
23+
24+
# Disable buffering, so that the logs stream through.
25+
export PYTHONUNBUFFERED=1
26+
27+
# Debug: show build environment
28+
env | grep KOKORO
29+
30+
# Setup service account credentials.
31+
export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-account.json
32+
33+
# Setup project id.
34+
export PROJECT_ID=$(cat "${KOKORO_GFILE_DIR}/project-id.json")
35+
36+
# Remove old nox
37+
python3 -m pip uninstall --yes --quiet nox-automation
38+
39+
# Install nox
40+
python3 -m pip install --upgrade --quiet nox
41+
python3 -m nox --version
42+
43+
# If this is a continuous build, send the test log to the FlakyBot.
44+
# See https://github.com/googleapis/repo-automation-bots/tree/main/packages/flakybot.
45+
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]]; then
46+
cleanup() {
47+
chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot
48+
$KOKORO_GFILE_DIR/linux_amd64/flakybot
49+
}
50+
trap cleanup EXIT HUP
51+
fi
52+
53+
# If NOX_SESSION is set, it only runs the specified session,
54+
# otherwise run all the sessions.
55+
if [[ -n "${NOX_SESSION:-}" ]]; then
56+
python3 -m nox -s ${NOX_SESSION:-}
57+
else
58+
python3 -m nox
59+
fi

.kokoro/docker/docs/Dockerfile

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from ubuntu:22.04
16+
17+
ENV DEBIAN_FRONTEND noninteractive
18+
19+
# Ensure local Python is preferred over distribution Python.
20+
ENV PATH /usr/local/bin:$PATH
21+
22+
# Install dependencies.
23+
RUN apt-get update \
24+
&& apt-get install -y --no-install-recommends \
25+
apt-transport-https \
26+
build-essential \
27+
ca-certificates \
28+
curl \
29+
dirmngr \
30+
git \
31+
gpg-agent \
32+
graphviz \
33+
libbz2-dev \
34+
libdb5.3-dev \
35+
libexpat1-dev \
36+
libffi-dev \
37+
liblzma-dev \
38+
libreadline-dev \
39+
libsnappy-dev \
40+
libssl-dev \
41+
libsqlite3-dev \
42+
portaudio19-dev \
43+
python3-distutils \
44+
redis-server \
45+
software-properties-common \
46+
ssh \
47+
sudo \
48+
tcl \
49+
tcl-dev \
50+
tk \
51+
tk-dev \
52+
uuid-dev \
53+
wget \
54+
zlib1g-dev \
55+
&& add-apt-repository universe \
56+
&& apt-get update \
57+
&& apt-get -y install jq \
58+
&& apt-get clean autoclean \
59+
&& apt-get autoremove -y \
60+
&& rm -rf /var/lib/apt/lists/* \
61+
&& rm -f /var/cache/apt/archives/*.deb
62+
63+
ENV VERSION v4.2.0
64+
ENV BINARY yq_linux_amd64
65+
RUN wget https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY} -O /usr/bin/yq && \
66+
chmod +x /usr/bin/yq
67+
68+
###################### Install python 3.9.13
69+
70+
# Download python 3.9.13
71+
RUN wget https://www.python.org/ftp/python/3.9.13/Python-3.9.13.tgz
72+
73+
# Extract files
74+
RUN tar -xvf Python-3.9.13.tgz
75+
76+
# Install python 3.9.13
77+
RUN ./Python-3.9.13/configure --enable-optimizations
78+
RUN make altinstall
79+
80+
###################### Install pip
81+
RUN wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \
82+
&& python3 /tmp/get-pip.py \
83+
&& rm /tmp/get-pip.py
84+
85+
# Test pip
86+
RUN python3 -m pip
87+
88+
CMD ["python3.8"]

.kokoro/docker/docs/requirements.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nox

.kokoro/docker/docs/requirements.txt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#
2+
# This file is autogenerated by pip-compile with Python 3.11
3+
# by the following command:
4+
#
5+
# pip-compile --allow-unsafe --generate-hashes requirements.in
6+
#
7+
argcomplete==3.3.0 \
8+
--hash=sha256:c168c3723482c031df3c207d4ba8fa702717ccb9fc0bfe4117166c1f537b4a54 \
9+
--hash=sha256:fd03ff4a5b9e6580569d34b273f741e85cd9e072f3feeeee3eba4891c70eda62
10+
# via nox
11+
colorlog==6.8.2 \
12+
--hash=sha256:3e3e079a41feb5a1b64f978b5ea4f46040a94f11f0e8bbb8261e3dbbeca64d44 \
13+
--hash=sha256:4dcbb62368e2800cb3c5abd348da7e53f6c362dda502ec27c560b2e58a66bd33
14+
# via nox
15+
distlib==0.3.8 \
16+
--hash=sha256:034db59a0b96f8ca18035f36290806a9a6e6bd9d1ff91e45a7f172eb17e51784 \
17+
--hash=sha256:1530ea13e350031b6312d8580ddb6b27a104275a31106523b8f123787f494f64
18+
# via virtualenv
19+
filelock==3.13.4 \
20+
--hash=sha256:404e5e9253aa60ad457cae1be07c0f0ca90a63931200a47d9b6a6af84fd7b45f \
21+
--hash=sha256:d13f466618bfde72bd2c18255e269f72542c6e70e7bac83a0232d6b1cc5c8cf4
22+
# via virtualenv
23+
nox==2024.4.15 \
24+
--hash=sha256:6492236efa15a460ecb98e7b67562a28b70da006ab0be164e8821177577c0565 \
25+
--hash=sha256:ecf6700199cdfa9e5ea0a41ff5e6ef4641d09508eda6edb89d9987864115817f
26+
# via -r requirements.in
27+
packaging==24.0 \
28+
--hash=sha256:2ddfb553fdf02fb784c234c7ba6ccc288296ceabec964ad2eae3777778130bc5 \
29+
--hash=sha256:eb82c5e3e56209074766e6885bb04b8c38a0c015d0a30036ebe7ece34c9989e9
30+
# via nox
31+
platformdirs==4.2.1 \
32+
--hash=sha256:031cd18d4ec63ec53e82dceaac0417d218a6863f7745dfcc9efe7793b7039bdf \
33+
--hash=sha256:17d5a1161b3fd67b390023cb2d3b026bbd40abde6fdb052dfbd3a29c3ba22ee1
34+
# via virtualenv
35+
virtualenv==20.26.0 \
36+
--hash=sha256:0846377ea76e818daaa3e00a4365c018bc3ac9760cbb3544de542885aad61fb3 \
37+
--hash=sha256:ec25a9671a5102c8d2657f62792a27b48f016664c6873f6beed3800008577210
38+
# via nox

.kokoro/docs/common.cfg

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: "genai-toolbox-langchain-python/.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/genai-toolbox-langchain-python/.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"
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+
}

.kokoro/docs/docs-presubmit.cfg

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/genai-toolbox-langchain-python/.kokoro/build.sh"
22+
}
23+
24+
# Only run this nox session.
25+
env_vars: {
26+
key: "NOX_SESSION"
27+
value: "docs docfx"
28+
}

.kokoro/docs/docs.cfg

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

.kokoro/populate-secrets.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
# Copyright 2025 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+
function now { date +"%Y-%m-%d %H:%M:%S" | tr -d '\n' ;}
19+
function msg { println "$*" >&2 ;}
20+
function println { printf '%s\n' "$(now) $*" ;}
21+
22+
23+
# Populates requested secrets set in SECRET_MANAGER_KEYS from service account:
24+
# kokoro-trampoline@cloud-devrel-kokoro-resources.iam.gserviceaccount.com
25+
SECRET_LOCATION="${KOKORO_GFILE_DIR}/secret_manager"
26+
msg "Creating folder on disk for secrets: ${SECRET_LOCATION}"
27+
mkdir -p ${SECRET_LOCATION}
28+
for key in $(echo ${SECRET_MANAGER_KEYS} | sed "s/,/ /g")
29+
do
30+
msg "Retrieving secret ${key}"
31+
docker run --entrypoint=gcloud \
32+
--volume=${KOKORO_GFILE_DIR}:${KOKORO_GFILE_DIR} \
33+
gcr.io/google.com/cloudsdktool/cloud-sdk \
34+
secrets versions access latest \
35+
--project cloud-devrel-kokoro-resources \
36+
--secret ${key} > \
37+
"${SECRET_LOCATION}/${key}"
38+
if [[ $? == 0 ]]; then
39+
msg "Secret written to ${SECRET_LOCATION}/${key}"
40+
else
41+
msg "Error retrieving secret ${key}"
42+
fi
43+
done

0 commit comments

Comments
 (0)