Skip to content

Commit 37cc514

Browse files
devversionmatsko
authored andcommitted
ci: add yarn cache for material-unit tests job (angular#29378)
PR Close angular#29378
1 parent 067657c commit 37cc514

File tree

4 files changed

+45
-17
lines changed

4 files changed

+45
-17
lines changed

.circleci/config.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,24 @@ jobs:
563563
steps:
564564
- *attach_workspace
565565
- *init_environment
566-
- run: ./scripts/ci/run_angular_material_unit_tests.sh
566+
- run:
567+
name: "Determining SHA of Material Ivy branch"
568+
command: git ls-remote ${MATERIAL_REPO_URL} ${MATERIAL_REPO_BRANCH} | cut -f1 > material_repo_sha
569+
- run:
570+
name: "Cloning Material repository"
571+
command: ./scripts/ci/clone_angular_material_repo.sh
572+
- restore_cache:
573+
keys:
574+
- v1-angular-material-{{ checksum "material_repo_sha" }}
575+
- v1-angular-material-
576+
- run:
577+
name: "Running Material unit tests"
578+
command: ./scripts/ci/run_angular_material_unit_tests.sh
579+
- save_cache:
580+
key: v1-angular-material-{{ checksum "material_repo_sha" }}
581+
paths:
582+
# Needs to be hardcoded because environment variables are not interpolated here.
583+
- "/tmp/material2/node_modules"
567584

568585
workflows:
569586
version: 2

.circleci/env.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ setPublicVar SAUCE_TUNNEL_IDENTIFIER "angular-${CIRCLE_BUILD_NUM}-${CIRCLE_NODE_
6262
# acquire CircleCI instances for too long if sauceconnect failed, we need a connect timeout.
6363
setPublicVar SAUCE_READY_FILE_TIMEOUT 120
6464

65+
####################################################################################################
66+
# Define environment variables for the Angular Material unit tests job.
67+
####################################################################################################
68+
# We specifically use a directory within "/tmp" here because we want the cloned repo to be
69+
# completely isolated from angular/angular in order to avoid any bad interactions between
70+
# their separate build setups.
71+
setPublicVar MATERIAL_REPO_TMP_DIR "/tmp/material2"
72+
setPublicVar MATERIAL_REPO_URL "https://github.com/angular/material2.git"
73+
setPublicVar MATERIAL_REPO_BRANCH "ivy-2019"
6574

6675
# Source `$BASH_ENV` to make the variables available immediately.
6776
source $BASH_ENV;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
set -u -e -o pipefail
4+
5+
# Ensure that the temporary directory does not exist.
6+
rm -rf ${MATERIAL_REPO_TMP_DIR}
7+
8+
# Clone the Material repository into the given temporary directory.
9+
git clone --depth 1 --branch ${MATERIAL_REPO_BRANCH} ${MATERIAL_REPO_URL} \
10+
${MATERIAL_REPO_TMP_DIR}
Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,28 @@
11
#!/usr/bin/env bash
22
set -u -e -o pipefail
33

4-
54
# This script runs unit tests from angular/material2.
65

76
# Save the dir for the root of the Angular repo.
87
angular_dir=$(pwd)
98

10-
# Clone the angular/material2 repo into tmp so we can run the tests from there.
11-
# We specifically use /tmp here because we want the cloned repo to be completely
12-
# isolated from angular/angular in order to avoid any bad interactions between their
13-
# separate build setups. Also note that this is using the ivy-2019 branch, which has
14-
# previously been set up to work with ivy.
15-
cd /tmp
16-
rm -rf /tmp/material2
17-
git clone --depth 1 --branch ivy-2019 https://github.com/angular/material2.git
9+
# Switch into Material directory.
10+
cd ${MATERIAL_REPO_TMP_DIR}
1811

1912
# Install dependencies for the freshly cloned repo.
20-
cd /tmp/material2
21-
yarn install --frozen-lockfile --non-interactive # TODO: cache
13+
yarn install --frozen-lockfile --non-interactive
2214

2315
# Install this version of Angular into the freshly cloned repo.
24-
rm -rf /tmp/material2/node_modules/@angular/*
25-
cp -r ${angular_dir}/dist/packages-dist-ivy-aot/* /tmp/material2/node_modules/@angular/
16+
rm -rf ./node_modules/@angular/*
17+
cp -r ${angular_dir}/dist/packages-dist-ivy-aot/* ./node_modules/@angular/
2618

27-
# The angular/material2 CI sets TEST_PLATFORM to either local, saucelabs, or browserstack.
28-
# For angular/angular, we only want to run the local tests.
19+
# The angular/material2 CI sets TEST_PLATFORM to either "local", "saucelabs", or "browserstack".
20+
# For angular/angular, we only want to run the "local" tests.
2921
export TEST_PLATFORM=local
3022

3123
# Append the test blocklist into angular/material2's karma-test-shim.js.
3224
# This filters out known-failing tests because the goal is to prevent regressions.
33-
cat ${angular_dir}/tools/material-ci/angular_material_test_blocklist.js >> /tmp/material2/test/karma-test-shim.js
25+
cat ${angular_dir}/tools/material-ci/angular_material_test_blocklist.js >> ./test/karma-test-shim.js
3426

3527
# Now actually run the tests.
3628
yarn gulp test:single-run

0 commit comments

Comments
 (0)