Skip to content

Commit d8d0606

Browse files
authored
build: fix kokoro docs-presubmit build (#685)
Fixes #682
1 parent cfd9e1f commit d8d0606

File tree

4 files changed

+96
-23
lines changed

4 files changed

+96
-23
lines changed

packages/google-cloud-ndb/.kokoro/build.sh

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,27 @@ export PYTHONUNBUFFERED=1
2727
# Debug: show build environment
2828
env | grep KOKORO
2929

30-
# Setup service account credentials.
31-
export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-account.json
30+
if [[ -f "${KOKORO_GFILE_DIR}/service-account.json" ]]; then
31+
# Setup service account credentials.
32+
export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-account.json
33+
fi
3234

3335
# Setup project id.
3436
export PROJECT_ID=$(cat "${KOKORO_GFILE_DIR}/project-id.json")
3537

36-
# Configure local Redis to be used
37-
export REDIS_CACHE_URL=redis://localhost
38-
redis-server &
38+
if [[ -f "${KOKORO_GFILE_DIR}/service-account.json" ]]; then
39+
# Configure local Redis to be used
40+
export REDIS_CACHE_URL=redis://localhost
41+
redis-server &
3942

40-
# Configure local memcached to be used
41-
export MEMCACHED_HOSTS=127.0.0.1
42-
service memcached start
43+
# Configure local memcached to be used
44+
export MEMCACHED_HOSTS=127.0.0.1
45+
service memcached start
4346

44-
# Some system tests require indexes. Use gcloud to create them.
45-
gcloud auth activate-service-account --key-file=$GOOGLE_APPLICATION_CREDENTIALS --project=$PROJECT_ID
46-
gcloud --quiet --verbosity=debug datastore indexes create tests/system/index.yaml
47+
# Some system tests require indexes. Use gcloud to create them.
48+
gcloud auth activate-service-account --key-file=$GOOGLE_APPLICATION_CREDENTIALS --project=$PROJECT_ID
49+
gcloud --quiet --verbosity=debug datastore indexes create tests/system/index.yaml
50+
fi
4751

4852

4953
# Remove old nox

packages/google-cloud-ndb/.kokoro/docs/docs-presubmit.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ env_vars: {
2424
# Only run this nox session.
2525
env_vars: {
2626
key: "NOX_SESSION"
27-
value: "docs docfx"
27+
value: "docs"
2828
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Copyright 2020 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+
# Template for .trampolinerc
16+
17+
# Add required env vars here.
18+
required_envvars+=(
19+
"STAGING_BUCKET"
20+
"V2_STAGING_BUCKET"
21+
)
22+
23+
# Add env vars which are passed down into the container here.
24+
pass_down_envvars+=(
25+
"STAGING_BUCKET"
26+
"V2_STAGING_BUCKET"
27+
"NOX_SESSION"
28+
)
29+
30+
# Prevent unintentional override on the default image.
31+
if [[ "${TRAMPOLINE_IMAGE_UPLOAD:-false}" == "true" ]] && \
32+
[[ -z "${TRAMPOLINE_IMAGE:-}" ]]; then
33+
echo "Please set TRAMPOLINE_IMAGE if you want to upload the Docker image."
34+
exit 1
35+
fi
36+
37+
# Define the default value if it makes sense.
38+
if [[ -z "${TRAMPOLINE_IMAGE_UPLOAD:-}" ]]; then
39+
TRAMPOLINE_IMAGE_UPLOAD=""
40+
fi
41+
42+
if [[ -z "${TRAMPOLINE_IMAGE:-}" ]]; then
43+
TRAMPOLINE_IMAGE=""
44+
fi
45+
46+
if [[ -z "${TRAMPOLINE_DOCKERFILE:-}" ]]; then
47+
TRAMPOLINE_DOCKERFILE=""
48+
fi
49+
50+
if [[ -z "${TRAMPOLINE_BUILD_FILE:-}" ]]; then
51+
TRAMPOLINE_BUILD_FILE=""
52+
fi

packages/google-cloud-ndb/owlbot.py

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,30 @@
2323

2424
s.replace(".kokoro/build.sh", """(export PROJECT_ID=.*)""", """\g<1>
2525
26-
# Configure local Redis to be used
27-
export REDIS_CACHE_URL=redis://localhost
28-
redis-server &
29-
30-
# Configure local memcached to be used
31-
export MEMCACHED_HOSTS=127.0.0.1
32-
service memcached start
33-
34-
# Some system tests require indexes. Use gcloud to create them.
35-
gcloud auth activate-service-account --key-file=$GOOGLE_APPLICATION_CREDENTIALS --project=$PROJECT_ID
36-
gcloud --quiet --verbosity=debug datastore indexes create tests/system/index.yaml
26+
if [[ -f "${KOKORO_GFILE_DIR}/service-account.json" ]]; then
27+
# Configure local Redis to be used
28+
export REDIS_CACHE_URL=redis://localhost
29+
redis-server &
30+
31+
# Configure local memcached to be used
32+
export MEMCACHED_HOSTS=127.0.0.1
33+
service memcached start
34+
35+
# Some system tests require indexes. Use gcloud to create them.
36+
gcloud auth activate-service-account --key-file=$GOOGLE_APPLICATION_CREDENTIALS --project=$PROJECT_ID
37+
gcloud --quiet --verbosity=debug datastore indexes create tests/system/index.yaml
38+
fi
3739
""")
3840

41+
s.replace(".kokoro/build.sh",
42+
"""# Setup service account credentials.
43+
export GOOGLE_APPLICATION_CREDENTIALS=\$\{KOKORO_GFILE_DIR\}/service-account.json""",
44+
"""if [[ -f "${KOKORO_GFILE_DIR}/service-account.json" ]]; then
45+
# Setup service account credentials.
46+
export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-account.json
47+
fi"""
48+
)
49+
3950
s.replace(
4051
".kokoro/docker/docs/Dockerfile",
4152
"libsqlite3-dev.*\n",
@@ -51,6 +62,12 @@
5162
"""
5263
)
5364

65+
assert 1 == s.replace(
66+
".kokoro/docs/docs-presubmit.cfg",
67+
'value: "docs docfx"',
68+
'value: "docs"',
69+
)
70+
5471
s.shell.run(["nox", "-s", "blacken"], hide_output=False)
5572

5673
# ----------------------------------------------------------------------------

0 commit comments

Comments
 (0)