Skip to content

Commit e50c85b

Browse files
committed
chore: updates run_doctest script for clarity, and cleaner BASH
1 parent 05ec0d7 commit e50c85b

1 file changed

Lines changed: 10 additions & 18 deletions

File tree

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
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.
52
set -eo pipefail
63

74
# Disable buffering, so that the logs stream through.
@@ -13,40 +10,35 @@ export PYTHONUNBUFFERED=1
1310
export PROJECT_ROOT=$(realpath "$(dirname "${BASH_SOURCE[0]}")/../../..")
1411
cd "$PROJECT_ROOT"
1512

16-
# This is needed in order for `git diff` to succeed
1713
git config --global --add safe.directory "$(realpath .)"
1814

1915
package_name="bigframes"
2016
package_path="packages/${package_name}"
21-
22-
# Determine if we should skip based on git diff
2317
files_to_check="${package_path}"
2418

19+
# Use the IF block to handle the case where KOKORO vars are missing
20+
# (e.g. local testing)
2521
if [[ -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
3025
else
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
3229
fi
3330

31+
# Check if modified OR if it's a continuous build
3432
if [[ "${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[@]}"
5042
else
5143
echo "No changes in ${package_name} and not a continuous build, skipping."
52-
fi
44+
fi

0 commit comments

Comments
 (0)