Skip to content

Commit 734d08a

Browse files
committed
Merge remote-tracking branch 'upstream/master' into pr/18668
2 parents 057c6b0 + 7f63750 commit 734d08a

File tree

1,401 files changed

+49293
-8860
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,401 files changed

+49293
-8860
lines changed

.bazelrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ build:remote --host_cpu=k8
8181
# Setup the remote build execution servers.
8282
build:remote --remote_cache=remotebuildexecution.googleapis.com
8383
build:remote --remote_executor=remotebuildexecution.googleapis.com
84-
build:remote --tls_enabled=true
8584
build:remote --auth_enabled=true
8685

8786
# Setup the toolchain and platform for the remote build execution. The platform

.bazelversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.1.0
1+
3.6.0

.circleci/config.yml

Lines changed: 59 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,6 @@ var_5: &job_defaults
2626
docker:
2727
- image: *docker_image
2828

29-
# Job step for checking out the source code from GitHub. This also ensures that the source code
30-
# is rebased on top of master.
31-
var_6: &checkout_code
32-
checkout:
33-
# After checkout, rebase on top of master. By default, PRs are not rebased on top of master,
34-
# which we want. See https://discuss.circleci.com/t/1662
35-
post: git pull --ff-only origin "refs/pull/${CI_PULL_REQUEST//*pull\//}/merge"
36-
3729
# Restores the cache that could be available for the current Yarn lock file. The cache usually
3830
# includes the node modules and the Bazel repository cache.
3931
var_7: &restore_cache
@@ -159,12 +151,34 @@ orbs:
159151
# push conflicts.
160152
queue: eddiewebb/[email protected]
161153

154+
155+
commands:
156+
checkout_and_rebase:
157+
description: Checkout and rebase the repository
158+
steps:
159+
- checkout
160+
- run:
161+
name: Set up environment
162+
environment:
163+
CIRCLE_GIT_BASE_REVISION: << pipeline.git.base_revision >>
164+
CIRCLE_GIT_REVISION: << pipeline.git.revision >>
165+
command: ./.circleci/env.sh
166+
- run:
167+
name: Rebase PR on target branch
168+
# After checkout, rebase on top of target branch.
169+
command: |
170+
if [ -n "$CIRCLE_PR_NUMBER" ]; then
171+
# User is required for rebase.
172+
git config user.name "angular-ci"
173+
git config user.email "angular-ci"
174+
node .circleci/rebase-pr.js
175+
fi
176+
162177
# -----------------------------------------------------------------------------------------
163178
# Job definitions. Jobs which are defined just here, will not run automatically. Each job
164179
# must be part of a workflow definition in order to run for PRs and push builds.
165180
# -----------------------------------------------------------------------------------------
166181
jobs:
167-
168182
# -----------------------------------
169183
# Job to test that everything builds with Bazel
170184
# -----------------------------------
@@ -174,7 +188,7 @@ jobs:
174188
environment:
175189
GCP_DECRYPT_TOKEN: *gcp_decrypt_token
176190
steps:
177-
- *checkout_code
191+
- checkout_and_rebase
178192
- *restore_cache
179193
- *setup_bazel_ci_config
180194
- *setup_bazel_remote_execution
@@ -196,7 +210,7 @@ jobs:
196210
environment:
197211
GCP_DECRYPT_TOKEN: *gcp_decrypt_token
198212
steps:
199-
- *checkout_code
213+
- checkout_and_rebase
200214
- *restore_cache
201215
- *setup_bazel_ci_config
202216
- *setup_bazel_remote_execution
@@ -218,7 +232,7 @@ jobs:
218232
environment:
219233
GCP_DECRYPT_TOKEN: *gcp_decrypt_token
220234
steps:
221-
- *checkout_code
235+
- checkout_and_rebase
222236
- *restore_cache
223237
- *setup_bazel_ci_config
224238
- *setup_bazel_remote_execution
@@ -237,14 +251,17 @@ jobs:
237251
environment:
238252
GCP_DECRYPT_TOKEN: *gcp_decrypt_token
239253
steps:
240-
- *checkout_code
254+
- checkout_and_rebase
241255
- *restore_cache
242256
- *setup_bazel_ci_config
243257
- *setup_bazel_remote_execution
244258
- *yarn_install
245259
- *setup_bazel_binary
246260

