ray/ci
mehrdadn b14728d999
Shellcheck quoting (#9596)
* Fix SC2006: Use $(...) notation instead of legacy backticked `...`.

* Fix SC2016: Expressions don't expand in single quotes, use double quotes for that.

* Fix SC2046: Quote this to prevent word splitting.

* Fix SC2053: Quote the right-hand side of == in [[ ]] to prevent glob matching.

* Fix SC2068: Double quote array expansions to avoid re-splitting elements.

* Fix SC2086: Double quote to prevent globbing and word splitting.

* Fix SC2102: Ranges can only match single chars (mentioned due to duplicates).

* Fix SC2140: Word is of the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"?

* Fix SC2145: Argument mixes string and array. Use * or separate argument.

* Fix SC2209: warning: Use var=$(command) to assign output (or quote to assign string).

Co-authored-by: Mehrdad <noreply@github.com>
2020-07-21 21:56:41 -05:00
..
asan_tests Shellcheck quoting (#9596) 2020-07-21 21:56:41 -05:00
jenkins_tests Shellcheck quoting (#9596) 2020-07-21 21:56:41 -05:00
long_running_distributed_tests [Testing] Multi-node Training+Tune Long Running Test (#8966) 2020-06-22 14:49:16 -07:00
long_running_tests [serve] Rename to Controller (#9566) 2020-07-20 12:50:29 -07:00
microbenchmark/ray-project 0.8.5 Release change. (#8358) 2020-05-28 09:37:19 -07:00
performance_tests Change Python's ObjectID to ObjectRef (#9353) 2020-07-10 17:49:04 +08:00
regression_test Shellcheck comments (#9595) 2020-07-21 16:47:09 -05:00
travis Shellcheck quoting (#9596) 2020-07-21 21:56:41 -05:00
keep_alive Shellcheck quoting (#9596) 2020-07-21 21:56:41 -05:00
README.md Various CI fixes and cleanup (#8289) 2020-05-05 10:47:49 -07:00
suppress_output Shellcheck quoting (#9596) 2020-07-21 21:56:41 -05:00

CI process

This document is a work-in-progress. Please double-check file/function/etc. names for changes, as this document may be out of sync.

Dependencies

All dependencies (e.g. apt, pip) should be installed in install_dependencies(), following the same pattern as those that already exist.

Once a dependency is added/removed, please ensure that shell environment variables are persisted appropriately, as CI systems differ on when ~/.bashrc et al. are reloaded, if at all. (And they are not necessarily idempotent.)

Bazel, environment variables, and caching

Any environment variables passed to Bazel actions (e.g. PATH) should be idempotent to hit the Bazel cache.

If a different PATH gets passed to a Bazel action, Bazel will not hit the cache, and you might trigger a full rebuild when you really expect an incremental (or no-op) build for an option (say pip install -e . after bazel build //...).

Invocation

The CI system (such as Travis) must source (not execute) ci/travis/ci.sh and pass the action(s) to execute. The script either handles the work or dispatches it to other script(s) as it deems appropriate. This helps ensure any environment setup/teardown is handled appropriately.

Development best practices & pitfalls (read before adding a new script)

Before adding new scripts, please read this section.

First, please consider modifying an existing script instead (e.g. add your code as a separate function). Adding new scripts has a number of pitfalls that easily take hours (even days) to track down and fix:

  • When calling other scripts (as executables), environment variables (like PATH) cannot propagate back up to the caller. Often, the caller expects such variables to be updated.

  • When sourcing other scripts, global state (ROOT_DIR, main, set -e, etc.) may be overwritten silently, causing unexpected behavior.

The following practices can avoid such pitfalls while maintaining intuitive control flow:

  • Put all environment-modifying functions in the top-level shell script, so that their invocation behaves intuitively. (The sheer length of the script is a secondary concern and can be mitigated by keeping functions modular.)

  • Avoid adding new scripts if possible. If it's necessary that you do so, call them instead of sourcing them. Note that thies implies new scripts should not modify the environment, or the caller will not see such changes!

  • Always add code inside a function, not at global scope. Use local for variables where it makes sense. However, be careful and know the shell rules: for example, e.g. local x=$(false) succeeds even under set -e.

Ultimately, it's best to only add new scripts if they might need to be executed directly by non-CI code, as in that case, they should probably not use CI entrypoints (which assume exclusive control over the machine).