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