build: lock material unit tests job to specific commit (#31569)
No longer locks the Material unit tests job to a specific branch, but rather allows locking to a specific commit from a given branch. This allows us to use the "master" branch from the `components` repository. PR Close #31569
This commit is contained in:
parent
7e46a6d99d
commit
0cd4c019cf
|
@ -141,6 +141,11 @@ var_14: ¬ify_dev_infra_on_fail
|
|||
notificationJson="{\"text\":\":x: \`$CIRCLE_JOB\` job for $CIRCLE_BRANCH branch failed on build $CIRCLE_BUILD_NUM: $CIRCLE_BUILD_URL :scream:\"}"
|
||||
curl --request POST --header "Content-Type: application/json" --data "$notificationJson" $SLACK_DEV_INFRA_CI_FAILURES_WEBHOOK_URL
|
||||
|
||||
# Cache key for the Material unit tests job. **Note** when updating the SHA in the cache keys,
|
||||
# also update the SHA for the "MATERIAL_REPO_COMMIT" environment variable.
|
||||
var_15: &material_unit_tests_cache_key v4-angular-material-701302dc482d7e4b77990b24e3b5ab330bbf1aa5
|
||||
var_16: &material_unit_tests_cache_key_short v4-angular-material
|
||||
|
||||
version: 2
|
||||
jobs:
|
||||
setup:
|
||||
|
@ -621,27 +626,26 @@ jobs:
|
|||
# Although RBE is configured below for the Material repo, also setup RBE in the Angular repo
|
||||
# to provision Angular's GCP token into the environment variables.
|
||||
- *setup_bazel_remote_execution
|
||||
- run:
|
||||
name: "Cloning Material repository"
|
||||
command: ./scripts/ci/clone_angular_material_repo.sh
|
||||
# Restore the cache before cloning the repository because the clone script re-uses
|
||||
# the restored repository if present. This reduces the amount of times the components
|
||||
# repository needs to be cloned (this is slow and increases based on commits in the repo).
|
||||
- restore_cache:
|
||||
# Material directory must be kept in sync with the `$MATERIAL_REPO_TMP_DIR` env variable.
|
||||
# It needs to be hardcoded here, because env variables interpolation is not supported.
|
||||
keys:
|
||||
- v2-angular-material-{{ checksum "/tmp/material2/yarn.lock" }}
|
||||
- v2-angular-material-
|
||||
- *material_unit_tests_cache_key
|
||||
- *material_unit_tests_cache_key_short
|
||||
- run:
|
||||
name: "Fetching Material repository"
|
||||
command: ./scripts/ci/clone_angular_material_repo.sh
|
||||
- run:
|
||||
# Run yarn install to fetch the Bazel binaries as used in the Material repo.
|
||||
name: Installing Material dependencies.
|
||||
command: yarn --cwd ${MATERIAL_REPO_TMP_DIR} install --frozen-lockfile --non-interactive
|
||||
# Save the cache before we run the Material unit tests script. This is necessary
|
||||
# because we don't want to cache the node modules which have been modified to contain
|
||||
# the attached Ivy package output.
|
||||
- save_cache:
|
||||
# Material directory must be kept in sync with the `$MATERIAL_REPO_TMP_DIR` env variable.
|
||||
# It needs to be hardcoded here, because env variables interpolation is not supported.
|
||||
key: v2-angular-material-{{ checksum "/tmp/material2/yarn.lock" }}
|
||||
key: *material_unit_tests_cache_key
|
||||
paths:
|
||||
- "/tmp/material2/node_modules"
|
||||
# Material directory must be kept in sync with the `$MATERIAL_REPO_TMP_DIR` env variable.
|
||||
# It needs to be hardcoded here, because env variables interpolation is not supported.
|
||||
- "/tmp/material2"
|
||||
- run:
|
||||
name: "Setup Bazel RBE remote execution in Material repo"
|
||||
command: |
|
||||
|
|
|
@ -77,7 +77,9 @@ setPublicVar SAUCE_READY_FILE_TIMEOUT 120
|
|||
# their separate build setups.
|
||||
setPublicVar MATERIAL_REPO_TMP_DIR "/tmp/material2"
|
||||
setPublicVar MATERIAL_REPO_URL "https://github.com/angular/material2.git"
|
||||
setPublicVar MATERIAL_REPO_TAG "8.1.0"
|
||||
setPublicVar MATERIAL_REPO_BRANCH "master"
|
||||
# **NOTE**: When updating the commit SHA, also update the cache key in the CircleCI "config.yml".
|
||||
setPublicVar MATERIAL_REPO_COMMIT "701302dc482d7e4b77990b24e3b5ab330bbf1aa5"
|
||||
|
||||
# Source `$BASH_ENV` to make the variables available immediately.
|
||||
source $BASH_ENV;
|
||||
|
|
|
@ -2,9 +2,30 @@
|
|||
|
||||
set -u -e -o pipefail
|
||||
|
||||
# Ensure that the temporary directory does not exist.
|
||||
rm -rf ${MATERIAL_REPO_TMP_DIR}
|
||||
# Clones the Angular Material repository if the repository has not been cloned before. If
|
||||
# the repository is already cloned, the script refreshes the repository by syncing with
|
||||
# upstream and resetting to the desired Material commit (see "MATERIAL_REPO_COMMIT" variable).
|
||||
|
||||
# Clone the Material repository into the given temporary directory.
|
||||
git clone --depth 1 --branch ${MATERIAL_REPO_TAG} ${MATERIAL_REPO_URL} \
|
||||
${MATERIAL_REPO_TMP_DIR}
|
||||
if [[ ! -d "${MATERIAL_REPO_TMP_DIR}" ]]; then
|
||||
# Clone the Material repository if not present through restored cache.
|
||||
git clone --branch ${MATERIAL_REPO_BRANCH} ${MATERIAL_REPO_URL} ${MATERIAL_REPO_TMP_DIR}
|
||||
|
||||
# Switch into the cloned repository.
|
||||
cd ${MATERIAL_REPO_TMP_DIR}
|
||||
|
||||
# Reset branch to the desired commit.
|
||||
git reset --hard ${MATERIAL_REPO_COMMIT}
|
||||
else
|
||||
# Switch into the cached repository.
|
||||
cd ${MATERIAL_REPO_TMP_DIR}
|
||||
|
||||
# Only refresh the repository if the current branch HEAD is not
|
||||
# matching the desired commit.
|
||||
if [[ "$(git rev-parse HEAD)" != "${MATERIAL_REPO_COMMIT}" ]]; then
|
||||
# Pull the latest changes of the specified branch.
|
||||
git fetch origin ${MATERIAL_REPO_BRANCH}
|
||||
|
||||
# Reset the current branch to the desired commit.
|
||||
git reset --hard ${MATERIAL_REPO_COMMIT}
|
||||
fi
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue