Skip to content

Commit

Permalink
Validate Bazel uses correct Python version
Browse files Browse the repository at this point in the history
Signed-off-by: Cade Daniel <cade@anyscale.com>
  • Loading branch information
cadedaniel committed Jun 27, 2023
1 parent 7aa1d54 commit 1f5867e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ci/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -743,10 +743,13 @@ build() {
}

run_minimal_test() {
EXPECTED_PYTHON_VERSION=$1
BAZEL_EXPORT_OPTIONS="$(./ci/run/bazel_export_options)"
# Ignoring shellcheck is necessary because if ${BAZEL_EXPORT_OPTIONS} is wrapped by the double quotation,
# bazel test cannot recognize the option.
# shellcheck disable=SC2086
bazel test --test_output=streamed --config=ci --test_env=RAY_MINIMAL=1 --test_env=EXPECTED_PYTHON_VERSION=$EXPECTED_PYTHON_VERSION ${BAZEL_EXPORT_OPTIONS} python/ray/tests/test_minimal_install
# shellcheck disable=SC2086
bazel test --test_output=streamed --config=ci --test_env=RAY_MINIMAL=1 ${BAZEL_EXPORT_OPTIONS} python/ray/tests/test_basic
# shellcheck disable=SC2086
bazel test --test_output=streamed --config=ci --test_env=RAY_MINIMAL=1 --test_env=TEST_EXTERNAL_REDIS=1 ${BAZEL_EXPORT_OPTIONS} python/ray/tests/test_basic
Expand Down
1 change: 1 addition & 0 deletions python/ray/tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ py_test_module_list(
"test_metrics_agent_2.py",
"test_microbenchmarks.py",
"test_mini.py",
"test_minimal_install.py",
"test_numba.py",
"test_redis_tls.py",
"test_raylet_output.py",
Expand Down
26 changes: 26 additions & 0 deletions python/ray/tests/test_minimal_install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# coding: utf-8
"""
Tests that are specific to minimal installations.
"""

import pytest
import os
import sys

@pytest.mark.skipif(os.environ.get("RAY_MINIMAL", "0") != "1", reason="Skip unless running in a minimal install.")
def test_correct_python_version():
"""
Validate that Bazel uses the correct Python version in our minimal tests.
"""
expected_python_version = os.environ.get("EXPECTED_PYTHON_VERSION", '').strip()
assert expected_python_version, f"EXPECTED_PYTHON_VERSION is {expected_python_version=}"

actual_major, actual_minor = sys.version_info[:2]
actual_version = f"{actual_major}.{actual_minor}"
assert actual_version == expected_python_version, f"{expected_python_version=} {actual_version=}"

if __name__ == "__main__":
if os.environ.get("PARALLEL_CI"):
sys.exit(pytest.main(["-n", "auto", "--boxed", "-vs", __file__]))
else:
sys.exit(pytest.main(["-sv", __file__]))

0 comments on commit 1f5867e

Please sign in to comment.