247-
- run: bazel test src/... --build_tag_filters=e2e --test_tag_filters=e2e --build_tests_only
261+
# Run e2e tests. Note that protractor test targets are flaky sometimes, so we run them
262+
# with flaky test attempts. This means that Bazel will re-run a failed e2e test target
263+
# a second time to ensure it's a real test failure. This improves CI stability.
264+
- run: yarn e2e --flaky_test_attempts=2
248265
- *slack_notify_on_failure
249266

250267
# ------------------------------------------------------------------------------------------
@@ -257,7 +274,7 @@ jobs:
257274
environment:
258275
GCP_DECRYPT_TOKEN: *gcp_decrypt_token
259276
steps:
260-
- *checkout_code
277+
- checkout_and_rebase
261278
- *restore_cache
262279
- *setup_bazel_ci_config
263280
- *setup_bazel_remote_execution
@@ -278,7 +295,7 @@ jobs:
278295
BROWSER_STACK_USERNAME: "angularteam1"
279296
BROWSER_STACK_ACCESS_KEY: "CaXMeMHD9pr5PHg8N7Jq"
280297
steps:
281-
- *checkout_code
298+
- checkout_and_rebase
282299
- *restore_cache
283300
- *setup_bazel_ci_config
284301
- *yarn_install
@@ -300,7 +317,7 @@ jobs:
300317
# a rate limit exception.
301318
KARMA_PARALLEL_BROWSERS: 2
302319
steps:
303-
- *checkout_code
320+
- checkout_and_rebase
304321
- *restore_cache
305322
- *setup_bazel_ci_config
306323
- *yarn_install
@@ -313,8 +330,11 @@ jobs:
313330
# ----------------------------------
314331
lint:
315332
<<: *job_defaults
333+
environment:
334+
CI_GIT_BASE_REVISION: << pipeline.git.base_revision >>
335+
CI_GIT_REVISION: << pipeline.git.revision >>
316336
steps:
317-
- *checkout_code
337+
- checkout_and_rebase
318338
- *restore_cache
319339
- *setup_bazel_ci_config
320340
- *yarn_install
@@ -333,10 +353,20 @@ jobs:
333353
yarn check-entry-point-setup $(bazel info bazel-bin)/entry_points_manifest.json
334354
335355
- run: yarn ng-dev format changed --check << pipeline.git.base_revision >>
356+
- run:
357+
name: Check Commit Message (PR Only)
358+
# Only run the commit message checks on pull requests since we can't do
359+
# much about any failures that have made it into the main branch.
360+
command: |
361+
if [ -n "$CIRCLE_PR_NUMBER" ]; then
362+
yarn ng-dev commit-message validate-range --range $CI_COMMIT_RANGE
363+
fi
336364
- run: yarn ownerslint
365+
- run: yarn check-mdc-tests
337366
- run: yarn stylelint
338367
- run: yarn tslint
339368
- run: yarn -s ts-circular-deps:check
369+
- run: yarn check-mdc-exports
340370

341371
- *slack_notify_on_failure
342372
- *save_cache
@@ -351,7 +381,7 @@ jobs:
351381
environment:
352382
GCP_DECRYPT_TOKEN: *gcp_decrypt_token
353383
steps:
354-
- *checkout_code
384+
- checkout_and_rebase
355385
- *restore_cache
356386
- *setup_bazel_ci_config
357387
- *setup_bazel_remote_execution
@@ -403,7 +433,7 @@ jobs:
403433
upload_release_packages:
404434
<<: *job_defaults
405435
steps:
406-
- *checkout_code
436+
- checkout_and_rebase
407437
- *restore_cache
408438
- *attach_release_output
409439
- *yarn_install
@@ -424,7 +454,7 @@ jobs:
424454
environment:
425455
GCP_DECRYPT_TOKEN: *gcp_decrypt_token
426456
steps:
427-
- *checkout_code
457+
- checkout_and_rebase
428458
- *restore_cache
429459
- *attach_release_output
430460
- *setup_bazel_ci_config
@@ -440,7 +470,7 @@ jobs:
440470
# The components examples package is not a release package, but we publish it
441471
# as part of this job to the docs-content repository. It's not contained in the
442472
# attached release output, so we need to build it here.
443-
- run: bazel build src/components-examples:npm_package --config=snapshot-build
473+
- run: yarn build-docs-content
444474

