Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e2931af

Browse files
author
ace-n
committed
Take 2
1 parent 45c4854 commit e2931af

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

.kokoro/tests/run_tests.sh

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16+
# Only run Python 2.7 if the PR in question has a `kokoro-lite` label
17+
if [[ ! -z "$KOKORO_GITHUB_PULL_REQUEST_NUMBER" ]]; then
18+
set +e
19+
curl -s "https://api.github.com/repos/GoogleCloudPlatform/python-docs-samples/pulls/$KOKORO_GITHUB_PULL_REQUEST_NUMBER" \
20+
| grep "kokoro:lite" > /dev/null
21+
if [[ $? -eq 0 ]] && [[ "${RUN_TESTS_SESSION}" != "py-2.7" ]]; then
22+
# Skip this build
23+
echo "This build is being skipped!"
24+
echo " GitHub PRs with the 'kokoro:lite'"
25+
echo " label are ONLY tested in Python 2.7"
26+
27+
exit 1
28+
fi
29+
set -e
30+
fi
31+
1632
# `-e` enables the script to automatically fail when a command fails
1733
# `-o pipefail` sets the exit code to the rightmost comment to exit with a non-zero
1834
set -eo pipefail
@@ -51,20 +67,6 @@ if [[ $* == *--only-diff-head* ]]; then
5167
fi
5268
fi
5369

54-
# Only run Python 2.7 if the PR in question has a `kokoro-lite` label
55-
if [[ ! -z $KOKORO_GITHUB_PULL_REQUEST_NUMBER ]]; then
56-
curl -s "https://api.github.com/repos/GoogleCloudPlatform/python-docs-samples/pulls/$KOKORO_GITHUB_PULL_REQUEST_NUMBER" \
57-
| grep "kokoro:lite" > /dev/null
58-
if [[ $? -eq 0 ]] && [[ "${RUN_TESTS_SESSION}" != "py-2.7" ]]; then
59-
# Skip this build
60-
echo "This build is being skipped!"
61-
echo " GitHub PRs with the 'kokoro:lite'"
62-
echo " label are ONLY tested in Python 2.7"
63-
64-
exit 1
65-
fi
66-
fi
67-
6870
# Because Kokoro runs presubmit builds simalteneously, we often see
6971
# quota related errors. I think we can avoid this by changing the
7072
# order of tests to execute (e.g. reverse order for py-3.8

.kokoro/trampoline_v2.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,9 @@ docker_flags=(
418418
"--env" "KOKORO_GFILE_DIR=/secrets/gfile"
419419
"--volume" "${KOKORO_KEYSTORE_DIR:-/dev/shm}:/secrets/keystore"
420420
"--env" "KOKORO_KEYSTORE_DIR=/secrets/keystore"
421+
422+
# Pass down the GitHub pull request number
423+
"--env" "KOKORO_GITHUB_PULL_REQUEST_NUMBER=${KOKORO_GITHUB_PULL_REQUEST_NUMBER}"
421424
)
422425

423426
# Add an option for nicer output if the build gets a tty.

0 commit comments

Comments
 (0)