Skip to content

Commit

Permalink
build: fix kokoro docs-presubmit build (googleapis#685)
Browse files Browse the repository at this point in the history
  • Loading branch information
parthea authored Sep 15, 2021
1 parent be931e5 commit edcb6e7
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 23 deletions.
26 changes: 15 additions & 11 deletions .kokoro/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,27 @@ export PYTHONUNBUFFERED=1
# Debug: show build environment
env | grep KOKORO

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

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

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

# Configure local memcached to be used
export MEMCACHED_HOSTS=127.0.0.1
service memcached start
# Configure local memcached to be used
export MEMCACHED_HOSTS=127.0.0.1
service memcached start

# Some system tests require indexes. Use gcloud to create them.
gcloud auth activate-service-account --key-file=$GOOGLE_APPLICATION_CREDENTIALS --project=$PROJECT_ID
gcloud --quiet --verbosity=debug datastore indexes create tests/system/index.yaml
# Some system tests require indexes. Use gcloud to create them.
gcloud auth activate-service-account --key-file=$GOOGLE_APPLICATION_CREDENTIALS --project=$PROJECT_ID
gcloud --quiet --verbosity=debug datastore indexes create tests/system/index.yaml
fi


# Remove old nox
Expand Down
2 changes: 1 addition & 1 deletion .kokoro/docs/docs-presubmit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ env_vars: {
# Only run this nox session.
env_vars: {
key: "NOX_SESSION"
value: "docs docfx"
value: "docs"
}
52 changes: 52 additions & 0 deletions .trampolinerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Template for .trampolinerc

# Add required env vars here.
required_envvars+=(
"STAGING_BUCKET"
"V2_STAGING_BUCKET"
)

# Add env vars which are passed down into the container here.
pass_down_envvars+=(
"STAGING_BUCKET"
"V2_STAGING_BUCKET"
"NOX_SESSION"
)

# Prevent unintentional override on the default image.
if [[ "${TRAMPOLINE_IMAGE_UPLOAD:-false}" == "true" ]] && \
[[ -z "${TRAMPOLINE_IMAGE:-}" ]]; then
echo "Please set TRAMPOLINE_IMAGE if you want to upload the Docker image."
exit 1
fi

# Define the default value if it makes sense.
if [[ -z "${TRAMPOLINE_IMAGE_UPLOAD:-}" ]]; then
TRAMPOLINE_IMAGE_UPLOAD=""
fi

if [[ -z "${TRAMPOLINE_IMAGE:-}" ]]; then
TRAMPOLINE_IMAGE=""
fi

if [[ -z "${TRAMPOLINE_DOCKERFILE:-}" ]]; then
TRAMPOLINE_DOCKERFILE=""
fi

if [[ -z "${TRAMPOLINE_BUILD_FILE:-}" ]]; then
TRAMPOLINE_BUILD_FILE=""
fi
39 changes: 28 additions & 11 deletions owlbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,30 @@

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

s.replace(".kokoro/build.sh",
"""# Setup service account credentials.
export GOOGLE_APPLICATION_CREDENTIALS=\$\{KOKORO_GFILE_DIR\}/service-account.json""",
"""if [[ -f "${KOKORO_GFILE_DIR}/service-account.json" ]]; then
# Setup service account credentials.
export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-account.json
fi"""
)

s.replace(
".kokoro/docker/docs/Dockerfile",
"libsqlite3-dev.*\n",
Expand All @@ -51,6 +62,12 @@
"""
)

assert 1 == s.replace(
".kokoro/docs/docs-presubmit.cfg",
'value: "docs docfx"',
'value: "docs"',
)

s.shell.run(["nox", "-s", "blacken"], hide_output=False)

# ----------------------------------------------------------------------------
Expand Down

0 comments on commit edcb6e7

Please sign in to comment.