Skip to content

Commit

Permalink
build(python): enable flakybot on library unit and system tests (#950)
Browse files Browse the repository at this point in the history
  • Loading branch information
busunkim96 authored Feb 17, 2021
1 parent 0973d57 commit d176743
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
4 changes: 3 additions & 1 deletion synthtool/gcp/templates/python_library/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ docs.metadata

# Virtual environment
env/

# Test logs
coverage.xml
sponge_log.xml
*sponge_log.xml

# System test environment variables.
system_tests/local_test_setup
Expand Down
10 changes: 10 additions & 0 deletions synthtool/gcp/templates/python_library/.kokoro/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ python3 -m pip uninstall --yes --quiet nox-automation
python3 -m pip install --upgrade --quiet nox
python3 -m nox --version

# If this is a continuous build, send the test log to the FlakyBot.
# See https://github.com/googleapis/repo-automation-bots/tree/master/packages/flakybot.
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]]; then
cleanup() {
chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot
$KOKORO_GFILE_DIR/linux_amd64/flakybot
}
trap cleanup EXIT HUP
fi

# If NOX_SESSION is set, it only runs the specified session,
# otherwise run all the sessions.
if [[ -n "${NOX_SESSION:-}" ]]; then
Expand Down
17 changes: 15 additions & 2 deletions synthtool/gcp/templates/python_library/noxfile.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def default(session):
session.run(
"py.test",
"--quiet",
f"--junitxml=unit_{session.python}_sponge_log.xml",
"--cov=google/cloud",
"--cov=tests/unit",
"--cov-append",
Expand Down Expand Up @@ -169,9 +170,21 @@ def system(session):

# Run py.test against the system tests.
if system_test_exists:
session.run("py.test", "--quiet", system_test_path, *session.posargs)
session.run(
"py.test",
"--quiet",
f"--junitxml=system_{session.python}_sponge_log.xml",
system_test_path,
*session.posargs
)
if system_test_folder_exists:
session.run("py.test", "--quiet", system_test_folder_path, *session.posargs)
session.run(
"py.test",
"--quiet",
f"--junitxml=system_{session.python}_sponge_log.xml",
system_test_folder_path,
*session.posargs
)

{% if samples_test %}
@nox.session(python=["2.7", "3.7"])
Expand Down

0 comments on commit d176743

Please sign in to comment.