Yoshi Automation Bot | c482712 | 2020-05-29 15:23:49 -0700 | [diff] [blame] | 1 | #!/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 Bot | 17c8516 | 2021-03-20 03:56:07 -0700 | [diff] [blame] | 16 | # 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 Bot | c482712 | 2020-05-29 15:23:49 -0700 | [diff] [blame] | 20 | |
| 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 |
| 23 | set -eo pipefail |
| 24 | # Enables `**` to include files nested inside sub-folders |
| 25 | shopt -s globstar |
| 26 | |
| 27 | cd github/google-api-python-client |
| 28 | |
| 29 | # Run periodic samples tests at latest release |
| 30 | if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then |
Yoshi Automation Bot | 17c8516 | 2021-03-20 03:56:07 -0700 | [diff] [blame] | 31 | # 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 Bot | c482712 | 2020-05-29 15:23:49 -0700 | [diff] [blame] | 35 | LATEST_RELEASE=$(git describe --abbrev=0 --tags) |
| 36 | git checkout $LATEST_RELEASE |
Yoshi Automation Bot | 17c8516 | 2021-03-20 03:56:07 -0700 | [diff] [blame] | 37 | 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 Bot | c482712 | 2020-05-29 15:23:49 -0700 | [diff] [blame] | 43 | fi |
Yoshi Automation Bot | 17c8516 | 2021-03-20 03:56:07 -0700 | [diff] [blame] | 44 | fi |
Yoshi Automation Bot | c482712 | 2020-05-29 15:23:49 -0700 | [diff] [blame] | 45 | |
Yoshi Automation Bot | 17c8516 | 2021-03-20 03:56:07 -0700 | [diff] [blame] | 46 | exec .kokoro/test-samples-impl.sh |