From fed76306d908f4fe30434d02026c19ea04b00db2 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Thu, 24 Mar 2022 20:23:53 +0100 Subject: [PATCH] ci: improve stability of windows bazel CI job (#45431) Improves stability of the Windows Bazel CI job by installing Bazelisk globally. Also makes the environment helpers more convenient by evaluating the variable assignments directly, simplifying some Bash logic. PR Close #45431 --- .circleci/config.yml | 10 ++++++++-- .circleci/env-helpers.inc.sh | 5 ++++- .circleci/env.sh | 8 -------- .circleci/env.windows.sh | 6 ++++++ 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4aca316f1ad..484d3541747 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -715,15 +715,21 @@ jobs: - *cache_key_win - *cache_key_win_fallback + # Install project dependencies, and install Bazelisk globally. This is necessary as + # Windows might error when `bazel` is invoked from the project node modules. The Bazel + # invocation might modify the symlinked project `node_modules` again, causing failures. - yarn_install + - run: yarn global add @bazel/bazelisk@${BAZELISK_VERSION} - run: name: Build all windows CI targets - command: yarn bazel build //packages/compiler-cli/... + command: | + $(yarn global bin)/bazelisk build //packages/compiler-cli/... no_output_timeout: 15m - run: name: Test all windows CI targets - command: yarn bazel test --test_tag_filters="-browser:chromium-local" //packages/compiler-cli/... + command: | + $(yarn global bin)/bazelisk test --test_tag_filters="-browser:chromium-local" //packages/compiler-cli/... no_output_timeout: 15m - save_cache: diff --git a/.circleci/env-helpers.inc.sh b/.circleci/env-helpers.inc.sh index 5fa1263e112..a51f67c7d8b 100644 --- a/.circleci/env-helpers.inc.sh +++ b/.circleci/env-helpers.inc.sh @@ -31,7 +31,10 @@ function setSecretVar() { local -r originalShellOptions=$(set +o); set +x -eu -o pipefail; - echo "export $1=\"${2:-}\";" >> $BASH_ENV; + local assignmentStatement="export $1=\"${2:-}\";" + + echo "${assignmentStatement}" >> $BASH_ENV; + eval "${assignmentStatement}" # Restore original shell options. eval "$originalShellOptions"; diff --git a/.circleci/env.sh b/.circleci/env.sh index 7972ae532ac..6543b62b2de 100755 --- a/.circleci/env.sh +++ b/.circleci/env.sh @@ -91,14 +91,6 @@ echo "export CI_REPO_NAME=\"${CI_REPO_NAME}\";" >> $bazelVarEnv echo "export CI_REPO_OWNER=\"${CI_REPO_OWNER}\";" >> $bazelVarEnv echo "export CI_SECRET_PAYLOAD_FIREBASE_TOKEN=\"${CI_SECRET_PAYLOAD_FIREBASE_TOKEN}\";" >> $bazelVarEnv -#################################################################################################### -#################################################################################################### -## Source `$BASH_ENV` to make the variables available immediately. ## -## ***NOTE: This must remain the last variable definition in this script*** ## -#################################################################################################### -#################################################################################################### -source $BASH_ENV; - #################################################################################################### # Platform-specific environment setup (which can leverage the base variables from here) #################################################################################################### diff --git a/.circleci/env.windows.sh b/.circleci/env.windows.sh index 79a6571747d..891c4f7067d 100755 --- a/.circleci/env.windows.sh +++ b/.circleci/env.windows.sh @@ -9,3 +9,9 @@ openssl aes-256-cbc -d -in "${PROJECT_ROOT}/.circleci/gcp_token" \ # Set bazel configuration for CircleCI runs. #################################################################################################### cp "${PROJECT_ROOT}/.circleci/bazel.windows.rc" "${USERPROFILE}/.bazelrc"; + + +# Expose the Bazelisk version. We need to run Bazelisk globally since Windows has problems launching +# Bazel from a node modules directoy that might be modified by the Bazel Yarn install then. +setPublicVar BAZELISK_VERSION \ + "$(cd ${PROJECT_ROOT}; node -p 'require("./package.json").devDependencies["@bazel/bazelisk"]')" \ No newline at end of file