445475
# Ensures that we do not push the snapshot artifacts upstream until all previous
446476
# snapshot build jobs have completed. This helps avoiding conflicts when multiple
@@ -462,7 +492,7 @@ jobs:
462492
<<: *job_defaults
463493
resource_class: xlarge
464494
steps:
465-
- *checkout_code
495+
- checkout_and_rebase
466496
- *restore_cache
467497
- *attach_release_output
468498
- *yarn_install
@@ -486,7 +516,7 @@ jobs:
486516
<<: *job_defaults
487517
resource_class: xlarge
488518
steps:
489-
- *checkout_code
519+
- checkout_and_rebase
490520
- *restore_cache
491521
- *attach_release_output
492522
- *setup_snapshot_builds
@@ -513,7 +543,7 @@ jobs:
513543
environment:
514544
GCP_DECRYPT_TOKEN: *gcp_decrypt_token
515545
steps:
516-
- *checkout_code
546+
- checkout_and_rebase
517547
- *restore_cache
518548
- *setup_bazel_ci_config
519549
- *setup_bazel_remote_execution
@@ -534,7 +564,7 @@ jobs:
534564
environment:
535565
GCP_DECRYPT_TOKEN: *gcp_decrypt_token
536566
steps:
537-
- *checkout_code
567+
- checkout_and_rebase
538568
- *restore_cache
539569
- *setup_bazel_ci_config
540570
- *setup_bazel_remote_execution
@@ -554,7 +584,7 @@ jobs:
554584
environment:
555585
GCP_DECRYPT_TOKEN: *gcp_decrypt_token
556586
steps:
557-
- *checkout_code
587+
- checkout_and_rebase
558588
- *restore_cache
559589
- *setup_bazel_ci_config
560590
- *setup_bazel_remote_execution
@@ -575,7 +605,7 @@ jobs:
575605
environment:
576606
GCP_DECRYPT_TOKEN: *gcp_decrypt_token
577607
steps:
578-
- *checkout_code
608+
- checkout_and_rebase
579609
- *restore_cache
580610
- *setup_bazel_ci_config
581611
- *setup_bazel_remote_execution
@@ -601,7 +631,7 @@ jobs:
601631
environment:
602632
GCP_DECRYPT_TOKEN: *gcp_decrypt_token
603633
steps:
604-
- *checkout_code
634+
- checkout_and_rebase
605635
- *restore_cache
606636
- *setup_bazel_binary
607637
- *setup_bazel_ci_config

.circleci/env-helpers.inc.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
####################################################################################################
2+
# Helpers for defining environment variables for CircleCI.
3+
#
4+
# In CircleCI, each step runs in a new shell. The way to share ENV variables across steps is to
5+
# export them from `$BASH_ENV`, which is automatically sourced at the beginning of every step (for
6+
# the default `bash` shell).
7+
#
8+
# See also https://circleci.com/docs/2.0/env-vars/#using-bash_env-to-set-environment-variables.
9+
####################################################################################################
10+
11+
# Set and print an environment variable.
12+
#
13+
# Use this function for setting environment variables that are public, i.e. it is OK for them to be
14+
# visible to anyone through the CI logs.
15+
#
16+
# Usage: `setPublicVar <name> <value>`
17+
function setPublicVar() {
18+
setSecretVar $1 "$2";
19+
echo "$1=$2";
20+
}
21+
22+
# Set (without printing) an environment variable.
23+
#
24+
# Use this function for setting environment variables that are secret, i.e. should not be visible to
25+
# everyone through the CI logs.
26+
#
27+
# Usage: `setSecretVar <name> <value>`
28+
function setSecretVar() {
29+
# WARNING: Secrets (e.g. passwords, access tokens) should NOT be printed.
30+
# (Keep original shell options to restore at the end.)
31+
local -r originalShellOptions=$(set +o);
32+
set +x -eu -o pipefail;
33+
34+
echo "export $1=\"${2:-}\";" >> $BASH_ENV;
35+
36+
# Restore original shell options.
37+
eval "$originalShellOptions";
38+
}
39+
40+
41+
# Create a function to set an environment variable, when called.
42+
#
43+
# Use this function for creating setter for public environment variables that require expensive or
44+
# time-consuming computaions and may not be needed. When needed, you can call this function to set
45+
# the environment variable (which will be available through `$BASH_ENV` from that point onwards).
46+
#
47+
# Arguments:
48+
# - `<name>`: The name of the environment variable. The generated setter function will be
49+
# `setPublicVar_<name>`.
50+
# - `<code>`: The code to run to compute the value for the variable. Since this code should be
51+
# executed lazily, it must be properly escaped. For example:
52+
# ```sh
53+
# # DO NOT do this:
54+
# createPublicVarSetter MY_VAR "$(whoami)"; # `whoami` will be evaluated eagerly
55+
#
56+
# # DO this isntead:
57+
# createPublicVarSetter MY_VAR "\$(whoami)"; # `whoami` will NOT be evaluated eagerly
58+
# ```
59+
#
60+
# Usage: `createPublicVarSetter <name> <code>`
61+
#
62+
# Example:
63+
# ```sh
64+
# createPublicVarSetter MY_VAR 'echo "FOO"';
65+
# echo $MY_VAR; # Not defined
66+
#
67+
# setPublicVar_MY_VAR;
68+
# source $BASH_ENV;
69+
# echo $MY_VAR; # FOO
70+
# ```
71+
function createPublicVarSetter() {
72+
echo "setPublicVar_$1() { setPublicVar $1 \"$2\"; }" >> $BASH_ENV;
73+
}

