From bbe5d83eb8f452915bbe3dd603922890ea54b25c Mon Sep 17 00:00:00 2001 From: Philipp Moritz Date: Tue, 17 Dec 2019 17:33:33 -0800 Subject: [PATCH] Windows CI for Ray on github actions (#6519) * Windows CI for Ray * Update main.yml * Does this work? * Download Bazel to current directory * Install required packages via Chocolatey * Improve the Windows CI script --- .bazelrc | 10 ++-- .github/workflows/main.yml | 97 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/main.yml diff --git a/.bazelrc b/.bazelrc index 1dcb8f1f2..2fc26dd44 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,5 +1,6 @@ -# build config -build --compilation_mode=opt +# Must be first. Enables build:windows, build:linux, build:macos, build:freebsd, build:openbsd +build --enable_platform_specific_config +############################################################################### build --action_env=BAZEL_LLVM build --action_env=BAZEL_SH build --action_env=PATH @@ -7,8 +8,9 @@ build --action_env=PYTHON2_BIN_PATH build --action_env=PYTHON3_BIN_PATH # Use Clang-Cl (Clang front-end with Visual C++ backend) on Windows build --action_env=USE_CLANG_CL=1 -# Enable build:windows, build:linux, build:macos, build:freebsd -build --enable_platform_specific_config +build:linux --compilation_mode=opt +build:macos --compilation_mode=opt +build:windows --compilation_mode=fastbuild # TODO(mehrdadn): Revert the "-\\.(asm|S)$" exclusion when this Bazel bug # for compiling assembly files is fixed on Windows: # https://github.com/bazelbuild/bazel/issues/8924 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..199a7e711 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,97 @@ +name: CI + +on: [push] + +jobs: + build: + name: ${{ matrix.name }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + # Github Actions requires a single row to be added to the build matrix. + # See https://help.github.com/en/articles/workflow-syntax-for-github-actions. + name: [ + windows-clang-cl, + ] + include: + - name: windows-clang-cl + os: windows-latest + compiler: clang-cl + steps: + - name: Install Bazel + shell: bash + run: | + if [ "${OSTYPE}" = "msys" ]; then + choco install --no-progress bazel + fi + - name: Install C/C++ toolchains + if: matrix.compiler == 'clang' || matrix.compiler == 'clang-cl' + shell: bash + run: | + if [ "${OSTYPE}" = "msys" ]; then + choco install --no-progress llvm + elif 1>&- command -v pacman; then + sudo pacman -S --needed --noconfirm --noprogressbar clang + elif 1>&- command -v apt-get; then + sudo apt-get -q -y install clang + fi + - name: Install MSYS2 (only needed if some shell commands are missing) + if: false && runner.os == 'Windows' + uses: numworks/setup-msys2@v1 + with: + update: false + - name: Checkout repository + uses: actions/checkout@v1 + with: + fetch-depth: 1 + - name: Perform build + shell: bash + run: | + set -euo pipefail + main() { + if [ "${OSTYPE}" = "msys" ]; then + export MSYS2_ARG_CONV_EXCL="*" # Don't let MSYS2 attempt to auto-translate arguments that look like paths + local latest_python_bin="" + for latest_python_bin in /proc/registry/HKEY_LOCAL_MACHINE/Software/Python/PythonCore/*/InstallPath/@; do + if [ -f "${latest_python_bin}" ]; then + latest_python_bin="$(tr -d '\0' < "${latest_python_bin}")" + latest_python_bin="${latest_python_bin}\\" + else + latest_python_bin="" + fi + done + latest_python_bin="${latest_python_bin}python.exe" + if [ -f "${latest_python_bin}" ]; then + export PYTHON2_BIN_PATH="${latest_python_bin}" PYTHON3_BIN_PATH="${latest_python_bin}" + fi + fi + # NOTE: Only options that are _user preferences_ (i.e. not repository-specific) should go here. + # These are options that people may disagree on having on their own machines, but which are useful for our builds. + bazel_output_root="${HOME}/bazel" + if [ "${OSTYPE}" = "msys" ]; then + bazel_output_root="$(cygpath -w -- "${bazel_output_root}")" + fi + local startflags=() + startflags+=(--batch) + startflags+=(--nodeep_execroot) + #startflags+=(--output_user_root="${bazel_output_root}") + local cmdflags=() + cmdflags+=(--attempt_to_print_relative_paths) + cmdflags+=(--color=yes) + cmdflags+=(--experimental_repository_cache_hardlinks) + cmdflags+=(--experimental_ui_deduplicate) + cmdflags+=(--incompatible_strict_action_env) + cmdflags+=(--keep_going) + cmdflags+=(--per_file_copt="-\\.(asm|S)$@-fansi-escape-codes") + cmdflags+=(--per_file_copt="-\\.(asm|S)$@-fcolor-diagnostics") + cmdflags+=(--show_progress_rate_limit=5) + cmdflags+=(--show_task_finish) + cmdflags+=(--show_timestamps) + cmdflags+=(--symlink_prefix=/) + cmdflags+=(--verbose_failures) + local packages=() + packages+=("//:ray_pkg") + bazel "${startflags[@]}" build "${cmdflags[@]}" "${packages[@]}" "$@" + } + main "$@"