blob: a76aaf5888c516c2cf7b2370336f7d17fc01ad4c [file] [log] [blame]
Yoshi Automation Botc4827122020-05-29 15:23:49 -07001#!/bin/bash
2# Copyright 2020 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
Yoshi Automation Bot17c85162021-03-20 03:56:07 -070016# The default test runner for samples.
17#
18# For periodic builds, we rewinds the repo to the latest release, and
19# run test-samples-impl.sh.
Yoshi Automation Botc4827122020-05-29 15:23:49 -070020
21# `-e` enables the script to automatically fail when a command fails
22# `-o pipefail` sets the exit code to the rightmost comment to exit with a non-zero
23set -eo pipefail
24# Enables `**` to include files nested inside sub-folders
25shopt -s globstar
26
27cd github/google-api-python-client
28
29# Run periodic samples tests at latest release
30if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then
Yoshi Automation Bot17c85162021-03-20 03:56:07 -070031 # preserving the test runner implementation.
32 cp .kokoro/test-samples-impl.sh "${TMPDIR}/test-samples-impl.sh"
33 echo "--- IMPORTANT IMPORTANT IMPORTANT ---"
34 echo "Now we rewind the repo back to the latest release..."
Yoshi Automation Botc4827122020-05-29 15:23:49 -070035 LATEST_RELEASE=$(git describe --abbrev=0 --tags)
36 git checkout $LATEST_RELEASE
Yoshi Automation Bot17c85162021-03-20 03:56:07 -070037 echo "The current head is: "
38 echo $(git rev-parse --verify HEAD)
39 echo "--- IMPORTANT IMPORTANT IMPORTANT ---"
40 # move back the test runner implementation if there's no file.
41 if [ ! -f .kokoro/test-samples-impl.sh ]; then
42 cp "${TMPDIR}/test-samples-impl.sh" .kokoro/test-samples-impl.sh
Yoshi Automation Botc4827122020-05-29 15:23:49 -070043 fi
Yoshi Automation Bot17c85162021-03-20 03:56:07 -070044fi
Yoshi Automation Botc4827122020-05-29 15:23:49 -070045
Yoshi Automation Bot17c85162021-03-20 03:56:07 -070046exec .kokoro/test-samples-impl.sh