.circleci/env.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env bash
2+
3+
# Variables
4+
readonly projectDir=$(realpath "$(dirname ${BASH_SOURCE[0]})/..")
5+
readonly envHelpersPath="$projectDir/.circleci/env-helpers.inc.sh";
6+
readonly bashEnvCachePath="$projectDir/.circleci/bash_env_cache";
7+
8+
# Load helpers and make them available everywhere (through `$BASH_ENV`).
9+
source $envHelpersPath;
10+
echo "source $envHelpersPath;" >> $BASH_ENV;
11+
12+
13+
####################################################################################################
14+
# Define PUBLIC environment variables for CircleCI.
15+
####################################################################################################
16+
# See https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables for more info.
17+
####################################################################################################
18+
setPublicVar CI "$CI"
19+
setPublicVar PROJECT_ROOT "$projectDir";
20+
# This is the branch being built; e.g. `pull/12345` for PR builds.
21+
setPublicVar CI_BRANCH "$CIRCLE_BRANCH";
22+
setPublicVar CI_BUILD_URL "$CIRCLE_BUILD_URL";
23+
setPublicVar CI_COMMIT "$CIRCLE_SHA1";
24+
# `CI_COMMIT_RANGE` is only used on push builds (a.k.a. non-PR, non-scheduled builds and rerun
25+
# workflows of such builds).
26+
setPublicVar CI_GIT_BASE_REVISION "${CIRCLE_GIT_BASE_REVISION}";
27+
setPublicVar CI_GIT_REVISION "${CIRCLE_GIT_REVISION}";
28+
setPublicVar CI_COMMIT_RANGE "$CIRCLE_GIT_BASE_REVISION..$CIRCLE_GIT_REVISION";
29+
setPublicVar CI_PULL_REQUEST "${CIRCLE_PR_NUMBER:-false}";
30+
setPublicVar CI_REPO_NAME "$CIRCLE_PROJECT_REPONAME";
31+
setPublicVar CI_REPO_OWNER "$CIRCLE_PROJECT_USERNAME";
32+
setPublicVar CI_PR_REPONAME "$CIRCLE_PR_REPONAME";
33+
setPublicVar CI_PR_USERNAME "$CIRCLE_PR_USERNAME";
34+
35+
####################################################################################################
36+
# Decrypt GCP Credentials and store them as the Google default credentials.
37+
####################################################################################################
38+
mkdir -p "$HOME/.config/gcloud";
39+
openssl aes-256-cbc -d -in "${projectDir}/.circleci/gcp_token" \
40+
-md md5 -k "$CIRCLE_PROJECT_REPONAME" -out "$HOME/.config/gcloud/application_default_credentials.json"
41+
####################################################################################################
42+
# Set bazel configuration for CircleCI runs.
43+
####################################################################################################
44+
cp "${projectDir}/.circleci/bazel.linux.rc" "$HOME/.bazelrc";
45+
46+
####################################################################################################
47+
####################################################################################################
48+
## Source `$BASH_ENV` to make the variables available immediately. ##
49+
## ***NOTE: This must remain the the last action in this script*** ##
50+
####################################################################################################
51+
####################################################################################################
52+
source $BASH_ENV;

0 commit comments

Comments
 (0)