Skip to content

Commit 16bc5b4

Browse files
committed
Make sure to use the latest supported Python version in macOS Pip tests
Also fix `bazelisk query` to obtain the KMS targets. PiperOrigin-RevId: 861850422 Change-Id: I3f616fb992ffd372a6a532d414078572390ab8aa (cherry picked from commit aea2d46)
1 parent ca799af commit 16bc5b4

File tree

2 files changed

+36
-13
lines changed

2 files changed

+36
-13
lines changed

kokoro/macos_external/pip/run_tests.sh

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ fi
3232
# Sourcing required to update callers environment.
3333
source ./kokoro/testutils/install_protoc.sh "30.2"
3434

35+
# Make sure we use the latest supported Python version.
36+
eval "$(pyenv init -)"
37+
pyenv install -s 3.13
38+
pyenv shell 3.13
39+
3540
./kokoro/testutils/install_tink_via_pip.sh "$(pwd)"
3641

3742
CACHE_FLAGS=()
@@ -45,20 +50,25 @@ readonly CACHE_FLAGS
4550
# testing/helper.py will look for testdata in TINK_PYTHON_ROOT_PATH/testdata.
4651
export TINK_PYTHON_ROOT_PATH="$(pwd)"
4752

48-
./kokoro/testutils/copy_credentials.sh "testdata" "all"
49-
./kokoro/testutils/copy_credentials.sh "examples/testdata" "gcp"
50-
5153
echo "---------- RUNNING TEST WITH PYTHON ($(date))"
5254
find tink/ -not -path "*integration/*" -type f -name "*_test.py" -print0 \
5355
| xargs -t -0 -n1 python3
5456

5557
cd examples
5658

57-
echo "--------- tests_pip_install_tink tests"
58-
TARGETS=$(bazel query 'attr(tags, tests_pip_install_tink, ...) except attr(tags, requires_kms, ...)')
59+
# We are running bash scripts that use the local python3 toolchain to run tests
60+
# against the locally installed tink-py. These are `sh_test` targets and we
61+
# run them with `bazelisk test` because it is more convenient.
62+
63+
# Intall test requirements for the local python3 toolchain.
64+
python3 -m pip install --require-hashes --no-deps -r requirements.txt
65+
66+
echo "--------- EXAMPLE TARGETS (tests_pip_install_tink, not requires_kms)"
67+
TARGETS=$(bazelisk query 'attr(tags, tests_pip_install_tink, ...) except attr(tags, requires_kms, ...)')
5968
echo "${TARGETS}"
6069

61-
echo "---------- BUILDING KMS Specific tests ($(date))"
70+
echo "---------- BUILDING EXAMPLES ($(date))"
6271
bazelisk build "${CACHE_FLAGS[@]}" -- $TARGETS
63-
echo "---------- TESTING KMS Specific tests ($(date))"
64-
bazelisk test "${CACHE_FLAGS[@]}" -- $TARGETS
72+
echo "---------- TESTING EXAMPLES ($(date))"
73+
bazelisk test "${CACHE_FLAGS[@]}" \
74+
--test_env=PYENV_VERSION="${PYENV_VERSION}" -- $TARGETS

kokoro/macos_external/pip_kms/run_tests.sh

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ fi
3131
# Sourcing required to update callers environment.
3232
source ./kokoro/testutils/install_protoc.sh "30.2"
3333

34+
# Make sure we use the latest supported Python version.
35+
eval "$(pyenv init -)"
36+
pyenv install -s 3.13
37+
pyenv shell 3.13
38+
3439
./kokoro/testutils/install_tink_via_pip.sh -a "$(pwd)"
3540
source ./kokoro/testutils/install_vault.sh
3641
source ./kokoro/testutils/run_hcvault_test_server.sh
@@ -55,11 +60,19 @@ find tink/ -type f -name "*_test.py" -print0 | xargs -t -0 -n1 python3
5560

5661
cd examples
5762

58-
echo "--------- tests_pip_install_tink tests"
59-
TARGETS=$(bazel query 'attr(tags, tests_pip_install_tink, ...) except attr(tags, requires_kms, ...)')
63+
# We are running bash scripts that use the local python3 toolchain to run tests
64+
# against the locally installed tink-py. These are `sh_test` targets and we
65+
# run them with `bazelisk test` because it is more convenient.
66+
67+
# Intall test requirements for the local python3 toolchain.
68+
python3 -m pip install --require-hashes --no-deps -r requirements.txt
69+
70+
echo "--------- EXAMPLE TARGETS (tests_pip_install_tink, not requires_kms)"
71+
TARGETS=$(bazelisk query 'attr(tags, tests_pip_install_tink, attr(tags, requires_kms, ...))')
6072
echo "${TARGETS}"
6173

62-
echo "---------- BUILDING KMS Specific tests ($(date))"
74+
echo "---------- BUILDING EXAMPLES ($(date))"
6375
bazelisk build "${CACHE_FLAGS[@]}" -- $TARGETS
64-
echo "---------- TESTING KMS Specific tests ($(date))"
65-
bazelisk test "${CACHE_FLAGS[@]}" -- $TARGETS
76+
echo "---------- TESTING EXAMPLES ($(date))"
77+
bazelisk test "${CACHE_FLAGS[@]}" \
78+
--test_env=PYENV_VERSION="${PYENV_VERSION}" -- $TARGETS

0 commit comments

Comments
 (0)