diff --git a/packages/grafeas/.gitignore b/packages/grafeas/.gitignore index b9daa52f118d..b4243ced74e4 100644 --- a/packages/grafeas/.gitignore +++ b/packages/grafeas/.gitignore @@ -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 diff --git a/packages/grafeas/.kokoro/build.sh b/packages/grafeas/.kokoro/build.sh index f1bee15a6537..70d037c5da3c 100755 --- a/packages/grafeas/.kokoro/build.sh +++ b/packages/grafeas/.kokoro/build.sh @@ -36,10 +36,20 @@ python3.6 -m pip uninstall --yes --quiet nox-automation python3.6 -m pip install --upgrade --quiet nox python3.6 -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 python3.6 -m nox -s "${NOX_SESSION:-}" else python3.6 -m nox -fi +fi \ No newline at end of file diff --git a/packages/grafeas/noxfile.py b/packages/grafeas/noxfile.py index c7768a840a89..17a096b37447 100644 --- a/packages/grafeas/noxfile.py +++ b/packages/grafeas/noxfile.py @@ -79,6 +79,7 @@ def default(session): session.run( "py.test", "--quiet", + f"--junitxml=unit_{session.python}_sponge_log.xml", "--cov=grafeas", "--cov=tests.unit", "--cov-append", @@ -127,9 +128,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, + ) @nox.session(python=DEFAULT_PYTHON_VERSION)