11#! /bin/bash
2- # `-e` enables the script to automatically fail when a command fails
3- # `-o pipefail` sets the exit code to non-zero if any command fails,
4- # or zero if all commands in the pipeline exit successfully.
52set -eo pipefail
63
74# Disable buffering, so that the logs stream through.
@@ -13,40 +10,35 @@ export PYTHONUNBUFFERED=1
1310export PROJECT_ROOT=$( realpath " $( dirname " ${BASH_SOURCE[0]} " ) /../../.." )
1411cd " $PROJECT_ROOT "
1512
16- # This is needed in order for `git diff` to succeed
1713git config --global --add safe.directory " $( realpath .) "
1814
1915package_name=" bigframes"
2016package_path=" packages/${package_name} "
21-
22- # Determine if we should skip based on git diff
2317files_to_check=" ${package_path} "
2418
19+ # Use the IF block to handle the case where KOKORO vars are missing
20+ # (e.g. local testing)
2521if [[ -n " ${KOKORO_GITHUB_PULL_REQUEST_TARGET_BRANCH} " && -n " ${KOKORO_GITHUB_PULL_REQUEST_COMMIT} " ]]; then
2622 echo " checking changes with 'git diff ${KOKORO_GITHUB_PULL_REQUEST_TARGET_BRANCH} ...${KOKORO_GITHUB_PULL_REQUEST_COMMIT} -- ${files_to_check} '"
27- set +e
23+
2824 package_modified=$( git diff " ${KOKORO_GITHUB_PULL_REQUEST_TARGET_BRANCH} ...${KOKORO_GITHUB_PULL_REQUEST_COMMIT} " -- " ${files_to_check} " | wc -l)
29- set -e
3025else
26+ # If not a PR (like a local run or a different CI trigger),
27+ # we treat it as 0 so it falls through to the "continuous" check.
3128 package_modified=0
3229fi
3330
31+ # Check if modified OR if it's a continuous build
3432if [[ " ${package_modified} " -gt 0 || " $KOKORO_BUILD_ARTIFACTS_SUBDIR " == * " continuous" * ]]; then
3533 echo " ------------------------------------------------------------"
3634 echo " Running doctest for: ${package_name} "
3735 echo " ------------------------------------------------------------"
3836
39- # Ensure credentials are set for system tests in Kokoro
40- if [[ -z " ${GOOGLE_APPLICATION_CREDENTIALS} " && -f " ${KOKORO_GFILE_DIR} /service-account.json" ]]; then
41- export GOOGLE_APPLICATION_CREDENTIALS=" ${KOKORO_GFILE_DIR} /service-account.json"
42- fi
43-
4437 export GOOGLE_CLOUD_PROJECT=" bigframes-testing"
38+ export NOX_SESSION=(" cleanup" " doctest" )
39+
4540 cd " ${package_path} "
46-
47- python3 -m nox -s cleanup || echo " Warning: Cleanup session failed, proceeding to doctest."
48- python3 -m nox -s doctest
49- echo " DINOSAURS"
41+ python3 -m nox -s " ${nox_sessions[@]} "
5042else
5143 echo " No changes in ${package_name} and not a continuous build, skipping."
52- fi
44+ fi
0 commit comments