ci.sh 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. #!/usr/bin/env bash
  2. # Push caller's shell options (quietly)
  3. { SHELLOPTS_STACK="${SHELLOPTS_STACK-}|$(set +o); set -$-"; } 2> /dev/null
  4. set -eo pipefail
  5. if [ -z "${TRAVIS_PULL_REQUEST-}" ] || [ -n "${OSTYPE##darwin*}" ]; then set -ux; fi
  6. ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE:-$0}")"; pwd)"
  7. WORKSPACE_DIR="${ROOT_DIR}/.."
  8. suppress_output() {
  9. "${WORKSPACE_DIR}"/ci/suppress_output "$@"
  10. }
  11. keep_alive() {
  12. "${WORKSPACE_DIR}"/ci/keep_alive "$@"
  13. }
  14. # Calls the provided command with set -x temporarily suppressed
  15. suppress_xtrace() {
  16. {
  17. local restore_shell_state=""
  18. if [ -o xtrace ]; then set +x; restore_shell_state="set -x"; fi
  19. } 2> /dev/null
  20. local status=0
  21. "$@" || status=$?
  22. ${restore_shell_state}
  23. { return "${status}"; } 2> /dev/null
  24. }
  25. # Idempotent environment loading
  26. reload_env() {
  27. # Try to only modify CI-specific environment variables here (TRAVIS_... or GITHUB_...),
  28. # e.g. for CI cross-compatibility.
  29. # Normal environment variables should be set up at software installation time, not here.
  30. if [ -n "${GITHUB_PULL_REQUEST-}" ]; then
  31. case "${GITHUB_PULL_REQUEST}" in
  32. [1-9]*) TRAVIS_PULL_REQUEST="${GITHUB_PULL_REQUEST}";;
  33. *) TRAVIS_PULL_REQUEST=false;;
  34. esac
  35. export TRAVIS_PULL_REQUEST
  36. fi
  37. if [ "${GITHUB_ACTIONS-}" = true ] && [ -z "${TRAVIS_BRANCH-}" ]; then
  38. # Define TRAVIS_BRANCH to make Travis scripts run on GitHub Actions.
  39. TRAVIS_BRANCH="${GITHUB_BASE_REF:-${GITHUB_REF}}" # For pull requests, the base branch name
  40. TRAVIS_BRANCH="${TRAVIS_BRANCH#refs/heads/}" # Remove refs/... prefix
  41. # TODO(mehrdadn): Make TRAVIS_BRANCH be a named ref (e.g. 'master') like it's supposed to be.
  42. # For now we use a hash because GitHub Actions doesn't clone refs the same way as Travis does.
  43. TRAVIS_BRANCH="${GITHUB_HEAD_SHA:-${TRAVIS_BRANCH}}"
  44. export TRAVIS_BRANCH
  45. fi
  46. }
  47. _need_wheels() {
  48. local result="false"
  49. case "${OSTYPE}" in
  50. linux*) if [[ "${LINUX_WHEELS-}" == "1" ]]; then result="true"; fi;;
  51. darwin*) if [[ "${MAC_WHEELS-}" == "1" ]]; then result="true"; fi;;
  52. msys*) if [[ "${WINDOWS_WHEELS-}" == "1" ]]; then result="true"; fi;;
  53. esac
  54. echo "${result}"
  55. }
  56. NEED_WHEELS="$(_need_wheels)"
  57. compile_pip_dependencies() {
  58. # Compile boundaries
  59. TARGET="${1-requirements_compiled.txt}"
  60. if [[ "${HOSTTYPE}" == "aarch64" || "${HOSTTYPE}" = "arm64" ]]; then
  61. # Resolution currently does not work on aarch64 as some pinned packages
  62. # are not available. Once they are reasonably upgraded we should be able
  63. # to enable this here.p
  64. echo "Skipping for aarch64"
  65. return 0
  66. fi
  67. echo "Target file: $TARGET"
  68. # shellcheck disable=SC2262
  69. alias pip="python -m pip"
  70. pip install pip-tools
  71. # Required packages to lookup e.g. dragonfly-opt
  72. HAS_TORCH=0
  73. python -c "import torch" 2>/dev/null && HAS_TORCH=1
  74. pip install --no-cache-dir numpy torch
  75. pip-compile --verbose --resolver=backtracking \
  76. --pip-args --no-deps --strip-extras --no-header -o \
  77. "${WORKSPACE_DIR}/python/$TARGET" \
  78. "${WORKSPACE_DIR}/python/requirements.txt" \
  79. "${WORKSPACE_DIR}/python/requirements/lint-requirements.txt" \
  80. "${WORKSPACE_DIR}/python/requirements/test-requirements.txt" \
  81. "${WORKSPACE_DIR}/python/requirements/anyscale-requirements.txt" \
  82. "${WORKSPACE_DIR}/python/requirements/docker/ray-docker-requirements.txt" \
  83. "${WORKSPACE_DIR}/python/requirements/ml/core-requirements.txt" \
  84. "${WORKSPACE_DIR}/python/requirements/ml/data-requirements.txt" \
  85. "${WORKSPACE_DIR}/python/requirements/ml/data-test-requirements.txt" \
  86. "${WORKSPACE_DIR}/python/requirements/ml/dl-cpu-requirements.txt" \
  87. "${WORKSPACE_DIR}/python/requirements/ml/rllib-requirements.txt" \
  88. "${WORKSPACE_DIR}/python/requirements/ml/rllib-test-requirements.txt" \
  89. "${WORKSPACE_DIR}/python/requirements/ml/train-requirements.txt" \
  90. "${WORKSPACE_DIR}/python/requirements/ml/train-test-requirements.txt" \
  91. "${WORKSPACE_DIR}/python/requirements/ml/tune-requirements.txt" \
  92. "${WORKSPACE_DIR}/python/requirements/ml/tune-test-requirements.txt" \
  93. "${WORKSPACE_DIR}/python/requirements/security-requirements.txt"
  94. # Remove some pins from upstream dependencies: ray
  95. sed -i "/^ray==/d" "${WORKSPACE_DIR}/python/$TARGET"
  96. # Delete local installation
  97. sed -i "/@ file/d" "${WORKSPACE_DIR}/python/$TARGET"
  98. # Remove +cpu and +pt20cpu suffixes e.g. for torch dependencies
  99. # This is needed because we specify the requirements as torch==version, but
  100. # the resolver adds the device-specific version tag. If this is not removed,
  101. # pip install will complain about irresolvable constraints.
  102. sed -i -E 's/==([\.0-9]+)\+[^\b]*cpu/==\1/g' "${WORKSPACE_DIR}/python/$TARGET"
  103. cat "${WORKSPACE_DIR}/python/$TARGET"
  104. if [ "$HAS_TORCH" -eq 0 ]; then
  105. pip uninstall -y torch
  106. fi
  107. }
  108. test_core() {
  109. local args=(
  110. "//:*" "//src/..."
  111. )
  112. case "${OSTYPE}" in
  113. msys)
  114. args+=(
  115. -//src/ray/util/tests:event_test
  116. -//:gcs_server_rpc_test
  117. -//src/ray/common/test:ray_syncer_test # TODO (iycheng): it's flaky on windows. Add it back once we figure out the cause
  118. -//:gcs_health_check_manager_test
  119. -//:gcs_client_reconnection_test
  120. )
  121. ;;
  122. esac
  123. BAZEL_EXPORT_OPTIONS=($(./ci/run/bazel_export_options))
  124. bazel test --config=ci --build_tests_only "${BAZEL_EXPORT_OPTIONS[@]}" -- "${args[@]}"
  125. }
  126. # For running Serve tests on Windows.
  127. test_serve() {
  128. if [ "${OSTYPE}" = msys ]; then
  129. args+=(
  130. python/ray/serve/...
  131. -python/ray/serve/tests:test_cross_language # Ray java not built on Windows yet.
  132. -python/ray/serve/tests:test_gcs_failure # Fork not supported in windows
  133. -python/ray/serve/tests:test_standalone_2 # Multinode not supported on Windows
  134. -python/ray/serve/tests:test_gradio
  135. -python/ray/serve/tests:test_fastapi
  136. )
  137. fi
  138. if [ 0 -lt "${#args[@]}" ]; then # Any targets to test?
  139. install_ray
  140. # Shard the args.
  141. BUILDKITE_PARALLEL_JOB=${BUILDKITE_PARALLEL_JOB:-'0'}
  142. BUILDKITE_PARALLEL_JOB_COUNT=${BUILDKITE_PARALLEL_JOB_COUNT:-'1'}
  143. TEST_SELECTION=($(python ./ci/ray_ci/bazel_sharding.py --exclude_manual --index "${BUILDKITE_PARALLEL_JOB}" --count "${BUILDKITE_PARALLEL_JOB_COUNT}" "${args[@]}"))
  144. BAZEL_EXPORT_OPTIONS=($(./ci/run/bazel_export_options))
  145. bazel test --config=ci \
  146. --build_tests_only "${BAZEL_EXPORT_OPTIONS[@]}" \
  147. --test_env=CI="1" \
  148. --test_env=RAY_CI_POST_WHEEL_TESTS="1" \
  149. --test_env=USERPROFILE="${USERPROFILE}" \
  150. --test_output=streamed \
  151. -- "${TEST_SELECTION[@]}"
  152. fi
  153. }
  154. # For running Python tests on Windows (excluding Serve).
  155. test_python() {
  156. if [ "${OSTYPE}" = msys ]; then
  157. args+=(
  158. python/ray/tests/...
  159. -python/ray/tests:test_actor_advanced # crashes in shutdown
  160. -python/ray/tests:test_autoscaler # We don't support Autoscaler on Windows
  161. -python/ray/tests:test_autoscaler_aws
  162. -python/ray/tests:test_cli
  163. -python/ray/tests:test_client_init # timeout
  164. -python/ray/tests:test_command_runner # We don't support Autoscaler on Windows
  165. -python/ray/tests:test_gcp_tpu_command_runner # We don't support Autoscaler on Windows
  166. -python/ray/tests:test_gcs_fault_tolerance # flaky
  167. -python/ray/tests:test_global_gc
  168. -python/ray/tests:test_job
  169. -python/ray/tests:test_memstat
  170. -python/ray/tests:test_multi_node_3
  171. -python/ray/tests:test_object_manager # OOM on test_object_directory_basic
  172. -python/ray/tests:test_resource_demand_scheduler
  173. -python/ray/tests:test_stress # timeout
  174. -python/ray/tests:test_stress_sharded # timeout
  175. -python/ray/tests:test_tracing # tracing not enabled on windows
  176. -python/ray/tests:kuberay/test_autoscaling_e2e # irrelevant on windows
  177. -python/ray/tests:vsphere/test_vsphere_node_provider # irrelevant on windows
  178. -python/ray/tests:vsphere/test_vsphere_sdk_provider # irrelevant on windows
  179. -python/ray/tests/xgboost/... # Requires ML dependencies, should not be run on Windows
  180. -python/ray/tests/lightgbm/... # Requires ML dependencies, should not be run on Windows
  181. -python/ray/tests/horovod/... # Requires ML dependencies, should not be run on Windows
  182. -python/ray/tests:test_batch_node_provider_unit.py # irrelevant on windows
  183. -python/ray/tests:test_batch_node_provider_integration.py # irrelevant on windows
  184. )
  185. fi
  186. if [ 0 -lt "${#args[@]}" ]; then # Any targets to test?
  187. install_ray
  188. # Shard the args.
  189. BUILDKITE_PARALLEL_JOB=${BUILDKITE_PARALLEL_JOB:-'0'}
  190. BUILDKITE_PARALLEL_JOB_COUNT=${BUILDKITE_PARALLEL_JOB_COUNT:-'1'}
  191. TEST_SELECTION=($(python ./ci/ray_ci/bazel_sharding.py --exclude_manual --index "${BUILDKITE_PARALLEL_JOB}" --count "${BUILDKITE_PARALLEL_JOB_COUNT}" "${args[@]}"))
  192. BAZEL_EXPORT_OPTIONS=($(./ci/run/bazel_export_options))
  193. bazel test --config=ci \
  194. --build_tests_only "${BAZEL_EXPORT_OPTIONS[@]}" \
  195. --test_env=CI="1" \
  196. --test_env=RAY_CI_POST_WHEEL_TESTS="1" \
  197. --test_env=USERPROFILE="${USERPROFILE}" \
  198. --test_output=streamed \
  199. -- "${TEST_SELECTION[@]}"
  200. fi
  201. }
  202. # For running Python tests on Windows (excluding Serve).
  203. test_train_windows() {
  204. if [ "${OSTYPE}" = msys ]; then
  205. args+=(
  206. python/ray/train:test_windows
  207. )
  208. fi
  209. if [ 0 -lt "${#args[@]}" ]; then # Any targets to test?
  210. install_ray
  211. # Shard the args.
  212. BUILDKITE_PARALLEL_JOB=${BUILDKITE_PARALLEL_JOB:-'0'}
  213. BUILDKITE_PARALLEL_JOB_COUNT=${BUILDKITE_PARALLEL_JOB_COUNT:-'1'}
  214. TEST_SELECTION=($(python ./ci/ray_ci/bazel_sharding.py --exclude_manual --index "${BUILDKITE_PARALLEL_JOB}" --count "${BUILDKITE_PARALLEL_JOB_COUNT}" "${args[@]}"))
  215. BAZEL_EXPORT_OPTIONS=($(./ci/run/bazel_export_options))
  216. bazel test --config=ci \
  217. --build_tests_only "${BAZEL_EXPORT_OPTIONS[@]}" \
  218. --test_env=CI="1" \
  219. --test_env=RAY_CI_POST_WHEEL_TESTS="1" \
  220. --test_env=USERPROFILE="${USERPROFILE}" \
  221. --test_output=streamed \
  222. -- "${TEST_SELECTION[@]}"
  223. fi
  224. }
  225. # For running large Python tests on Linux and MacOS.
  226. test_large() {
  227. BAZEL_EXPORT_OPTIONS=($(./ci/run/bazel_export_options))
  228. bazel test --config=ci "${BAZEL_EXPORT_OPTIONS[@]}" --test_env=CONDA_EXE --test_env=CONDA_PYTHON_EXE \
  229. --test_env=CONDA_SHLVL --test_env=CONDA_PREFIX --test_env=CONDA_DEFAULT_ENV --test_env=CONDA_PROMPT_MODIFIER \
  230. --test_env=CI --test_tag_filters="large_size_python_tests_shard_${BUILDKITE_PARALLEL_JOB}" "$@" \
  231. -- python/ray/tests/...
  232. }
  233. test_cpp() {
  234. # C++ worker example need _GLIBCXX_USE_CXX11_ABI flag, but if we put the flag into .bazelrc, the linux ci can't pass.
  235. # So only set the flag in c++ worker example. More details: https://github.com/ray-project/ray/pull/18273
  236. echo build --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" >> ~/.bazelrc
  237. bazel build --config=ci //cpp:all
  238. BAZEL_EXPORT_OPTIONS=($(./ci/run/bazel_export_options))
  239. bazel test --config=ci "${BAZEL_EXPORT_OPTIONS[@]}" --test_strategy=exclusive //cpp:all --build_tests_only
  240. # run cluster mode test with external cluster
  241. bazel test //cpp:cluster_mode_test --test_arg=--external_cluster=true --test_arg=--redis_password="1234" \
  242. --test_arg=--ray_redis_password="1234"
  243. bazel test --test_output=all //cpp:test_python_call_cpp
  244. # run the cpp example, currently does not work on mac
  245. if [[ "${OSTYPE}" != darwin* ]]; then
  246. rm -rf ray-template
  247. ray cpp --generate-bazel-project-template-to ray-template
  248. pushd ray-template && bash run.sh
  249. fi
  250. }
  251. test_wheels() {
  252. local TEST_WHEEL_RESULT=0
  253. "${WORKSPACE_DIR}"/ci/build/test-wheels.sh || TEST_WHEEL_RESULT=$?
  254. if [[ "${TEST_WHEEL_RESULT}" != 0 ]]; then
  255. cat -- /tmp/ray/session_latest/logs/* || true
  256. sleep 60 # Explicitly sleep 60 seconds for logs to go through
  257. fi
  258. return "${TEST_WHEEL_RESULT}"
  259. }
  260. install_npm_project() {
  261. if [ "${OSTYPE}" = msys ]; then
  262. # Not Windows-compatible: https://github.com/npm/cli/issues/558#issuecomment-584673763
  263. { echo "WARNING: Skipping NPM due to module incompatibilities with Windows"; } 2> /dev/null
  264. else
  265. npm ci
  266. fi
  267. }
  268. build_dashboard_front_end() {
  269. if [ "${OSTYPE}" = msys ]; then
  270. { echo "WARNING: Skipping dashboard due to NPM incompatibilities with Windows"; } 2> /dev/null
  271. elif [ "${NO_DASHBOARD-}" = "1" ]; then
  272. echo "Skipping dashboard build"
  273. else
  274. (
  275. cd ray/dashboard/client
  276. # skip nvm activation on buildkite linux instances.
  277. if [ -z "${BUILDKITE-}" ] || [[ "${OSTYPE}" != linux* ]]; then
  278. set +x # suppress set -x since it'll get very noisy here
  279. . "${HOME}/.nvm/nvm.sh"
  280. NODE_VERSION="14"
  281. nvm install $NODE_VERSION
  282. nvm use --silent $NODE_VERSION
  283. fi
  284. install_npm_project
  285. npm run build
  286. )
  287. fi
  288. }
  289. build_sphinx_docs() {
  290. install_ray
  291. (
  292. cd "${WORKSPACE_DIR}"/doc
  293. if [ "${OSTYPE}" = msys ]; then
  294. echo "WARNING: Documentation not built on Windows due to currently-unresolved issues"
  295. else
  296. make html
  297. pip install datasets==2.0.0
  298. fi
  299. )
  300. }
  301. check_sphinx_links() {
  302. (
  303. cd "${WORKSPACE_DIR}"/doc
  304. if [ "${OSTYPE}" = msys ]; then
  305. echo "WARNING: Documentation not built on Windows due to currently-unresolved issues"
  306. else
  307. make linkcheck
  308. fi
  309. )
  310. }
  311. _bazel_build_before_install() {
  312. local target
  313. if [ "${OSTYPE}" = msys ]; then
  314. target="//:ray_pkg"
  315. else
  316. # Just build Python on other platforms.
  317. # This because pip install captures & suppresses the build output, which causes a timeout on CI.
  318. target="//:ray_pkg"
  319. fi
  320. # NOTE: Do not add build flags here. Use .bazelrc and --config instead.
  321. if [ -z "${RAY_DEBUG_BUILD-}" ]; then
  322. bazel build "${target}"
  323. elif [ "${RAY_DEBUG_BUILD}" = "asan" ]; then
  324. # bazel build --config asan "${target}"
  325. echo "Not needed"
  326. elif [ "${RAY_DEBUG_BUILD}" = "debug" ]; then
  327. bazel build --config debug "${target}"
  328. else
  329. echo "Invalid config given"
  330. exit 1
  331. fi
  332. }
  333. install_ray() {
  334. # TODO(mehrdadn): This function should be unified with the one in python/build-wheel-windows.sh.
  335. (
  336. cd "${WORKSPACE_DIR}"/python
  337. build_dashboard_front_end
  338. keep_alive pip install -v -e .
  339. )
  340. (
  341. # For runtime_env tests, wheels are needed
  342. cd "${WORKSPACE_DIR}"
  343. keep_alive pip wheel -e python -w .whl
  344. )
  345. }
  346. validate_wheels_commit_str() {
  347. if [ "${OSTYPE}" = msys ]; then
  348. echo "Windows builds do not set the commit string, skipping wheel commit validity check."
  349. return 0
  350. fi
  351. if [ -n "${BUILDKITE_COMMIT}" ]; then
  352. EXPECTED_COMMIT=${BUILDKITE_COMMIT:-}
  353. else
  354. EXPECTED_COMMIT=${TRAVIS_COMMIT:-}
  355. fi
  356. if [ -z "$EXPECTED_COMMIT" ]; then
  357. echo "Could not validate expected wheel commits: TRAVIS_COMMIT is empty."
  358. return 0
  359. fi
  360. for whl in .whl/*.whl; do
  361. basename=${whl##*/}
  362. if [[ "$basename" =~ "_cpp" ]]; then
  363. # cpp wheels cannot be checked this way
  364. echo "Skipping CPP wheel ${basename} for wheel commit validation."
  365. continue
  366. fi
  367. WHL_COMMIT=$(unzip -p "$whl" "*ray/_version.py" | grep "^commit" | awk -F'"' '{print $2}')
  368. if [ "${WHL_COMMIT}" != "${EXPECTED_COMMIT}" ]; then
  369. echo "Wheel ${basename} has incorrect commit: (${WHL_COMMIT}) is not expected commit (${EXPECTED_COMMIT}). Aborting."
  370. exit 1
  371. fi
  372. echo "Wheel ${basename} has the correct commit: ${WHL_COMMIT}"
  373. done
  374. echo "All wheels passed the sanity check and have the correct wheel commit set."
  375. }
  376. build_wheels_and_jars() {
  377. _bazel_build_before_install
  378. # Create wheel output directory and empty contents
  379. # If buildkite runners are re-used, wheels from previous builds might be here, so we delete them.
  380. mkdir -p .whl
  381. rm -rf .whl/* || true
  382. case "${OSTYPE}" in
  383. linux*)
  384. # Mount bazel cache dir to the docker container.
  385. # For the linux wheel build, we use a shared cache between all
  386. # wheels, but not between different travis runs, because that
  387. # caused timeouts in the past. See the "cache: false" line below.
  388. local MOUNT_BAZEL_CACHE=(
  389. -e "TRAVIS=true"
  390. -e "TRAVIS_PULL_REQUEST=${TRAVIS_PULL_REQUEST:-false}"
  391. -e "TRAVIS_COMMIT=${TRAVIS_COMMIT}"
  392. -e "CI=${CI}"
  393. -e "RAY_INSTALL_JAVA=${RAY_INSTALL_JAVA:-1}"
  394. -e "BUILDKITE=${BUILDKITE:-}"
  395. -e "BUILDKITE_PULL_REQUEST=${BUILDKITE_PULL_REQUEST:-}"
  396. -e "BUILDKITE_BAZEL_CACHE_URL=${BUILDKITE_BAZEL_CACHE_URL:-}"
  397. -e "RAY_DEBUG_BUILD=${RAY_DEBUG_BUILD:-}"
  398. -e "BUILD_ONE_PYTHON_ONLY=${BUILD_ONE_PYTHON_ONLY:-}"
  399. )
  400. IMAGE_NAME="quay.io/pypa/manylinux2014_${HOSTTYPE}"
  401. IMAGE_TAG="2022-12-20-b4884d9"
  402. local MOUNT_ENV=()
  403. if [[ "${LINUX_JARS-}" == "1" ]]; then
  404. MOUNT_ENV+=(-e "BUILD_JAR=1")
  405. fi
  406. if [[ -z "${BUILDKITE-}" ]]; then
  407. # This command should be kept in sync with ray/python/README-building-wheels.md,
  408. # except the "${MOUNT_BAZEL_CACHE[@]}" part.
  409. docker run --rm -w /ray -v "${PWD}":/ray "${MOUNT_BAZEL_CACHE[@]}" \
  410. "${MOUNT_ENV[@]}" "${IMAGE_NAME}:${IMAGE_TAG}" /ray/python/build-wheel-manylinux2014.sh
  411. else
  412. rm -rf /ray-mount/*
  413. rm -rf /ray-mount/.whl || true
  414. rm -rf /ray/.whl || true
  415. cp -rT /ray /ray-mount
  416. ls -a /ray-mount
  417. docker run --rm -w /ray -v /ray:/ray "${MOUNT_BAZEL_CACHE[@]}" \
  418. "${MOUNT_ENV[@]}" "${IMAGE_NAME}:${IMAGE_TAG}" /ray/python/build-wheel-manylinux2014.sh
  419. cp -rT /ray-mount /ray # copy new files back here
  420. find . | grep whl # testing
  421. # Sync the directory to buildkite artifacts
  422. rm -rf /artifact-mount/.whl || true
  423. if [ "${UPLOAD_WHEELS_AS_ARTIFACTS-}" = "1" ]; then
  424. cp -r .whl /artifact-mount/.whl
  425. chmod -R 777 /artifact-mount/.whl
  426. fi
  427. validate_wheels_commit_str
  428. fi
  429. ;;
  430. darwin*)
  431. # This command should be kept in sync with ray/python/README-building-wheels.md.
  432. "${WORKSPACE_DIR}"/python/build-wheel-macos.sh
  433. mkdir -p /tmp/artifacts/.whl
  434. rm -rf /tmp/artifacts/.whl || true
  435. if [[ "${UPLOAD_WHEELS_AS_ARTIFACTS-}" == "1" ]]; then
  436. cp -r .whl /tmp/artifacts/.whl
  437. chmod -R 777 /tmp/artifacts/.whl
  438. fi
  439. validate_wheels_commit_str
  440. ;;
  441. msys*)
  442. keep_alive "${WORKSPACE_DIR}"/python/build-wheel-windows.sh
  443. ;;
  444. esac
  445. }
  446. configure_system() {
  447. git config --global advice.detachedHead false
  448. git config --global core.askpass ""
  449. git config --global credential.helper ""
  450. git config --global credential.modalprompt false
  451. # Requests library need root certificates.
  452. if [[ "${OSTYPE}" == "msys" ]]; then
  453. certutil -generateSSTFromWU roots.sst && certutil -addstore -f root roots.sst && rm roots.sst
  454. fi
  455. }
  456. # Initializes the environment for the current job. Performs the following tasks:
  457. # - Calls 'exit 0' in this job step and all subsequent steps to quickly exit if provided a list of
  458. # job names and none of them has been triggered.
  459. # - Sets variables to indicate the job names that have been triggered.
  460. # Note: Please avoid exporting these variables. Instead, source any callees that need to use them.
  461. # This helps reduce implicit coupling of callees to their parents, as they will be unable to run
  462. # when not sourced, (especially with set -u).
  463. # - Installs dependencies for the current job.
  464. # - Exports any environment variables necessary to run the build.
  465. # Usage: init [JOB_NAMES]
  466. # - JOB_NAMES (optional): Comma-separated list of job names to trigger on.
  467. init() {
  468. configure_system
  469. "${ROOT_DIR}/env/install-dependencies.sh"
  470. }
  471. build() {
  472. if [[ "${NEED_WHEELS}" == "true" ]]; then
  473. build_wheels_and_jars
  474. return
  475. fi
  476. # Build and install ray into the system.
  477. # For building the wheel, see build_wheels_and_jars.
  478. _bazel_build_before_install
  479. install_ray
  480. }
  481. run_minimal_test() {
  482. EXPECTED_PYTHON_VERSION="$1"
  483. BAZEL_EXPORT_OPTIONS=($(./ci/run/bazel_export_options))
  484. 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
  485. bazel test --test_output=streamed --config=ci --test_env=RAY_MINIMAL=1 "${BAZEL_EXPORT_OPTIONS[@]}" python/ray/tests/test_basic
  486. 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
  487. bazel test --test_output=streamed --config=ci "${BAZEL_EXPORT_OPTIONS[@]}" python/ray/tests/test_basic_2
  488. 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_2
  489. bazel test --test_output=streamed --config=ci "${BAZEL_EXPORT_OPTIONS[@]}" python/ray/tests/test_basic_3
  490. 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_3
  491. bazel test --test_output=streamed --config=ci "${BAZEL_EXPORT_OPTIONS[@]}" python/ray/tests/test_basic_4
  492. 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_4
  493. bazel test --test_output=streamed --config=ci "${BAZEL_EXPORT_OPTIONS[@]}" python/ray/tests/test_basic_5
  494. 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_5
  495. bazel test --test_output=streamed --config=ci --test_env=RAY_MINIMAL=1 "${BAZEL_EXPORT_OPTIONS[@]}" python/ray/tests/test_output
  496. bazel test --test_output=streamed --config=ci --test_env=RAY_MINIMAL=1 "${BAZEL_EXPORT_OPTIONS[@]}" python/ray/tests/test_runtime_env_ray_minimal
  497. bazel test --test_output=streamed --config=ci "${BAZEL_EXPORT_OPTIONS[@]}" python/ray/tests/test_utils
  498. bazel test --test_output=streamed --config=ci --test_env=RAY_MINIMAL=1 "${BAZEL_EXPORT_OPTIONS[@]}" python/ray/tests/test_serve_ray_minimal
  499. bazel test --test_output=streamed --config=ci --test_env=RAY_MINIMAL=1 "${BAZEL_EXPORT_OPTIONS[@]}" python/ray/dashboard/test_dashboard
  500. bazel test --test_output=streamed --config=ci --test_env=RAY_MINIMAL=1 "${BAZEL_EXPORT_OPTIONS[@]}" python/ray/tests/test_usage_stats
  501. 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_usage_stats
  502. }
  503. test_minimal() {
  504. ./ci/env/install-minimal.sh "$1"
  505. echo "Installed minimal dependencies."
  506. ./ci/env/env_info.sh
  507. python ./ci/env/check_minimal_install.py --expected-python-version "$1"
  508. run_minimal_test "$1"
  509. }
  510. test_latest_core_dependencies() {
  511. ./ci/env/install-minimal.sh "$1"
  512. echo "Installed minimal dependencies."
  513. ./ci/env/env_info.sh
  514. ./ci/env/install-core-prerelease-dependencies.sh
  515. echo "Installed Core prerelease dependencies."
  516. ./ci/env/env_info.sh
  517. run_minimal_test "$1"
  518. }
  519. _main() {
  520. if [ "${GITHUB_ACTIONS-}" = true ]; then
  521. exec 2>&1 # Merge stdout and stderr to prevent out-of-order buffering issues
  522. reload_env
  523. fi
  524. "$@"
  525. }
  526. _main "$@"
  527. # Pop caller's shell options (quietly)
  528. { set -vx; eval "${SHELLOPTS_STACK##*|}"; SHELLOPTS_STACK="${SHELLOPTS_STACK%|*}"; } 2> /dev/null