• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
16set -eo pipefail
17
18if [[ -z "${PROJECT_ROOT:-}" ]]; then
19    PROJECT_ROOT="github/python-api-core"
20fi
21
22cd "${PROJECT_ROOT}"
23
24# Disable buffering, so that the logs stream through.
25export PYTHONUNBUFFERED=1
26
27# Debug: show build environment
28env | grep KOKORO
29
30# Setup service account credentials.
31export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-account.json
32
33# Setup project id.
34export PROJECT_ID=$(cat "${KOKORO_GFILE_DIR}/project-id.json")
35
36# If this is a continuous build, send the test log to the FlakyBot.
37# See https://github.com/googleapis/repo-automation-bots/tree/main/packages/flakybot.
38if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]]; then
39  cleanup() {
40    chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot
41    $KOKORO_GFILE_DIR/linux_amd64/flakybot
42  }
43  trap cleanup EXIT HUP
44fi
45
46# If NOX_SESSION is set, it only runs the specified session,
47# otherwise run all the sessions.
48if [[ -n "${NOX_SESSION:-}" ]]; then
49    python3 -m nox -s ${NOX_SESSION:-}
50else
51    python3 -m nox
52fi
53