blob: ffd5da96823a14f5c76f13b103a45fb06c8c56f8 [file] [log] [blame]
Bu Sun Kim3d177a82018-10-25 13:49:26 -07001#!/bin/bash
Bu Sun Kimf706cfd2020-04-20 14:05:05 -07002# Copyright 2018 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.
Bu Sun Kim3d177a82018-10-25 13:49:26 -070015
16set -eo pipefail
17
Yoshi Automation Bot4576f022021-01-18 02:34:02 -080018if [[ -z "${PROJECT_ROOT:-}" ]]; then
19 PROJECT_ROOT="github/google-api-python-client"
20fi
21
22cd "${PROJECT_ROOT}"
Bu Sun Kim3d177a82018-10-25 13:49:26 -070023
24# Disable buffering, so that the logs stream through.
25export PYTHONUNBUFFERED=1
26
Bu Sun Kimf706cfd2020-04-20 14:05:05 -070027# Debug: show build environment
28env | grep KOKORO
Bu Sun Kim3d177a82018-10-25 13:49:26 -070029
Bu Sun Kimf706cfd2020-04-20 14:05:05 -070030# 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# Remove old nox
Yoshi Automation Bot4576f022021-01-18 02:34:02 -080037python3 -m pip uninstall --yes --quiet nox-automation
Bu Sun Kimf706cfd2020-04-20 14:05:05 -070038
39# Install nox
Yoshi Automation Bot4576f022021-01-18 02:34:02 -080040python3 -m pip install --upgrade --quiet nox
41python3 -m nox --version
Bu Sun Kimf706cfd2020-04-20 14:05:05 -070042
Anthonios Partheniou1b1171d2021-03-10 14:52:03 -050043# If this is a continuous build, send the test log to the FlakyBot.
44# See https://github.com/googleapis/repo-automation-bots/tree/master/packages/flakybot.
45if [[ $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
51fi
52
Bu Sun Kim673ec5c2020-11-16 11:05:03 -070053# If NOX_SESSION is set, it only runs the specified session,
54# otherwise run all the sessions.
55if [[ -n "${NOX_SESSION:-}" ]]; then
Yoshi Automation Bot4576f022021-01-18 02:34:02 -080056 python3 -m nox -s ${NOX_SESSION:-}
Bu Sun Kim673ec5c2020-11-16 11:05:03 -070057else
Yoshi Automation Bot4576f022021-01-18 02:34:02 -080058 python3 -m nox
Bu Sun Kim673ec5c2020-11-16 11:05:03 -070059fi