mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
8d7fd91a67
For quite some time now, since we started to use Bazel for integration tests, we relied on some size tracking logic that did not actually fully work under Bazel. It was thought that all the necessary CI push/PR information is available to the Bazel test, but that was not the case. This was now fixed with the recent Rules NodeJS v5 update where I made sure the `env.sh` variables are actually available before we write them to the temporary file for the Bazel-access. This now will unveil an issue because payload size goldens would start being based on their branch name. e.g. the golden key in `13.3.x` should not be `master` but `13.3.x`. This makes more sense than `master` as key, but makes things more cumbersome and ideally we would not store the branch name at all (this is a larger change though -- not worth now since we might refactor this anyway). For now we will update the size tracking logic to always use `master` as golden key (like it worked in the past year(s)) With the environment fix we now (again) start uploading payload size results to Firebase. This did not work by accident either. The uploading logic is reliant on the CircleCI commit range which is not working/reliable in upstream branches. This commit removes this reliance on `COMMIT_RANGE` since it's not strictly necessary and currently breaking renovate PRs. We can re-enable this when we have a solution with CircleCI, or a workaround/resolution logic provided in e.g. `ng-dev ci determine-commit-range`. PR Close #45444
104 lines
5.9 KiB
Bash
Executable File
104 lines
5.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# Variables
|
|
readonly projectDir=$(realpath "$(dirname ${BASH_SOURCE[0]})/..")
|
|
readonly envHelpersPath="$projectDir/.circleci/env-helpers.inc.sh";
|
|
|
|
# Load helpers and make them available everywhere (through `$BASH_ENV`).
|
|
source $envHelpersPath;
|
|
echo "source $envHelpersPath;" >> $BASH_ENV;
|
|
|
|
|
|
####################################################################################################
|
|
# Define PUBLIC environment variables for CircleCI.
|
|
####################################################################################################
|
|
# See https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables for more info.
|
|
####################################################################################################
|
|
setPublicVar CI "$CI"
|
|
setPublicVar PROJECT_ROOT "$projectDir";
|
|
setPublicVar CI_AIO_MIN_PWA_SCORE "95";
|
|
# This is the branch being built; e.g. `pull/12345` for PR builds.
|
|
setPublicVar CI_BRANCH "$CIRCLE_BRANCH";
|
|
setPublicVar CI_BUILD_URL "$CIRCLE_BUILD_URL";
|
|
setPublicVar CI_COMMIT "$CIRCLE_SHA1";
|
|
# `CI_COMMIT_RANGE` is only used on push builds (a.k.a. non-PR, non-scheduled builds and rerun
|
|
# workflows of such builds).
|
|
setPublicVar CI_GIT_BASE_REVISION "${CIRCLE_GIT_BASE_REVISION}";
|
|
setPublicVar CI_GIT_REVISION "${CIRCLE_GIT_REVISION}";
|
|
setPublicVar CI_COMMIT_RANGE "$CIRCLE_GIT_BASE_REVISION..$CIRCLE_GIT_REVISION";
|
|
setPublicVar CI_PULL_REQUEST "${CIRCLE_PR_NUMBER:-false}";
|
|
setPublicVar CI_REPO_NAME "$CIRCLE_PROJECT_REPONAME";
|
|
setPublicVar CI_REPO_OWNER "$CIRCLE_PROJECT_USERNAME";
|
|
setPublicVar CI_PR_REPONAME "$CIRCLE_PR_REPONAME";
|
|
setPublicVar CI_PR_USERNAME "$CIRCLE_PR_USERNAME";
|
|
|
|
|
|
####################################################################################################
|
|
# Define "lazy" PUBLIC environment variables for CircleCI.
|
|
# (I.e. functions to set an environment variable when called.)
|
|
####################################################################################################
|
|
createPublicVarSetter CI_STABLE_BRANCH "\$(npm info @angular/core dist-tags.latest | sed -r 's/^\\s*([0-9]+\\.[0-9]+)\\.[0-9]+.*$/\\1.x/')";
|
|
|
|
|
|
####################################################################################################
|
|
# Define SECRET environment variables for CircleCI.
|
|
####################################################################################################
|
|
setSecretVar CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN "$AIO_DEPLOY_TOKEN";
|
|
setSecretVar CI_SECRET_PAYLOAD_FIREBASE_TOKEN "$ANGULAR_PAYLOAD_TOKEN";
|
|
|
|
|
|
####################################################################################################
|
|
# Define SauceLabs environment variables for CircleCI.
|
|
####################################################################################################
|
|
setPublicVar SAUCE_USERNAME "angular-framework";
|
|
setSecretVar SAUCE_ACCESS_KEY "0c731274ed5f-cbc9-16f4-021a-9835e39f";
|
|
# TODO(josephperrott): Remove environment variables once all saucelabs tests are via bazel method.
|
|
setPublicVar SAUCE_LOG_FILE /tmp/angular/sauce-connect.log
|
|
setPublicVar SAUCE_READY_FILE /tmp/angular/sauce-connect-ready-file.lock
|
|
setPublicVar SAUCE_PID_FILE /tmp/angular/sauce-connect-pid-file.lock
|
|
setPublicVar SAUCE_TUNNEL_IDENTIFIER "angular-framework-${CIRCLE_BUILD_NUM}-${CIRCLE_NODE_INDEX}"
|
|
# Amount of seconds we wait for sauceconnect to establish a tunnel instance. In order to not
|
|
# acquire CircleCI instances for too long if sauceconnect failed, we need a connect timeout.
|
|
setPublicVar SAUCE_READY_FILE_TIMEOUT 120
|
|
|
|
|
|
####################################################################################################
|
|
# Define environment variables for the `angular/components` repo unit tests job.
|
|
####################################################################################################
|
|
# We specifically use a directory within "/tmp" here because we want the cloned repo to be
|
|
# completely isolated from angular/angular in order to avoid any bad interactions between
|
|
# their separate build setups. **NOTE**: When updating the temporary directory, also update
|
|
# the `save_cache` path configuration in `config.yml`
|
|
setPublicVar COMPONENTS_REPO_TMP_DIR "/tmp/angular-components-repo"
|
|
setPublicVar COMPONENTS_REPO_URL "https://github.com/angular/components.git"
|
|
setPublicVar COMPONENTS_REPO_BRANCH "master"
|
|
# **NOTE**: When updating the commit SHA, also update the cache key in the CircleCI `config.yml`.
|
|
setPublicVar COMPONENTS_REPO_COMMIT "e0b76ed029939a7bb8246410b0170cfdbf35da25"
|
|
|
|
####################################################################################################
|
|
# Create shell script in /tmp for Bazel actions to access CI envs without
|
|
# busting the cache. Used by payload-size.sh script in integration tests.
|
|
####################################################################################################
|
|
readonly bazelVarEnv="/tmp/bazel-ci-env.sh"
|
|
echo "# Setup by /.circle/env.sh" > $bazelVarEnv
|
|
echo "export PROJECT_ROOT=\"${PROJECT_ROOT}\";" >> $bazelVarEnv
|
|
echo "export CI_BRANCH=\"${CI_BRANCH}\";" >> $bazelVarEnv
|
|
echo "export CI_BUILD_URL=\"${CI_BUILD_URL}\";" >> $bazelVarEnv
|
|
echo "export CI_COMMIT=\"${CI_COMMIT}\";" >> $bazelVarEnv
|
|
echo "export CI_PULL_REQUEST=\"${CI_PULL_REQUEST}\";" >> $bazelVarEnv
|
|
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
|
|
|
|
####################################################################################################
|
|
# Platform-specific environment setup (which can leverage the base variables from here)
|
|
####################################################################################################
|
|
|
|
# Conditionally, load additional environment settings based on the current VM
|
|
# operating system running. We detect Windows by checking for `%AppData%`.
|
|
if [[ -n "${APPDATA}" ]]; then
|
|
source ${projectDir}/.circleci/env.windows.sh
|
|
else
|
|
source ${projectDir}/.circleci/env.linux.sh
|
|
fi
|