Compare commits
244 Commits
creating-l
...
9.1.3
Author | SHA1 | Date | |
---|---|---|---|
e1071615c6 | |||
8bd5374cfd | |||
b9b9cc2ba8 | |||
a6e10ef869 | |||
9724169bf4 | |||
c0ed57db76 | |||
0bd50e2e50 | |||
0ceb27041f | |||
ec2affe104 | |||
c590e8ca7a | |||
254b9ea44c | |||
2a53f47159 | |||
722d9397b0 | |||
03de31a78e | |||
b22c5a953d | |||
24222e0c1f | |||
95f45e8070 | |||
18be33a9d1 | |||
a22d4f6c98 | |||
5ae8473c6b | |||
fd7c39e3cf | |||
d85d91df66 | |||
15930d21c7 | |||
61a7f98b98 | |||
c3c7bf6509 | |||
b2e7ce47ec | |||
94e518e3c7 | |||
0fa5ac8d0d | |||
f2fca3e243 | |||
5bab49828d | |||
db4e93d0ca | |||
479a59be43 | |||
52aab63dd9 | |||
506beeddc1 | |||
0075078179 | |||
bb7edc52aa | |||
ed2b0e945e | |||
da159bde83 | |||
06a9809e32 | |||
1e4fb74ec8 | |||
797c306306 | |||
972fc06135 | |||
a9117061d0 | |||
fe1d9bacc3 | |||
08b8b51486 | |||
1d4af3f734 | |||
609d81c65e | |||
af30efddc5 | |||
15115f6179 | |||
eec9b6bbb5 | |||
45fd77ead1 | |||
f16587e9b7 | |||
4f9991534e | |||
51a0ed2222 | |||
a5ea100e7c | |||
0429c7f5e9 | |||
1756cced4a | |||
793a001d7c | |||
5c3774cfe6 | |||
12266b2042 | |||
e385abc83c | |||
933cbfb828 | |||
c5e725111d | |||
93993864b1 | |||
26f49151e7 | |||
4b3f9ac739 | |||
80604d3a76 | |||
e615a10371 | |||
c8f2ca2349 | |||
a67afcc932 | |||
fd7698253e | |||
32de025dce | |||
a4e1768a74 | |||
b336871303 | |||
92fa6399f7 | |||
3992341d34 | |||
8c559ef104 | |||
0bac2b062c | |||
58d028178f | |||
e06512b22f | |||
603b0944d5 | |||
918e628f9b | |||
468cf69c55 | |||
c8f3fa9f3e | |||
78136cc3a7 | |||
66724fd159 | |||
8e7f9033a3 | |||
c8f9092364 | |||
bc995835b9 | |||
1bfa908ab3 | |||
2479f7d7ef | |||
333b8679ad | |||
5da621d3dd | |||
cbed582a1a | |||
d5aa6b5bd6 | |||
33eee43263 | |||
72053b0f27 | |||
d20ef47b16 | |||
bdc05aef64 | |||
798d959bee | |||
3570aaa363 | |||
421b6a97d6 | |||
b28a5f6eef | |||
52ab9397a0 | |||
b99e539b0e | |||
fd2ef74a31 | |||
cbc25bbf31 | |||
7385b2cf25 | |||
0daa48800e | |||
ffa4e11db1 | |||
41a41e741d | |||
c5384aee58 | |||
b02c950aac | |||
2eaa304aba | |||
9faf2e4a96 | |||
0e7a89a391 | |||
af4269471d | |||
915a6c17b9 | |||
93b32d3023 | |||
bd82b34f79 | |||
c626e90ab0 | |||
c6bbb0d8e5 | |||
f48a065db0 | |||
aeb6d0d0f7 | |||
655c9e386b | |||
2ad20b953f | |||
7059eaf2d2 | |||
939fda410f | |||
35ab6acab3 | |||
f4ee067cb8 | |||
068e28381d | |||
dff52ecb11 | |||
56af303dc3 | |||
136596ddb4 | |||
e515c913d9 | |||
31eaf78035 | |||
b0d680daa0 | |||
93cbef26c7 | |||
e2b221b8fa | |||
7a33c456d3 | |||
61db817eed | |||
4894220acf | |||
74b7a8eaf5 | |||
bfa55162de | |||
776f991c1a | |||
d9d1a1e682 | |||
867ff14a4a | |||
879457ca05 | |||
efbe4ad28a | |||
64f72c0600 | |||
81c05bfa01 | |||
56abcf088d | |||
6818432cd0 | |||
79bfb037df | |||
0fce20d79d | |||
9f486c31d2 | |||
d36066dd6c | |||
a631b99c69 | |||
78211c42ea | |||
5ff5a11509 | |||
e80047e897 | |||
eee5eeae76 | |||
c3ce1903b6 | |||
21da0346c7 | |||
af2d74fde9 | |||
8de62a9811 | |||
26e28453d6 | |||
8ea30b662f | |||
cb0a2a055d | |||
14ae3c0a21 | |||
90cae34c05 | |||
7bb35889fa | |||
03a3c753bb | |||
74b1464dff | |||
ff523c9ec9 | |||
392ef93c2b | |||
29dcb5bf68 | |||
de594ca221 | |||
3545a49a79 | |||
f4681b6e40 | |||
fb16557381 | |||
61c9da5542 | |||
dbb1eb0ffe | |||
002b81c0b0 | |||
beb3f19dc0 | |||
e8f3c47b03 | |||
c58e6ba13a | |||
61e5ab4703 | |||
10385c27da | |||
0ab244f39e | |||
eafa5260db | |||
15cffa210c | |||
df8e45a193 | |||
bb8744db94 | |||
43bad87ae1 | |||
c3b297a318 | |||
6ea232eb3c | |||
0baab0f3db | |||
e53b686375 | |||
5c28af0e74 | |||
60adc35d30 | |||
024cc3b84a | |||
ac17142001 | |||
8d7066223f | |||
0cb3c04128 | |||
2649794e65 | |||
bf426c5f0d | |||
aa6b9f0382 | |||
822b420a11 | |||
294c6297d7 | |||
58fc65d198 | |||
b6bd8d7572 | |||
b08168bb90 | |||
407fa42679 | |||
aef432384a | |||
fb70083339 | |||
c9c2408176 | |||
e066bddfe9 | |||
447a600477 | |||
70f9bfff43 | |||
57c02b044c | |||
6defe962c8 | |||
267bcb3e9c | |||
b0b66881b4 | |||
9ff8d78bcd | |||
563b707497 | |||
5357e643b3 | |||
f71d132f7c | |||
ba3edda230 | |||
0767d37c07 | |||
8ba24578bc | |||
133a97ad67 | |||
4e67a3ab3f | |||
377f0010fc | |||
6e09129e4c | |||
d80e51a6b1 | |||
feb66b00da | |||
cb19eac105 | |||
6e0564ade6 | |||
05eeb7d279 | |||
2ce5fa3cce | |||
e140cdcb34 | |||
14b2db1d43 | |||
2afc7e982e |
7
.bazelrc
7
.bazelrc
@ -33,11 +33,6 @@ build --incompatible_strict_action_env
|
|||||||
run --incompatible_strict_action_env
|
run --incompatible_strict_action_env
|
||||||
test --incompatible_strict_action_env
|
test --incompatible_strict_action_env
|
||||||
|
|
||||||
# Do not build runfile trees by default. If an execution strategy relies on runfile
|
|
||||||
# symlink teee, the tree is created on-demand. See: https://github.com/bazelbuild/bazel/issues/6627
|
|
||||||
# and https://github.com/bazelbuild/bazel/commit/03246077f948f2790a83520e7dccc2625650e6df
|
|
||||||
build --nobuild_runfile_links
|
|
||||||
|
|
||||||
###############################
|
###############################
|
||||||
# Release support #
|
# Release support #
|
||||||
# Turn on these settings with #
|
# Turn on these settings with #
|
||||||
@ -47,7 +42,7 @@ build --nobuild_runfile_links
|
|||||||
# Releases should always be stamped with version control info
|
# Releases should always be stamped with version control info
|
||||||
# This command assumes node on the path and is a workaround for
|
# This command assumes node on the path and is a workaround for
|
||||||
# https://github.com/bazelbuild/bazel/issues/4802
|
# https://github.com/bazelbuild/bazel/issues/4802
|
||||||
build:release --workspace_status_command="yarn -s ng-dev release build-env-stamp"
|
build:release --workspace_status_command="node ./tools/bazel_stamp_vars.js"
|
||||||
build:release --stamp
|
build:release --stamp
|
||||||
|
|
||||||
###############################
|
###############################
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
3.2.0
|
2.1.1
|
||||||
# [NB: this comment has to be after the first line, see https://github.com/bazelbuild/bazelisk/issues/117]
|
# [NB: this comment has to be after the first line, see https://github.com/bazelbuild/bazelisk/issues/117]
|
||||||
# When updating the Bazel version you also need to update the RBE toolchains version in package.bzl
|
# When updating the Bazel version you also need to update the RBE toolchains version in package.bzl
|
||||||
|
@ -12,8 +12,8 @@ We use this as a symmetric AES encryption key to encrypt tokens like
|
|||||||
a GitHub token that enables publishing snapshots.
|
a GitHub token that enables publishing snapshots.
|
||||||
|
|
||||||
To create the github_token file, we take this approach:
|
To create the github_token file, we take this approach:
|
||||||
- Find the angular-builds:token in the internal pw database
|
- Find the angular-builds:token in http://valentine
|
||||||
- Go inside the CircleCI default docker image so you use the same version of openssl as we will at runtime: `docker run --rm -it circleci/node:10.12`
|
- Go inside the CircleCI default docker image so you use the same version of openssl as we will at runtime: `docker run --rm -it circleci/node:10.12`
|
||||||
- echo "https://[token]:@github.com" > credentials
|
- echo "https://[token]:@github.com" > credentials
|
||||||
- openssl aes-256-cbc -e -in credentials -out .circleci/github_token -k $KEY
|
- openssl aes-256-cbc -e -in credentials -out .circleci/github_token -k $KEY
|
||||||
- If needed, base64-encode the result so you can copy-paste it out of docker: `base64 github_token`
|
- If needed, base64-encode the result so you can copy-paste it out of docker: `base64 github_token`
|
@ -19,12 +19,4 @@ build --local_ram_resources=14336
|
|||||||
|
|
||||||
# All build executed remotely should be done using our RBE configuration.
|
# All build executed remotely should be done using our RBE configuration.
|
||||||
build:remote --google_default_credentials
|
build:remote --google_default_credentials
|
||||||
|
|
||||||
# Upload to GCP's Build Status viewer to allow for us to have better viewing of execution/build
|
|
||||||
# logs. This is only done on CI as the BES (GCP's Build Status viewer) API requires credentials
|
|
||||||
# from service accounts, rather than end user accounts.
|
|
||||||
build:remote --bes_backend=buildeventservice.googleapis.com
|
|
||||||
build:remote --bes_timeout=30s
|
|
||||||
build:remote --bes_results_url="https://source.cloud.google.com/results/invocations/"
|
|
||||||
|
|
||||||
build --config=remote
|
build --config=remote
|
||||||
|
@ -22,18 +22,18 @@ version: 2.1
|
|||||||
# **NOTE 1 **: If you change the cache key prefix, also sync the cache_key_fallback to match.
|
# **NOTE 1 **: If you change the cache key prefix, also sync the cache_key_fallback to match.
|
||||||
# **NOTE 2 **: Keep the static part of the cache key as prefix to enable correct fallbacks.
|
# **NOTE 2 **: Keep the static part of the cache key as prefix to enable correct fallbacks.
|
||||||
# See https://circleci.com/docs/2.0/caching/#restoring-cache for how prefixes work in CircleCI.
|
# See https://circleci.com/docs/2.0/caching/#restoring-cache for how prefixes work in CircleCI.
|
||||||
var_3: &cache_key v7-angular-node-12-{{ checksum ".bazelversion" }}-{{ checksum "yarn.lock" }}-{{ checksum "WORKSPACE" }}-{{ checksum "packages/bazel/package.bzl" }}-{{ checksum "aio/yarn.lock" }}
|
var_3: &cache_key v6-angular-node-12-{{ checksum ".bazelversion" }}-{{ checksum "yarn.lock" }}-{{ checksum "WORKSPACE" }}-{{ checksum "packages/bazel/package.bzl" }}-{{ checksum "aio/yarn.lock" }}
|
||||||
# We invalidate the cache if the Bazel version changes because otherwise the `bazelisk` cache
|
# We invalidate the cache if the Bazel version changes because otherwise the `bazelisk` cache
|
||||||
# folder will contain all previously used versions and ultimately cause the cache restoring to
|
# folder will contain all previously used versions and ultimately cause the cache restoring to
|
||||||
# be slower due to its growing size.
|
# be slower due to its growing size.
|
||||||
var_4: &cache_key_fallback v7-angular-node-12-{{ checksum ".bazelversion" }}
|
var_4: &cache_key_fallback v6-angular-node-12-{{ checksum ".bazelversion" }}
|
||||||
var_3_win: &cache_key_win v7-angular-win-node-12-{{ checksum ".bazelversion" }}-{{ checksum "yarn.lock" }}-{{ checksum "WORKSPACE" }}-{{ checksum "packages/bazel/package.bzl" }}-{{ checksum "aio/yarn.lock" }}
|
var_3_win: &cache_key_win v6-angular-win-node-12-{{ checksum ".bazelversion" }}-{{ checksum "yarn.lock" }}-{{ checksum "WORKSPACE" }}-{{ checksum "packages/bazel/package.bzl" }}-{{ checksum "aio/yarn.lock" }}
|
||||||
var_4_win: &cache_key_win_fallback v7-angular-win-node-12-{{ checksum ".bazelversion" }}
|
var_4_win: &cache_key_win_fallback v6-angular-win-node-12-{{ checksum ".bazelversion" }}
|
||||||
|
|
||||||
# Cache key for the `components-repo-unit-tests` job. **Note** when updating the SHA in the
|
# Cache key for the `components-repo-unit-tests` job. **Note** when updating the SHA in the
|
||||||
# cache keys also update the SHA for the "COMPONENTS_REPO_COMMIT" environment variable.
|
# cache keys also update the SHA for the "COMPONENTS_REPO_COMMIT" environment variable.
|
||||||
var_5: &components_repo_unit_tests_cache_key v7-angular-components-f428c00465dfcf8a020237f22532480eedbd2cb6
|
var_5: &components_repo_unit_tests_cache_key v6-angular-components-598db096e668aa7e9debd56eedfd127b7a55e371
|
||||||
var_6: &components_repo_unit_tests_cache_key_fallback v7-angular-components-
|
var_6: &components_repo_unit_tests_cache_key_fallback v6-angular-components-
|
||||||
|
|
||||||
# Workspace initially persisted by the `setup` job, and then enhanced by `build-npm-packages` and
|
# Workspace initially persisted by the `setup` job, and then enhanced by `build-npm-packages` and
|
||||||
# `build-ivy-npm-packages`.
|
# `build-ivy-npm-packages`.
|
||||||
@ -67,6 +67,9 @@ var_10: &only_on_master
|
|||||||
# **NOTE 1**: Pin to exact images using an ID (SHA). See https://circleci.com/docs/2.0/circleci-images/#using-a-docker-image-id-to-pin-an-image-to-a-fixed-version.
|
# **NOTE 1**: Pin to exact images using an ID (SHA). See https://circleci.com/docs/2.0/circleci-images/#using-a-docker-image-id-to-pin-an-image-to-a-fixed-version.
|
||||||
# (Using the tag in not necessary when pinning by ID, but include it anyway for documentation purposes.)
|
# (Using the tag in not necessary when pinning by ID, but include it anyway for documentation purposes.)
|
||||||
# **NOTE 2**: If you change the version of the docker images, also change the `cache_key` suffix.
|
# **NOTE 2**: If you change the version of the docker images, also change the `cache_key` suffix.
|
||||||
|
# **NOTE 3**: If you change the version of the `*-browsers` docker image, make sure the
|
||||||
|
# `--versions.chrome` arg in `integration/bazel-schematics/test.sh` specifies a
|
||||||
|
# ChromeDriver version that is compatible with the Chrome version in the image.
|
||||||
executors:
|
executors:
|
||||||
default-executor:
|
default-executor:
|
||||||
parameters:
|
parameters:
|
||||||
@ -117,7 +120,7 @@ commands:
|
|||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
# Install GTK+ graphical user interface (libgtk-3-0), advanced linux sound architecture (libasound2)
|
# Install GTK+ graphical user interface (libgtk-3-0), advanced linux sound architecture (libasound2)
|
||||||
# and network security service libraries (libnss3) & X11 Screen Saver extension library (libssx1)
|
# and network security service libraries (libnss3) & X11 Screen Saver extension library (libssx1)
|
||||||
# which are dependencies of chrome & needed for karma & protractor headless chrome tests.
|
# which are dependendies of chrome & needed for karma & protractor headless chrome tests.
|
||||||
# This is a very small install which takes around 7s in comparing to using the full
|
# This is a very small install which takes around 7s in comparing to using the full
|
||||||
# circleci/node:x.x.x-browsers image.
|
# circleci/node:x.x.x-browsers image.
|
||||||
sudo apt-get -y install libgtk-3-0 libasound2 libnss3 libxss1
|
sudo apt-get -y install libgtk-3-0 libasound2 libnss3 libxss1
|
||||||
@ -160,7 +163,7 @@ commands:
|
|||||||
description: Sets up a domain that resolves to the local host.
|
description: Sets up a domain that resolves to the local host.
|
||||||
steps:
|
steps:
|
||||||
- run:
|
- run:
|
||||||
name: Preparing environment for running tests on Sauce Labs.
|
name: Preparing environment for running tests on Saucelabs.
|
||||||
command: |
|
command: |
|
||||||
# For SauceLabs jobs, we set up a domain which resolves to the machine which launched
|
# For SauceLabs jobs, we set up a domain which resolves to the machine which launched
|
||||||
# the tunnel. We do this because devices are sometimes not able to properly resolve
|
# the tunnel. We do this because devices are sometimes not able to properly resolve
|
||||||
@ -172,13 +175,13 @@ commands:
|
|||||||
setSecretVar SAUCE_ACCESS_KEY $(echo $SAUCE_ACCESS_KEY | rev)
|
setSecretVar SAUCE_ACCESS_KEY $(echo $SAUCE_ACCESS_KEY | rev)
|
||||||
- run:
|
- run:
|
||||||
# Sets up a local domain in the machine's host file that resolves to the local
|
# Sets up a local domain in the machine's host file that resolves to the local
|
||||||
# host. This domain is helpful in Sauce Labs tests where devices are not able to
|
# host. This domain is helpful in Saucelabs tests where devices are not able to
|
||||||
# properly resolve `localhost` or `127.0.0.1` through the sauce-connect tunnel.
|
# properly resolve `localhost` or `127.0.0.1` through the sauce-connect tunnel.
|
||||||
name: Setting up alias domain for local host.
|
name: Setting up alias domain for local host.
|
||||||
command: echo "127.0.0.1 $SAUCE_LOCALHOST_ALIAS_DOMAIN" | sudo tee -a /etc/hosts
|
command: echo "127.0.0.1 $SAUCE_LOCALHOST_ALIAS_DOMAIN" | sudo tee -a /etc/hosts
|
||||||
|
|
||||||
# Normally this would be an individual job instead of a command.
|
# Normally this would be an individual job instead of a command.
|
||||||
# But startup and setup time for each individual windows job are high enough to discourage
|
# But startup and setup time for each invidual windows job are high enough to discourage
|
||||||
# many small jobs, so instead we use a command for setup unless the gain becomes significant.
|
# many small jobs, so instead we use a command for setup unless the gain becomes significant.
|
||||||
setup_win:
|
setup_win:
|
||||||
description: Setup windows node environment
|
description: Setup windows node environment
|
||||||
@ -269,8 +272,13 @@ jobs:
|
|||||||
- custom_attach_workspace
|
- custom_attach_workspace
|
||||||
- init_environment
|
- init_environment
|
||||||
|
|
||||||
- run: yarn -s tslint
|
- run: 'yarn bazel:format -mode=check ||
|
||||||
- run: yarn -s ng-dev format changed $CI_GIT_BASE_REVISION --check
|
(echo "BUILD files not formatted. Please run ''yarn bazel:format''" ; exit 1)'
|
||||||
|
# Run the skylark linter to check our Bazel rules
|
||||||
|
- run: 'yarn bazel:lint ||
|
||||||
|
(echo -e "\n.bzl files have lint errors. Please run ''yarn bazel:lint-fix''"; exit 1)'
|
||||||
|
|
||||||
|
- run: yarn -s lint --branch $CI_GIT_BASE_REVISION
|
||||||
- run: yarn -s ts-circular-deps:check
|
- run: yarn -s ts-circular-deps:check
|
||||||
- run: yarn -s ng-dev pullapprove verify
|
- run: yarn -s ng-dev pullapprove verify
|
||||||
- run: yarn -s ng-dev commit-message validate-range --range $CI_COMMIT_RANGE
|
- run: yarn -s ng-dev commit-message validate-range --range $CI_COMMIT_RANGE
|
||||||
@ -381,6 +389,10 @@ jobs:
|
|||||||
- custom_attach_workspace
|
- custom_attach_workspace
|
||||||
- init_environment
|
- init_environment
|
||||||
- install_chrome_libs
|
- install_chrome_libs
|
||||||
|
# Compile dependencies to ivy
|
||||||
|
# Running `ngcc` here (instead of implicitly via `ng build`) allows us to take advantage of
|
||||||
|
# the parallel, async mode speed-up (~20-25s on CI).
|
||||||
|
- run: yarn --cwd aio ngcc --properties es2015
|
||||||
# Build aio
|
# Build aio
|
||||||
- run: yarn --cwd aio build --progress=false
|
- run: yarn --cwd aio build --progress=false
|
||||||
# Lint the code
|
# Lint the code
|
||||||
@ -596,8 +608,8 @@ jobs:
|
|||||||
- run:
|
- run:
|
||||||
name: Decrypt github credentials
|
name: Decrypt github credentials
|
||||||
# We need ensure that the same default digest is used for encoding and decoding with
|
# We need ensure that the same default digest is used for encoding and decoding with
|
||||||
# OpenSSL. OpenSSL versions might have different default digests which can cause
|
# openssl. Openssl versions might have different default digests which can cause
|
||||||
# decryption failures based on the installed OpenSSL version. https://stackoverflow.com/a/39641378/4317734
|
# decryption failures based on the installed openssl version. https://stackoverflow.com/a/39641378/4317734
|
||||||
command: 'openssl aes-256-cbc -d -in .circleci/github_token -md md5 -k "${KEY}" -out ~/.git_credentials'
|
command: 'openssl aes-256-cbc -d -in .circleci/github_token -md md5 -k "${KEY}" -out ~/.git_credentials'
|
||||||
- run: ./scripts/ci/publish-build-artifacts.sh
|
- run: ./scripts/ci/publish-build-artifacts.sh
|
||||||
|
|
||||||
@ -731,8 +743,8 @@ jobs:
|
|||||||
- run: yarn --cwd packages/zone.js promisetest
|
- run: yarn --cwd packages/zone.js promisetest
|
||||||
- run: yarn --cwd packages/zone.js promisefinallytest
|
- run: yarn --cwd packages/zone.js promisefinallytest
|
||||||
- run: yarn bazel build //packages/zone.js:npm_package &&
|
- run: yarn bazel build //packages/zone.js:npm_package &&
|
||||||
cp dist/bin/packages/zone.js/npm_package/bundles/zone-mix.umd.js ./packages/zone.js/test/extra/ &&
|
cp dist/bin/packages/zone.js/npm_package/dist/zone-mix.js ./packages/zone.js/test/extra/ &&
|
||||||
cp dist/bin/packages/zone.js/npm_package/bundles/zone-patch-electron.umd.js ./packages/zone.js/test/extra/ &&
|
cp dist/bin/packages/zone.js/npm_package/dist/zone-patch-electron.js ./packages/zone.js/test/extra/ &&
|
||||||
yarn --cwd packages/zone.js electrontest
|
yarn --cwd packages/zone.js electrontest
|
||||||
- run: yarn --cwd packages/zone.js jesttest
|
- run: yarn --cwd packages/zone.js jesttest
|
||||||
|
|
||||||
|
131
.circleci/env.sh
131
.circleci/env.sh
@ -5,76 +5,87 @@ readonly projectDir=$(realpath "$(dirname ${BASH_SOURCE[0]})/..")
|
|||||||
readonly envHelpersPath="$projectDir/.circleci/env-helpers.inc.sh";
|
readonly envHelpersPath="$projectDir/.circleci/env-helpers.inc.sh";
|
||||||
readonly bashEnvCachePath="$projectDir/.circleci/bash_env_cache";
|
readonly bashEnvCachePath="$projectDir/.circleci/bash_env_cache";
|
||||||
|
|
||||||
# Load helpers and make them available everywhere (through `$BASH_ENV`).
|
if [ -f $bashEnvCachePath ]; then
|
||||||
source $envHelpersPath;
|
# Since a bash env cache is present, load this into the $BASH_ENV
|
||||||
echo "source $envHelpersPath;" >> $BASH_ENV;
|
cat "$bashEnvCachePath" >> $BASH_ENV;
|
||||||
|
echo "BASH environment loaded from cached value at $bashEnvCachePath";
|
||||||
|
else
|
||||||
|
# Since no bash env cache is present, build out $BASH_ENV values.
|
||||||
|
|
||||||
|
# Load helpers and make them available everywhere (through `$BASH_ENV`).
|
||||||
|
source $envHelpersPath;
|
||||||
|
echo "source $envHelpersPath;" >> $BASH_ENV;
|
||||||
|
|
||||||
|
|
||||||
####################################################################################################
|
####################################################################################################
|
||||||
# Define PUBLIC environment variables for CircleCI.
|
# Define PUBLIC environment variables for CircleCI.
|
||||||
####################################################################################################
|
####################################################################################################
|
||||||
# See https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables for more info.
|
# See https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables for more info.
|
||||||
####################################################################################################
|
####################################################################################################
|
||||||
setPublicVar CI "$CI"
|
setPublicVar CI "$CI"
|
||||||
setPublicVar PROJECT_ROOT "$projectDir";
|
setPublicVar PROJECT_ROOT "$projectDir";
|
||||||
setPublicVar CI_AIO_MIN_PWA_SCORE "95";
|
setPublicVar CI_AIO_MIN_PWA_SCORE "95";
|
||||||
# This is the branch being built; e.g. `pull/12345` for PR builds.
|
# This is the branch being built; e.g. `pull/12345` for PR builds.
|
||||||
setPublicVar CI_BRANCH "$CIRCLE_BRANCH";
|
setPublicVar CI_BRANCH "$CIRCLE_BRANCH";
|
||||||
setPublicVar CI_BUILD_URL "$CIRCLE_BUILD_URL";
|
setPublicVar CI_BUILD_URL "$CIRCLE_BUILD_URL";
|
||||||
setPublicVar CI_COMMIT "$CIRCLE_SHA1";
|
setPublicVar CI_COMMIT "$CIRCLE_SHA1";
|
||||||
# `CI_COMMIT_RANGE` is only used on push builds (a.k.a. non-PR, non-scheduled builds and rerun
|
# `CI_COMMIT_RANGE` is only used on push builds (a.k.a. non-PR, non-scheduled builds and rerun
|
||||||
# workflows of such builds).
|
# workflows of such builds).
|
||||||
setPublicVar CI_GIT_BASE_REVISION "${CIRCLE_GIT_BASE_REVISION}";
|
setPublicVar CI_GIT_BASE_REVISION "${CIRCLE_GIT_BASE_REVISION}";
|
||||||
setPublicVar CI_GIT_REVISION "${CIRCLE_GIT_REVISION}";
|
setPublicVar CI_GIT_REVISION "${CIRCLE_GIT_REVISION}";
|
||||||
setPublicVar CI_COMMIT_RANGE "$CIRCLE_GIT_BASE_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_PULL_REQUEST "${CIRCLE_PR_NUMBER:-false}";
|
||||||
setPublicVar CI_REPO_NAME "$CIRCLE_PROJECT_REPONAME";
|
setPublicVar CI_REPO_NAME "$CIRCLE_PROJECT_REPONAME";
|
||||||
setPublicVar CI_REPO_OWNER "$CIRCLE_PROJECT_USERNAME";
|
setPublicVar CI_REPO_OWNER "$CIRCLE_PROJECT_USERNAME";
|
||||||
setPublicVar CI_PR_REPONAME "$CIRCLE_PR_REPONAME";
|
setPublicVar CI_PR_REPONAME "$CIRCLE_PR_REPONAME";
|
||||||
setPublicVar CI_PR_USERNAME "$CIRCLE_PR_USERNAME";
|
setPublicVar CI_PR_USERNAME "$CIRCLE_PR_USERNAME";
|
||||||
|
|
||||||
|
|
||||||
####################################################################################################
|
####################################################################################################
|
||||||
# Define "lazy" PUBLIC environment variables for CircleCI.
|
# Define "lazy" PUBLIC environment variables for CircleCI.
|
||||||
# (I.e. functions to set an environment variable when called.)
|
# (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/')";
|
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.
|
# Define SECRET environment variables for CircleCI.
|
||||||
####################################################################################################
|
####################################################################################################
|
||||||
setSecretVar CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN "$AIO_DEPLOY_TOKEN";
|
setSecretVar CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN "$AIO_DEPLOY_TOKEN";
|
||||||
setSecretVar CI_SECRET_PAYLOAD_FIREBASE_TOKEN "$ANGULAR_PAYLOAD_TOKEN";
|
setSecretVar CI_SECRET_PAYLOAD_FIREBASE_TOKEN "$ANGULAR_PAYLOAD_TOKEN";
|
||||||
|
|
||||||
|
|
||||||
####################################################################################################
|
####################################################################################################
|
||||||
# Define SauceLabs environment variables for CircleCI.
|
# Define SauceLabs environment variables for CircleCI.
|
||||||
####################################################################################################
|
####################################################################################################
|
||||||
setPublicVar SAUCE_USERNAME "angular-framework";
|
setPublicVar SAUCE_USERNAME "angular-framework";
|
||||||
setSecretVar SAUCE_ACCESS_KEY "0c731274ed5f-cbc9-16f4-021a-9835e39f";
|
setSecretVar SAUCE_ACCESS_KEY "0c731274ed5f-cbc9-16f4-021a-9835e39f";
|
||||||
# TODO(josephperrott): Remove environment variables once all saucelabs tests are via bazel method.
|
# TODO(josephperrott): Remove environment variables once all saucelabs tests are via bazel method.
|
||||||
setPublicVar SAUCE_LOG_FILE /tmp/angular/sauce-connect.log
|
setPublicVar SAUCE_LOG_FILE /tmp/angular/sauce-connect.log
|
||||||
setPublicVar SAUCE_READY_FILE /tmp/angular/sauce-connect-ready-file.lock
|
setPublicVar SAUCE_READY_FILE /tmp/angular/sauce-connect-ready-file.lock
|
||||||
setPublicVar SAUCE_PID_FILE /tmp/angular/sauce-connect-pid-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}"
|
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
|
# 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.
|
# acquire CircleCI instances for too long if sauceconnect failed, we need a connect timeout.
|
||||||
setPublicVar SAUCE_READY_FILE_TIMEOUT 120
|
setPublicVar SAUCE_READY_FILE_TIMEOUT 120
|
||||||
|
|
||||||
|
|
||||||
####################################################################################################
|
####################################################################################################
|
||||||
# Define environment variables for the `angular/components` repo unit tests job.
|
# 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
|
# 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
|
# 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
|
# their separate build setups. **NOTE**: When updating the temporary directory, also update
|
||||||
# the `save_cache` path configuration in `config.yml`
|
# the `save_cache` path configuration in `config.yml`
|
||||||
setPublicVar COMPONENTS_REPO_TMP_DIR "/tmp/angular-components-repo"
|
setPublicVar COMPONENTS_REPO_TMP_DIR "/tmp/angular-components-repo"
|
||||||
setPublicVar COMPONENTS_REPO_URL "https://github.com/angular/components.git"
|
setPublicVar COMPONENTS_REPO_URL "https://github.com/angular/components.git"
|
||||||
setPublicVar COMPONENTS_REPO_BRANCH "master"
|
setPublicVar COMPONENTS_REPO_BRANCH "master"
|
||||||
# **NOTE**: When updating the commit SHA, also update the cache key in the CircleCI `config.yml`.
|
# **NOTE**: When updating the commit SHA, also update the cache key in the CircleCI `config.yml`.
|
||||||
setPublicVar COMPONENTS_REPO_COMMIT "f428c00465dfcf8a020237f22532480eedbd2cb6"
|
setPublicVar COMPONENTS_REPO_COMMIT "598db096e668aa7e9debd56eedfd127b7a55e371"
|
||||||
|
|
||||||
|
# Save the created BASH_ENV into the bash env cache file.
|
||||||
|
cat "$BASH_ENV" >> $bashEnvCachePath;
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
####################################################################################################
|
####################################################################################################
|
||||||
|
@ -60,15 +60,14 @@ if (require.resolve === module) {
|
|||||||
|
|
||||||
// Helpers
|
// Helpers
|
||||||
function _main(args) {
|
function _main(args) {
|
||||||
triggerWebhook(...args)
|
triggerWebhook(...args).
|
||||||
.then(
|
then(({statusCode, responseText}) => (200 <= statusCode && statusCode < 400) ?
|
||||||
({statusCode, responseText}) => (200 <= statusCode && statusCode < 400) ?
|
console.log(`Status: ${statusCode}\n${responseText}`) :
|
||||||
console.log(`Status: ${statusCode}\n${responseText}`) :
|
Promise.reject(new Error(`Request failed (status: ${statusCode}): ${responseText}`))).
|
||||||
Promise.reject(new Error(`Request failed (status: ${statusCode}): ${responseText}`)))
|
catch(err => {
|
||||||
.catch(err => {
|
console.error(err);
|
||||||
console.error(err);
|
process.exit(1);
|
||||||
process.exit(1);
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function postJson(url, data) {
|
function postJson(url, data) {
|
||||||
@ -78,12 +77,15 @@ function postJson(url, data) {
|
|||||||
const statusCode = res.statusCode || -1;
|
const statusCode = res.statusCode || -1;
|
||||||
let responseText = '';
|
let responseText = '';
|
||||||
|
|
||||||
res.on('error', reject)
|
res.
|
||||||
.on('data', d => responseText += d)
|
on('error', reject).
|
||||||
.on('end', () => resolve({statusCode, responseText}));
|
on('data', d => responseText += d).
|
||||||
|
on('end', () => resolve({statusCode, responseText}));
|
||||||
};
|
};
|
||||||
|
|
||||||
request(url, opts, onResponse).on('error', reject).end(JSON.stringify(data));
|
request(url, opts, onResponse).
|
||||||
|
on('error', reject).
|
||||||
|
end(JSON.stringify(data));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
47
.dev-infra.json
Normal file
47
.dev-infra.json
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
{
|
||||||
|
"commitMessage": {
|
||||||
|
"maxLength": 120,
|
||||||
|
"minBodyLength": 0,
|
||||||
|
"types": [
|
||||||
|
"build",
|
||||||
|
"ci",
|
||||||
|
"docs",
|
||||||
|
"feat",
|
||||||
|
"fix",
|
||||||
|
"perf",
|
||||||
|
"refactor",
|
||||||
|
"release",
|
||||||
|
"style",
|
||||||
|
"test"
|
||||||
|
],
|
||||||
|
"scopes": [
|
||||||
|
"animations",
|
||||||
|
"bazel",
|
||||||
|
"benchpress",
|
||||||
|
"changelog",
|
||||||
|
"common",
|
||||||
|
"compiler",
|
||||||
|
"compiler-cli",
|
||||||
|
"core",
|
||||||
|
"dev-infra",
|
||||||
|
"docs-infra",
|
||||||
|
"elements",
|
||||||
|
"forms",
|
||||||
|
"http",
|
||||||
|
"language-service",
|
||||||
|
"localize",
|
||||||
|
"ngcc",
|
||||||
|
"packaging",
|
||||||
|
"platform-browser",
|
||||||
|
"platform-browser-dynamic",
|
||||||
|
"platform-server",
|
||||||
|
"platform-webworker",
|
||||||
|
"platform-webworker-dynamic",
|
||||||
|
"router",
|
||||||
|
"service-worker",
|
||||||
|
"upgrade",
|
||||||
|
"ve",
|
||||||
|
"zone.js"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
69
.github/ISSUE_TEMPLATE/1-bug-report.md
vendored
Normal file
69
.github/ISSUE_TEMPLATE/1-bug-report.md
vendored
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
---
|
||||||
|
name: "\U0001F41EBug report"
|
||||||
|
about: Report a bug in the Angular Framework
|
||||||
|
---
|
||||||
|
<!--🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅
|
||||||
|
|
||||||
|
Oh hi there! 😄
|
||||||
|
|
||||||
|
To expedite issue processing please search open and closed issues before submitting a new one.
|
||||||
|
Existing issues often contain information about workarounds, resolution, or progress updates.
|
||||||
|
|
||||||
|
🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅-->
|
||||||
|
|
||||||
|
|
||||||
|
# 🐞 bug report
|
||||||
|
|
||||||
|
### Affected Package
|
||||||
|
<!-- Can you pin-point one or more @angular/* packages as the source of the bug? -->
|
||||||
|
<!-- ✍️edit: --> The issue is caused by package @angular/....
|
||||||
|
|
||||||
|
|
||||||
|
### Is this a regression?
|
||||||
|
|
||||||
|
<!-- Did this behavior use to work in the previous version? -->
|
||||||
|
<!-- ✍️--> Yes, the previous version in which this bug was not present was: ....
|
||||||
|
|
||||||
|
|
||||||
|
### Description
|
||||||
|
|
||||||
|
<!-- ✍️--> A clear and concise description of the problem...
|
||||||
|
|
||||||
|
|
||||||
|
## 🔬 Minimal Reproduction
|
||||||
|
<!--
|
||||||
|
Please create and share minimal reproduction of the issue starting with this template: https://stackblitz.com/fork/angular-issue-repro2
|
||||||
|
-->
|
||||||
|
<!-- ✍️--> https://stackblitz.com/...
|
||||||
|
|
||||||
|
<!--
|
||||||
|
If StackBlitz is not suitable for reproduction of your issue, please create a minimal GitHub repository with the reproduction of the issue.
|
||||||
|
A good way to make a minimal reproduction is to create a new app via `ng new repro-app` and add the minimum possible code to show the problem.
|
||||||
|
Share the link to the repo below along with step-by-step instructions to reproduce the problem, as well as expected and actual behavior.
|
||||||
|
|
||||||
|
Issues that don't have enough info and can't be reproduced will be closed.
|
||||||
|
|
||||||
|
You can read more about issue submission guidelines here: https://github.com/angular/angular/blob/master/CONTRIBUTING.md#-submitting-an-issue
|
||||||
|
-->
|
||||||
|
|
||||||
|
## 🔥 Exception or Error
|
||||||
|
<pre><code>
|
||||||
|
<!-- If the issue is accompanied by an exception or an error, please share it below: -->
|
||||||
|
<!-- ✍️-->
|
||||||
|
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
|
||||||
|
## 🌍 Your Environment
|
||||||
|
|
||||||
|
**Angular Version:**
|
||||||
|
<pre><code>
|
||||||
|
<!-- run `ng version` and paste output below -->
|
||||||
|
<!-- ✍️-->
|
||||||
|
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
**Anything else relevant?**
|
||||||
|
<!-- ✍️Is this a browser specific issue? If so, please specify the browser and version. -->
|
||||||
|
|
||||||
|
<!-- ✍️Do any of these matter: operating system, IDE, package manager, HTTP server, ...? If so, please mention it below. -->
|
32
.github/ISSUE_TEMPLATE/2-feature-request.md
vendored
Normal file
32
.github/ISSUE_TEMPLATE/2-feature-request.md
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
---
|
||||||
|
name: "\U0001F680Feature request"
|
||||||
|
about: Suggest a feature for Angular Framework
|
||||||
|
|
||||||
|
---
|
||||||
|
<!--🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅
|
||||||
|
|
||||||
|
Oh hi there! 😄
|
||||||
|
|
||||||
|
To expedite issue processing please search open and closed issues before submitting a new one.
|
||||||
|
Existing issues often contain information about workarounds, resolution, or progress updates.
|
||||||
|
|
||||||
|
🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅-->
|
||||||
|
|
||||||
|
|
||||||
|
# 🚀 feature request
|
||||||
|
|
||||||
|
### Relevant Package
|
||||||
|
<!-- Can you pin-point one or more @angular/* packages the are relevant for this feature request? -->
|
||||||
|
<!-- ✍️edit: --> This feature request is for @angular/....
|
||||||
|
|
||||||
|
|
||||||
|
### Description
|
||||||
|
<!-- ✍️--> A clear and concise description of the problem or missing capability...
|
||||||
|
|
||||||
|
|
||||||
|
### Describe the solution you'd like
|
||||||
|
<!-- ✍️--> If you have a solution in mind, please describe it.
|
||||||
|
|
||||||
|
|
||||||
|
### Describe alternatives you've considered
|
||||||
|
<!-- ✍️--> Have you considered any alternative solutions or workarounds?
|
55
.github/ISSUE_TEMPLATE/3-docs-bug.md
vendored
Normal file
55
.github/ISSUE_TEMPLATE/3-docs-bug.md
vendored
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
---
|
||||||
|
name: "📚 Docs or angular.io issue report"
|
||||||
|
about: Report an issue in Angular's documentation or angular.io application
|
||||||
|
|
||||||
|
---
|
||||||
|
<!--🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅
|
||||||
|
|
||||||
|
Oh hi there! 😄
|
||||||
|
|
||||||
|
To expedite issue processing please search open and closed issues before submitting a new one.
|
||||||
|
Existing issues often contain information about workarounds, resolution, or progress updates.
|
||||||
|
|
||||||
|
🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅-->
|
||||||
|
|
||||||
|
# 📚 Docs or angular.io bug report
|
||||||
|
|
||||||
|
### Description
|
||||||
|
|
||||||
|
<!-- ✍️edit:--> A clear and concise description of the problem...
|
||||||
|
|
||||||
|
|
||||||
|
## 🔬 Minimal Reproduction
|
||||||
|
|
||||||
|
### What's the affected URL?**
|
||||||
|
<!-- ✍️edit:--> https://angular.io/...
|
||||||
|
|
||||||
|
### Reproduction Steps**
|
||||||
|
<!-- If applicable please list the steps to take to reproduce the issue -->
|
||||||
|
<!-- ✍️edit:-->
|
||||||
|
|
||||||
|
### Expected vs Actual Behavior**
|
||||||
|
<!-- If applicable please describe the difference between the expected and actual behavior after following the repro steps. -->
|
||||||
|
<!-- ✍️edit:-->
|
||||||
|
|
||||||
|
|
||||||
|
## 📷Screenshot
|
||||||
|
<!-- Often a screenshot can help to capture the issue better than a long description. -->
|
||||||
|
<!-- ✍️upload a screenshot:-->
|
||||||
|
|
||||||
|
|
||||||
|
## 🔥 Exception or Error
|
||||||
|
<pre><code>
|
||||||
|
<!-- If the issue is accompanied by an exception or an error, please share it below: -->
|
||||||
|
<!-- ✍️-->
|
||||||
|
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
|
||||||
|
## 🌍 Your Environment
|
||||||
|
|
||||||
|
### Browser info
|
||||||
|
<!-- ✍️Is this a browser specific issue? If so, please specify the device, browser, and version. -->
|
||||||
|
|
||||||
|
### Anything else relevant?
|
||||||
|
<!-- ✍️Please provide additional info if necessary. -->
|
11
.github/ISSUE_TEMPLATE/4-security-issue-disclosure.md
vendored
Normal file
11
.github/ISSUE_TEMPLATE/4-security-issue-disclosure.md
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
name: ⚠️ Security issue disclosure
|
||||||
|
about: Report a security issue in Angular Framework, Material, or CLI
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑
|
||||||
|
|
||||||
|
Please read https://angular.io/guide/security#report-issues on how to disclose security related issues.
|
||||||
|
|
||||||
|
🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑
|
16
.github/ISSUE_TEMPLATE/5-support-request.md
vendored
Normal file
16
.github/ISSUE_TEMPLATE/5-support-request.md
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
---
|
||||||
|
name: "❓Support request"
|
||||||
|
about: Questions and requests for support
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑
|
||||||
|
|
||||||
|
Please do not file questions or support requests on the GitHub issues tracker.
|
||||||
|
|
||||||
|
You can get your questions answered using other communication channels. Please see:
|
||||||
|
https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
|
||||||
|
|
||||||
|
Thank you!
|
||||||
|
|
||||||
|
🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑
|
13
.github/ISSUE_TEMPLATE/6-angular-cli.md
vendored
Normal file
13
.github/ISSUE_TEMPLATE/6-angular-cli.md
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
name: "\U0001F6E0️Angular CLI"
|
||||||
|
about: Issues and feature requests for Angular CLI
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑
|
||||||
|
|
||||||
|
Please file any Angular CLI issues at: https://github.com/angular/angular-cli/issues/new
|
||||||
|
|
||||||
|
For the time being, we keep Angular CLI issues in a separate repository.
|
||||||
|
|
||||||
|
🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑
|
13
.github/ISSUE_TEMPLATE/7-angular-components.md
vendored
Normal file
13
.github/ISSUE_TEMPLATE/7-angular-components.md
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
name: "\U0001F48EAngular Components"
|
||||||
|
about: Issues and feature requests for Angular Components
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑
|
||||||
|
|
||||||
|
Please file any Angular Components issues at: https://github.com/angular/components/issues/new
|
||||||
|
|
||||||
|
For the time being, we keep Angular Components issues in a separate repository.
|
||||||
|
|
||||||
|
🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑
|
22
.github/ISSUE_TEMPLATE/8-translate-docs.md
vendored
22
.github/ISSUE_TEMPLATE/8-translate-docs.md
vendored
@ -1,22 +0,0 @@
|
|||||||
---
|
|
||||||
name: "📚Traducir doc al español"
|
|
||||||
about: Solicitud para traducir ciertos docs al español
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
📚Traducir: <!-- ✍️ editar: --> creating-libraries.md
|
|
||||||
|
|
||||||
<!--🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅
|
|
||||||
|
|
||||||
Traducción de la documentación oficial de Angular a español
|
|
||||||
|
|
||||||
🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅-->
|
|
||||||
|
|
||||||
|
|
||||||
## Nombre del archivo:
|
|
||||||
<!-- ✍️ editar: --> creating-libraries.md
|
|
||||||
|
|
||||||
|
|
||||||
## Ruta donde se encuentra el archivo dentro del proyecto de Angular
|
|
||||||
|
|
||||||
<!-- ✍️ editar: --> https://github.com/angular-hispano/angular/blob/master/aio/content/guide/creating-libraries.md
|
|
62
.github/PULL_REQUEST_TEMPLATE.md
vendored
62
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -1,35 +1,43 @@
|
|||||||
## Lista de Verificación del PR
|
## PR Checklist
|
||||||
Comprueba si tu PR cumple los siguientes requisitos:
|
Please check if your PR fulfills the following requirements:
|
||||||
|
|
||||||
- [ ] El mensaje de commit conforme con [nuestras reglas](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#commit)
|
- [ ] The commit message follows our guidelines: https://github.com/angular/angular/blob/master/CONTRIBUTING.md#commit
|
||||||
- [ ] Prueba los cambios que agregaste (arreglo de bugs / funcionalidades)
|
- [ ] Tests for the changes have been added (for bug fixes / features)
|
||||||
- [ ] Revisa tus traducciones o cambios de contenido
|
- [ ] Docs have been added / updated (for bug fixes / features)
|
||||||
- [ ] Consulté el [diccionario de términos](https://github.com/angular-hispano/angular/issues/9) en español
|
|
||||||
- [ ] Se han creado dos archivos con la extensión correspondiente(.en.md para el archivo en inglés y .md para el Archivo en español)
|
|
||||||
- [ ] PR enlazada con el issue correspondiente
|
|
||||||
|
|
||||||
|
|
||||||
## Tipo de PR
|
## PR Type
|
||||||
¿Qué tipo de cambio introduce este PR?
|
What kind of change does this PR introduce?
|
||||||
|
|
||||||
<!-- Marca con una "x" las opciones que aplican. -->
|
<!-- Please check the one that applies to this PR using "x". -->
|
||||||
|
|
||||||
- [ ] Bugfix
|
- [ ] Bugfix
|
||||||
- [ ] Funcionalidad
|
- [ ] Feature
|
||||||
- [ ] Actualizar el estilo del código (formato, variables locales)
|
- [ ] Code style update (formatting, local variables)
|
||||||
- [ ] Refactorización (no cambios en la funcionalidad, no cambios en el api)
|
- [ ] Refactoring (no functional changes, no api changes)
|
||||||
- [ ] Cambios relacionados al build
|
- [ ] Build related changes
|
||||||
- [ ] Cambios relacionados al CI (Integración continua)
|
- [ ] CI related changes
|
||||||
- [ ] Cambios en el contenido de la documentación
|
- [ ] Documentation content changes
|
||||||
- [ ] Cambios en la aplicación / infrastructura de angular.io
|
- [ ] angular.io application / infrastructure changes
|
||||||
- [ ] Otro... Por favor describela:
|
- [ ] Other... Please describe:
|
||||||
|
|
||||||
## ¿Cuál es el comportamiento actual?
|
|
||||||
<!-- Describe el comportamiento actual que está modificando o vincule a un problema relevante.
|
|
||||||
-->
|
|
||||||
|
|
||||||
|
|
||||||
## ¿Cuál es el nuevo comportamiento?
|
## What is the current behavior?
|
||||||
<!--
|
<!-- Please describe the current behavior that you are modifying, or link to a relevant issue. -->
|
||||||
Ejemplo: Archivo en inglés traducido al español
|
|
||||||
-->
|
Issue Number: N/A
|
||||||
|
|
||||||
|
|
||||||
|
## What is the new behavior?
|
||||||
|
|
||||||
|
|
||||||
|
## Does this PR introduce a breaking change?
|
||||||
|
|
||||||
|
- [ ] Yes
|
||||||
|
- [ ] No
|
||||||
|
|
||||||
|
|
||||||
|
<!-- If this PR contains a breaking change, please describe the impact and migration path for existing applications below. -->
|
||||||
|
|
||||||
|
|
||||||
|
## Other information
|
||||||
|
6
.github/angular-robot.yml
vendored
6
.github/angular-robot.yml
vendored
@ -154,12 +154,6 @@ triage:
|
|||||||
-
|
-
|
||||||
- "type: RFC / Discussion / question"
|
- "type: RFC / Discussion / question"
|
||||||
- "comp: *"
|
- "comp: *"
|
||||||
-
|
|
||||||
- "type: confusing"
|
|
||||||
- "comp: *"
|
|
||||||
-
|
|
||||||
- "type: use-case"
|
|
||||||
- "comp: *"
|
|
||||||
|
|
||||||
# options for the triage PR plugin
|
# options for the triage PR plugin
|
||||||
triagePR:
|
triagePR:
|
||||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -42,6 +42,3 @@ yarn-error.log
|
|||||||
|
|
||||||
.notes.md
|
.notes.md
|
||||||
baseline.json
|
baseline.json
|
||||||
|
|
||||||
# Ignore .history for the xyz.local-history VSCode extension
|
|
||||||
.history
|
|
||||||
|
145
.gitmessage
145
.gitmessage
@ -1,145 +0,0 @@
|
|||||||
<type>(<scope>): <summary>
|
|
||||||
|
|
||||||
<Describe the motivation behind this change - explain WHY you are making this change. Wrap all lines
|
|
||||||
at 100 characters.>
|
|
||||||
|
|
||||||
Fixes #<issue number>
|
|
||||||
|
|
||||||
# ────────────────────────────────────────── 100 chars ────────────────────────────────────────────┤
|
|
||||||
|
|
||||||
|
|
||||||
# Example Commit Messages
|
|
||||||
# =======================
|
|
||||||
|
|
||||||
|
|
||||||
# ─── Example: Simple refactor ────────────────────────────────────────────────────────────────────┤
|
|
||||||
# refactor(core): rename refreshDynamicEmbeddedViews to refreshEmbeddedViews
|
|
||||||
#
|
|
||||||
# Improve code readability. The original name no longer matches how the function is used.
|
|
||||||
# ─────────────────────────────────────────────────────────────────────────────────────────────────┤
|
|
||||||
|
|
||||||
|
|
||||||
# ─── Example: Simple docs change ─────────────────────────────────────────────────────────────────┤
|
|
||||||
# docs: clarify the service limitation in providers.md guide
|
|
||||||
#
|
|
||||||
# Fixes #36332
|
|
||||||
# ─────────────────────────────────────────────────────────────────────────────────────────────────┤
|
|
||||||
|
|
||||||
|
|
||||||
# ─── Example: A bug fix ──────────────────────────────────────────────────────────────────────────┤
|
|
||||||
# fix(ngcc): ensure lockfile is removed when `analyzeFn` fails
|
|
||||||
#
|
|
||||||
# Previously an error thrown in the `analyzeFn` would cause the ngcc process to exit immediately
|
|
||||||
# without removing the lockfile, and potentially before the unlocker process had been successfully
|
|
||||||
# spawned resulting in the lockfile being orphaned and left behind.
|
|
||||||
#
|
|
||||||
# Now we catch these errors and remove the lockfile as needed.
|
|
||||||
# ─────────────────────────────────────────────────────────────────────────────────────────────────┤
|
|
||||||
|
|
||||||
|
|
||||||
# ─── Example: Breaking change ────────────────────────────────────────────────────────────────────┤
|
|
||||||
# feat(bazel): simplify ng_package by dropping esm5 and fesm5
|
|
||||||
#
|
|
||||||
# esm5 and fesm5 distributions are no longer needed and have been deprecated in the past.
|
|
||||||
#
|
|
||||||
# https://v9.angular.io/guide/deprecations#esm5-and-fesm5-code-formats-in-angular-npm-packages
|
|
||||||
#
|
|
||||||
# This commit modifies ng_package to no longer distribute these two formats in npm packages built by
|
|
||||||
# ng_package (e.g. @angular/core).
|
|
||||||
#
|
|
||||||
# This commit intentionally doesn't fully clean up the ng_package rule to remove all traces of esm5
|
|
||||||
# and fems5 build artifacts as that is a bigger cleanup and currently we are narrowing down the
|
|
||||||
# scope of this change to the MVP needed for v10, which in this case is 'do not put esm5 and fesm5'
|
|
||||||
# into the npm packages.
|
|
||||||
#
|
|
||||||
# More cleanup to follow: https://angular-team.atlassian.net/browse/FW-2143
|
|
||||||
#
|
|
||||||
# BREAKING CHANGE: esm5 and fesm5 format is no longer distributed in Angular's npm packages e.g.
|
|
||||||
# @angular/core
|
|
||||||
#
|
|
||||||
# Angular CLI will automatically downlevel the code to es5 if differential loading is enabled in the
|
|
||||||
# Angular project, so no action is required from Angular CLI users.
|
|
||||||
#
|
|
||||||
# If you are not using Angular CLI to build your application or library, and you need to be able to
|
|
||||||
# build es5 artifacts, then you will need to downlevel the distributed Angular code to es5 on your
|
|
||||||
# own.
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Fixes #1234
|
|
||||||
# ─────────────────────────────────────────────────────────────────────────────────────────────────┤
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Angular Commit Message Format
|
|
||||||
# =============================
|
|
||||||
#
|
|
||||||
# The full specification of the Angular Commit Message Format can be found at
|
|
||||||
# https://github.com/angular/angular/blob/master/CONTRIBUTING.md#commit
|
|
||||||
#
|
|
||||||
# The following is an excerpt of the specification with the most commonly needed info.
|
|
||||||
#
|
|
||||||
# Each commit message consists of a *header*, a *body*, and a *footer*.
|
|
||||||
#
|
|
||||||
# <header>
|
|
||||||
# <BLANK LINE>
|
|
||||||
# <body>
|
|
||||||
# <BLANK LINE>
|
|
||||||
# <footer>
|
|
||||||
#
|
|
||||||
# The header is mandatory.
|
|
||||||
#
|
|
||||||
# The body is mandatory for all commits except for those of scope "docs". When the body is required
|
|
||||||
# it must be at least 20 characters long.
|
|
||||||
#
|
|
||||||
# The footer is optional.
|
|
||||||
#
|
|
||||||
# Any line of the commit message cannot be longer than 100 characters.
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Commit Message Header
|
|
||||||
# ---------------------
|
|
||||||
#
|
|
||||||
# <type>(<scope>): <short summary>
|
|
||||||
# │ │ │
|
|
||||||
# │ │ └─⫸ Summary in present tense. Not capitalized. No period at the end.
|
|
||||||
# │ │
|
|
||||||
# │ └─⫸ Commit Scope: animations|bazel|benchpress|common|compiler|compiler-cli|core|
|
|
||||||
# │ elements|forms|http|language-service|localize|platform-browser|
|
|
||||||
# │ platform-browser-dynamic|platform-server|platform-webworker|
|
|
||||||
# │ platform-webworker-dynamic|router|service-worker|upgrade|zone.js|
|
|
||||||
# │ packaging|changelog|dev-infra|docs-infra|migrations|ngcc|ve
|
|
||||||
# │ https://github.com/angular/angular/blob/master/CONTRIBUTING.md#scope
|
|
||||||
# │
|
|
||||||
# └─⫸ Commit Type: build|ci|docs|feat|fix|perf|refactor|style|test
|
|
||||||
# https://github.com/angular/angular/blob/master/CONTRIBUTING.md#type
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Commit Message Body
|
|
||||||
# ---------------------
|
|
||||||
#
|
|
||||||
# Just as in the summary, use the imperative, present tense: "fix" not "fixed" nor "fixes".
|
|
||||||
#
|
|
||||||
# Explain the motivation for the change in the commit message body. This commit message should
|
|
||||||
# explain WHY you are making the change. You can include a comparison of the previous behavior with
|
|
||||||
# the new behavior in order to illustrate the impact of the change.
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Commit Message Footer
|
|
||||||
# ---------------------
|
|
||||||
#
|
|
||||||
# The footer can contain information about breaking changes and is also the place to reference
|
|
||||||
# GitHub issues, Jira tickets, and other PRs that this commit closes or is related to.
|
|
||||||
#
|
|
||||||
# ```
|
|
||||||
# BREAKING CHANGE: <breaking change summary>
|
|
||||||
# <BLANK LINE>
|
|
||||||
# <breaking change description + migration instructions>
|
|
||||||
# <BLANK LINE>
|
|
||||||
# <BLANK LINE>
|
|
||||||
# Fixes #<issue number>
|
|
||||||
# ```
|
|
||||||
#
|
|
||||||
# Breaking Change section should start with the phrase "BREAKING CHANGE: " followed by a summary of
|
|
||||||
# the breaking change, a blank line, and a detailed description of the breaking change that also
|
|
||||||
# includes migration instructions.
|
|
||||||
#
|
|
@ -1,52 +0,0 @@
|
|||||||
import {CommitMessageConfig} from '../dev-infra/commit-message/config';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The configuration for `ng-dev commit-message` commands.
|
|
||||||
*/
|
|
||||||
export const commitMessage: CommitMessageConfig = {
|
|
||||||
maxLineLength: 120,
|
|
||||||
minBodyLength: 20,
|
|
||||||
minBodyLengthTypeExcludes: ['docs'],
|
|
||||||
types: [
|
|
||||||
'build',
|
|
||||||
'ci',
|
|
||||||
'docs',
|
|
||||||
'feat',
|
|
||||||
'fix',
|
|
||||||
'perf',
|
|
||||||
'refactor',
|
|
||||||
'release',
|
|
||||||
'style',
|
|
||||||
'test',
|
|
||||||
],
|
|
||||||
scopes: [
|
|
||||||
'animations',
|
|
||||||
'bazel',
|
|
||||||
'benchpress',
|
|
||||||
'changelog',
|
|
||||||
'common',
|
|
||||||
'compiler',
|
|
||||||
'compiler-cli',
|
|
||||||
'core',
|
|
||||||
'dev-infra',
|
|
||||||
'docs-infra',
|
|
||||||
'elements',
|
|
||||||
'forms',
|
|
||||||
'http',
|
|
||||||
'language-service',
|
|
||||||
'localize',
|
|
||||||
'migrations',
|
|
||||||
'ngcc',
|
|
||||||
'packaging',
|
|
||||||
'platform-browser',
|
|
||||||
'platform-browser-dynamic',
|
|
||||||
'platform-server',
|
|
||||||
'platform-webworker',
|
|
||||||
'platform-webworker-dynamic',
|
|
||||||
'router',
|
|
||||||
'service-worker',
|
|
||||||
'upgrade',
|
|
||||||
've',
|
|
||||||
'zone.js',
|
|
||||||
]
|
|
||||||
};
|
|
@ -1,11 +0,0 @@
|
|||||||
import {commitMessage} from './commit-message';
|
|
||||||
import {format} from './format';
|
|
||||||
import {github} from './github';
|
|
||||||
import {merge} from './merge';
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
commitMessage,
|
|
||||||
format,
|
|
||||||
github,
|
|
||||||
merge,
|
|
||||||
};
|
|
@ -1,22 +0,0 @@
|
|||||||
import {FormatConfig} from '../dev-infra/format/config';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Configuration for the `ng-dev format` command.
|
|
||||||
*/
|
|
||||||
export const format: FormatConfig = {
|
|
||||||
'clang-format': {
|
|
||||||
'matchers': [
|
|
||||||
'**/*.{js,ts}',
|
|
||||||
// TODO: burn down format failures and remove aio and integration exceptions.
|
|
||||||
'!aio/**',
|
|
||||||
'!integration/**',
|
|
||||||
// Both third_party and .yarn are directories containing copied code which should
|
|
||||||
// not be modified.
|
|
||||||
'!third_party/**',
|
|
||||||
'!.yarn/**',
|
|
||||||
// Do not format d.ts files as they are generated
|
|
||||||
'!**/*.d.ts',
|
|
||||||
]
|
|
||||||
},
|
|
||||||
'buildifier': true
|
|
||||||
};
|
|
@ -1,15 +0,0 @@
|
|||||||
# The file is inert unless it's explicitly included into the local git config via:
|
|
||||||
#
|
|
||||||
# ```
|
|
||||||
# git config --add include.path '../.ng-dev/gitconfig'
|
|
||||||
# ```
|
|
||||||
#
|
|
||||||
# Calling that command will append the following into `.git/config` of the current git workspace
|
|
||||||
# (i.e. $GIT_DIR, typically `angular/.git/config`):
|
|
||||||
#
|
|
||||||
# ```
|
|
||||||
# [include]
|
|
||||||
# path = ../.ng-dev/gitconfig
|
|
||||||
# ```
|
|
||||||
[commit]
|
|
||||||
template = .gitmessage
|
|
@ -1,11 +0,0 @@
|
|||||||
import {GithubConfig} from '../dev-infra/utils/config';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Github configuration for the `ng-dev` command. This repository is used as
|
|
||||||
* remote for the merge script and other utilities like `ng-dev pr rebase`.
|
|
||||||
*/
|
|
||||||
|
|
||||||
export const github: GithubConfig = {
|
|
||||||
owner: 'angular',
|
|
||||||
name: 'angular'
|
|
||||||
};
|
|
@ -1,38 +0,0 @@
|
|||||||
import {MergeConfig} from '../dev-infra/pr/merge/config';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Configuration for the merge tool in `ng-dev`. This sets up the labels which
|
|
||||||
* are respected by the merge script (e.g. the target labels).
|
|
||||||
*/
|
|
||||||
export const merge = (): MergeConfig => {
|
|
||||||
// TODO: resume dynamically determining patch branch
|
|
||||||
const patch = '10.0.x';
|
|
||||||
return {
|
|
||||||
githubApiMerge: false,
|
|
||||||
claSignedLabel: 'cla: yes',
|
|
||||||
mergeReadyLabel: /^PR action: merge(-assistance)?/,
|
|
||||||
caretakerNoteLabel: 'PR action: merge-assistance',
|
|
||||||
commitMessageFixupLabel: 'commit message fixup',
|
|
||||||
labels: [
|
|
||||||
{
|
|
||||||
pattern: 'PR target: master-only',
|
|
||||||
branches: ['master'],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
pattern: 'PR target: patch-only',
|
|
||||||
branches: [patch],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
pattern: 'PR target: master & patch',
|
|
||||||
branches: ['master', patch],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
requiredBaseCommits: {
|
|
||||||
// PRs that target either `master` or the patch branch, need to be rebased
|
|
||||||
// on top of the latest commit message validation fix.
|
|
||||||
// These SHAs are the commits that update the required license text in the header.
|
|
||||||
'master': '5aeb9a4124922d8ac08eb73b8f322905a32b0b3a',
|
|
||||||
[patch]: '27b95ba64a5d99757f4042073fd1860e20e3ed24'
|
|
||||||
},
|
|
||||||
};
|
|
||||||
};
|
|
352
.pullapprove.yml
352
.pullapprove.yml
@ -34,8 +34,41 @@
|
|||||||
####################################################################################
|
####################################################################################
|
||||||
# GitHub usernames
|
# GitHub usernames
|
||||||
####################################################################################
|
####################################################################################
|
||||||
# See reviewer list under `required-minimum-review` group. Team member names and
|
# aikidave - Dave Shevitz
|
||||||
# usernames are managed there.
|
# alan-agius4 - Alan Agius
|
||||||
|
# alxhub - Alex Rickabaugh
|
||||||
|
# AndrewKushnir - Andrew Kushnir
|
||||||
|
# andrewseguin - Andrew Seguin
|
||||||
|
# atscott - Andrew Scott
|
||||||
|
# ayazhafiz - Ayaz Hafiz
|
||||||
|
# clydin - Charles Lyding
|
||||||
|
# crisbeto - Kristiyan Kostadinov
|
||||||
|
# dennispbrown - Denny Brown
|
||||||
|
# devversion - Paul Gschwendtner
|
||||||
|
# dgp1130 - Doug Parker
|
||||||
|
# filipesilva - Filipe Silva
|
||||||
|
# gkalpak - Georgios Kalpakas
|
||||||
|
# gregmagolan - Greg Magolan
|
||||||
|
# IgorMinar - Igor Minar
|
||||||
|
# jbogarthyde - Judy Bogart
|
||||||
|
# jelbourn - Jeremy Elbourn
|
||||||
|
# JiaLiPassion - Jia Li
|
||||||
|
# JoostK - Joost Koehoorn
|
||||||
|
# josephperrott - Joey Perrott
|
||||||
|
# juleskremer - Jules Kremer
|
||||||
|
# kapunahelewong - Kapunahele Wong
|
||||||
|
# kara - Kara Erickson
|
||||||
|
# kyliau - Keen Yee Liau
|
||||||
|
# manughub - Manu Murthy
|
||||||
|
# matsko - Matias Niemela
|
||||||
|
# mgechev - Minko Gechev
|
||||||
|
# mhevery - Miško Hevery
|
||||||
|
# michaelprentice - Michael Prentice
|
||||||
|
# mmalerba - Miles Malerba
|
||||||
|
# petebacondarwin - Pete Bacon Darwin
|
||||||
|
# pkozlowski-opensource - Pawel Kozlowski
|
||||||
|
# robwormald - Rob Wormald
|
||||||
|
# StephenFluin - Stephen Fluin
|
||||||
|
|
||||||
|
|
||||||
####################################################################################
|
####################################################################################
|
||||||
@ -47,8 +80,8 @@
|
|||||||
# Used for approving minor changes, large-scale refactorings, and in emergency situations.
|
# Used for approving minor changes, large-scale refactorings, and in emergency situations.
|
||||||
#
|
#
|
||||||
# IgorMinar
|
# IgorMinar
|
||||||
# jelbourn
|
|
||||||
# josephperrott
|
# josephperrott
|
||||||
|
# kara
|
||||||
# mhevery
|
# mhevery
|
||||||
#
|
#
|
||||||
# =========================================================
|
# =========================================================
|
||||||
@ -67,16 +100,8 @@ version: 3
|
|||||||
# Meta field that goes unused by PullApprove to allow for defining aliases to be
|
# Meta field that goes unused by PullApprove to allow for defining aliases to be
|
||||||
# used throughout the config.
|
# used throughout the config.
|
||||||
meta:
|
meta:
|
||||||
can-be-global-approved: &can-be-global-approved "\"global-approvers\" not in groups.approved"
|
1: &can-be-global-approved "\"global-approvers\" not in groups.approved"
|
||||||
can-be-global-docs-approved: &can-be-global-docs-approved "\"global-docs-approvers\" not in groups.approved"
|
2: &can-be-global-docs-approved "\"global-docs-approvers\" not in groups.approved"
|
||||||
defaults: &defaults
|
|
||||||
reviews:
|
|
||||||
# Authors provide their approval implicitly, this approval allows for a reviewer
|
|
||||||
# from a group not to need a review specifically for an area of the repository
|
|
||||||
# they own. This is coupled with the `required-minimum-review` group which requires
|
|
||||||
# that all PRs are reviewed by at least one team member who is not the author of
|
|
||||||
# the PR.
|
|
||||||
author_value: 1
|
|
||||||
|
|
||||||
# turn on 'draft' support
|
# turn on 'draft' support
|
||||||
# https://docs.pullapprove.com/config/github-api-version/
|
# https://docs.pullapprove.com/config/github-api-version/
|
||||||
@ -132,62 +157,10 @@ groups:
|
|||||||
required: 1
|
required: 1
|
||||||
reviewed_for: required
|
reviewed_for: required
|
||||||
|
|
||||||
# =========================================================
|
|
||||||
# Require review on all PRs
|
|
||||||
#
|
|
||||||
# All PRs require at least one review. This rule will not
|
|
||||||
# request any reviewers, however will require that at least
|
|
||||||
# one review is provided before the group is satisfied.
|
|
||||||
# =========================================================
|
|
||||||
required-minimum-review:
|
|
||||||
conditions:
|
|
||||||
- *can-be-global-approved
|
|
||||||
- *can-be-global-docs-approved
|
|
||||||
reviews:
|
|
||||||
request: 0 # Do not request any reviews from the reviewer group
|
|
||||||
required: 1 # Require that all PRs have approval from at least one of the users in the group
|
|
||||||
author_value: 0 # The author of the PR cannot provide an approval for themself
|
|
||||||
reviewers:
|
|
||||||
users:
|
|
||||||
- aikidave # Dave Shevitz
|
|
||||||
- alan-agius4 # Alan Agius
|
|
||||||
- alxhub # Alex Rickabaugh
|
|
||||||
- AndrewKushnir # Andrew Kushnir
|
|
||||||
- andrewseguin # Andrew Seguin
|
|
||||||
- atscott # Andrew Scott
|
|
||||||
- ayazhafiz # Ayaz Hafiz
|
|
||||||
- clydin # Charles Lyding
|
|
||||||
- crisbeto # Kristiyan Kostadinov
|
|
||||||
- dennispbrown # Denny Brown
|
|
||||||
- devversion # Paul Gschwendtner
|
|
||||||
- dgp1130 # Doug Parker
|
|
||||||
- filipesilva # Filipe Silva
|
|
||||||
- gkalpak # Georgios Kalpakas
|
|
||||||
- gregmagolan # Greg Magolan
|
|
||||||
- IgorMinar # Igor Minar
|
|
||||||
- jbogarthyde # Judy Bogart
|
|
||||||
- jelbourn # Jeremy Elbourn
|
|
||||||
- JiaLiPassion # Jia Li
|
|
||||||
- JoostK # Joost Koehoorn
|
|
||||||
- josephperrott # Joey Perrott
|
|
||||||
- juleskremer # Jules Kremer
|
|
||||||
- kapunahelewong # Kapunahele Wong
|
|
||||||
- kara # Kara Erickson
|
|
||||||
- kyliau # Keen Yee Liau
|
|
||||||
- manughub # Manu Murthy
|
|
||||||
- mgechev # Minko Gechev
|
|
||||||
- mhevery # Miško Hevery
|
|
||||||
- mmalerba # Miles Malerba
|
|
||||||
- petebacondarwin # Pete Bacon Darwin
|
|
||||||
- pkozlowski-opensource # Pawel Kozlowski
|
|
||||||
- Splaktar # Michael Prentice
|
|
||||||
- StephenFluin # Stephen Fluin
|
|
||||||
|
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# Framework: Animations
|
# Framework: Animations
|
||||||
# =========================================================
|
# =========================================================
|
||||||
fw-animations:
|
fw-animations:
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
conditions:
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- *can-be-global-docs-approved
|
- *can-be-global-docs-approved
|
||||||
@ -205,21 +178,18 @@ groups:
|
|||||||
])
|
])
|
||||||
reviewers:
|
reviewers:
|
||||||
users:
|
users:
|
||||||
- crisbeto
|
- matsko
|
||||||
- IgorMinar
|
|
||||||
- jelbourn
|
|
||||||
|
|
||||||
|
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# Framework: Compiler
|
# Framework: Compiler
|
||||||
# =========================================================
|
# =========================================================
|
||||||
fw-compiler:
|
fw-compiler:
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
conditions:
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- *can-be-global-docs-approved
|
- *can-be-global-docs-approved
|
||||||
- >
|
- >
|
||||||
contains_any_globs(files.exclude('packages/compiler-cli/ngcc/**'), [
|
contains_any_globs(files, [
|
||||||
'packages/compiler/**',
|
'packages/compiler/**',
|
||||||
'packages/examples/compiler/**',
|
'packages/examples/compiler/**',
|
||||||
'packages/compiler-cli/**',
|
'packages/compiler-cli/**',
|
||||||
@ -228,22 +198,29 @@ groups:
|
|||||||
'aio/content/guide/aot-metadata-errors.md',
|
'aio/content/guide/aot-metadata-errors.md',
|
||||||
'aio/content/guide/template-typecheck.md '
|
'aio/content/guide/template-typecheck.md '
|
||||||
])
|
])
|
||||||
|
- >
|
||||||
|
not contains_any_globs(files, [
|
||||||
|
'packages/compiler-cli/ngcc/**'
|
||||||
|
])
|
||||||
reviewers:
|
reviewers:
|
||||||
users:
|
users:
|
||||||
- alxhub
|
- alxhub
|
||||||
- AndrewKushnir
|
- AndrewKushnir
|
||||||
- JoostK
|
- JoostK
|
||||||
|
- kara
|
||||||
|
|
||||||
|
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# Framework: Compiler / ngcc
|
# Framework: Compiler / ngcc
|
||||||
# =========================================================
|
# =========================================================
|
||||||
fw-ngcc:
|
fw-ngcc:
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
conditions:
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- *can-be-global-docs-approved
|
- *can-be-global-docs-approved
|
||||||
- files.include('packages/compiler-cli/ngcc/**')
|
- >
|
||||||
|
contains_any_globs(files, [
|
||||||
|
'packages/compiler-cli/ngcc/**'
|
||||||
|
])
|
||||||
reviewers:
|
reviewers:
|
||||||
users:
|
users:
|
||||||
- alxhub
|
- alxhub
|
||||||
@ -252,32 +229,15 @@ groups:
|
|||||||
- petebacondarwin
|
- petebacondarwin
|
||||||
|
|
||||||
|
|
||||||
# =========================================================
|
|
||||||
# Framework: Migrations
|
|
||||||
# =========================================================
|
|
||||||
fw-migrations:
|
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
|
||||||
- *can-be-global-approved
|
|
||||||
- *can-be-global-docs-approved
|
|
||||||
- files.include("packages/core/schematics/**")
|
|
||||||
reviewers:
|
|
||||||
users:
|
|
||||||
- alxhub
|
|
||||||
- crisbeto
|
|
||||||
- devversion
|
|
||||||
|
|
||||||
|
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# Framework: Core
|
# Framework: Core
|
||||||
# =========================================================
|
# =========================================================
|
||||||
fw-core:
|
fw-core:
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
conditions:
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- *can-be-global-docs-approved
|
- *can-be-global-docs-approved
|
||||||
- >
|
- >
|
||||||
contains_any_globs(files.exclude("packages/core/schematics/**"), [
|
contains_any_globs(files, [
|
||||||
'packages/core/**',
|
'packages/core/**',
|
||||||
'packages/examples/core/**',
|
'packages/examples/core/**',
|
||||||
'packages/common/**',
|
'packages/common/**',
|
||||||
@ -316,7 +276,6 @@ groups:
|
|||||||
'aio/content/images/guide/dependency-injection-in-action/**',
|
'aio/content/images/guide/dependency-injection-in-action/**',
|
||||||
'aio/content/guide/dependency-injection-navtree.md',
|
'aio/content/guide/dependency-injection-navtree.md',
|
||||||
'aio/content/guide/dependency-injection-providers.md',
|
'aio/content/guide/dependency-injection-providers.md',
|
||||||
'aio/content/guide/lightweight-injection-tokens.md',
|
|
||||||
'aio/content/guide/displaying-data.md',
|
'aio/content/guide/displaying-data.md',
|
||||||
'aio/content/examples/displaying-data/**',
|
'aio/content/examples/displaying-data/**',
|
||||||
'aio/content/images/guide/displaying-data/**',
|
'aio/content/images/guide/displaying-data/**',
|
||||||
@ -347,38 +306,26 @@ groups:
|
|||||||
'aio/content/guide/ngmodule-vs-jsmodule.md',
|
'aio/content/guide/ngmodule-vs-jsmodule.md',
|
||||||
'aio/content/guide/module-types.md',
|
'aio/content/guide/module-types.md',
|
||||||
'aio/content/guide/template-syntax.md',
|
'aio/content/guide/template-syntax.md',
|
||||||
'aio/content/guide/built-in-template-functions.md',
|
|
||||||
'aio/content/examples/built-in-template-functions/**',
|
'aio/content/examples/built-in-template-functions/**',
|
||||||
'aio/content/guide/event-binding.md',
|
|
||||||
'aio/content/examples/event-binding/**',
|
'aio/content/examples/event-binding/**',
|
||||||
'aio/content/guide/interpolation.md',
|
|
||||||
'aio/content/examples/interpolation/**',
|
'aio/content/examples/interpolation/**',
|
||||||
'aio/content/examples/template-syntax/**',
|
'aio/content/examples/template-syntax/**',
|
||||||
'aio/content/images/guide/template-syntax/**',
|
'aio/content/images/guide/template-syntax/**',
|
||||||
'aio/content/guide/binding-syntax.md',
|
|
||||||
'aio/content/examples/binding-syntax/**',
|
'aio/content/examples/binding-syntax/**',
|
||||||
'aio/content/guide/property-binding.md',
|
|
||||||
'aio/content/examples/property-binding/**',
|
'aio/content/examples/property-binding/**',
|
||||||
'aio/content/guide/attribute-binding.md',
|
|
||||||
'aio/content/examples/attribute-binding/**',
|
'aio/content/examples/attribute-binding/**',
|
||||||
'aio/content/guide/two-way-binding.md',
|
|
||||||
'aio/content/examples/two-way-binding/**',
|
'aio/content/examples/two-way-binding/**',
|
||||||
'aio/content/guide/built-in-directives.md',
|
|
||||||
'aio/content/examples/built-in-directives/**',
|
'aio/content/examples/built-in-directives/**',
|
||||||
'aio/content/images/guide/built-in-directives/**',
|
'aio/content/images/guide/built-in-directives/**',
|
||||||
'aio/content/guide/template-reference-variables.md',
|
|
||||||
'aio/content/examples/template-reference-variables/**',
|
'aio/content/examples/template-reference-variables/**',
|
||||||
'aio/content/guide/inputs-outputs.md',
|
|
||||||
'aio/content/examples/inputs-outputs/**',
|
'aio/content/examples/inputs-outputs/**',
|
||||||
'aio/content/images/guide/inputs-outputs/**',
|
'aio/content/images/guide/inputs-outputs/**',
|
||||||
'aio/content/guide/template-expression-operators.md',
|
|
||||||
'aio/content/examples/template-expression-operators/**',
|
'aio/content/examples/template-expression-operators/**',
|
||||||
'aio/content/guide/pipes.md',
|
'aio/content/guide/pipes.md',
|
||||||
'aio/content/examples/pipes/**',
|
'aio/content/examples/pipes/**',
|
||||||
'aio/content/images/guide/pipes/**',
|
'aio/content/images/guide/pipes/**',
|
||||||
'aio/content/guide/providers.md',
|
'aio/content/guide/providers.md',
|
||||||
'aio/content/examples/providers/**',
|
'aio/content/examples/providers/**',
|
||||||
'aio/content/images/guide/providers/**',
|
|
||||||
'aio/content/guide/singleton-services.md',
|
'aio/content/guide/singleton-services.md',
|
||||||
'aio/content/guide/set-document-title.md',
|
'aio/content/guide/set-document-title.md',
|
||||||
'aio/content/examples/set-document-title/**',
|
'aio/content/examples/set-document-title/**',
|
||||||
@ -386,9 +333,7 @@ groups:
|
|||||||
'aio/content/guide/sharing-ngmodules.md',
|
'aio/content/guide/sharing-ngmodules.md',
|
||||||
'aio/content/guide/structural-directives.md',
|
'aio/content/guide/structural-directives.md',
|
||||||
'aio/content/examples/structural-directives/**',
|
'aio/content/examples/structural-directives/**',
|
||||||
'aio/content/guide/svg-in-templates.md',
|
|
||||||
'aio/content/images/guide/structural-directives/**',
|
'aio/content/images/guide/structural-directives/**',
|
||||||
'aio/content/guide/template-statements.md',
|
|
||||||
'aio/content/guide/user-input.md',
|
'aio/content/guide/user-input.md',
|
||||||
'aio/content/examples/user-input/**',
|
'aio/content/examples/user-input/**',
|
||||||
'aio/content/images/guide/user-input/**'
|
'aio/content/images/guide/user-input/**'
|
||||||
@ -397,8 +342,7 @@ groups:
|
|||||||
users:
|
users:
|
||||||
- alxhub
|
- alxhub
|
||||||
- AndrewKushnir
|
- AndrewKushnir
|
||||||
- atscott
|
- kara
|
||||||
- ~kara # do not request reviews from Kara, but allow her to approve PRs
|
|
||||||
- mhevery
|
- mhevery
|
||||||
- pkozlowski-opensource
|
- pkozlowski-opensource
|
||||||
|
|
||||||
@ -407,13 +351,13 @@ groups:
|
|||||||
# Framework: Http
|
# Framework: Http
|
||||||
# =========================================================
|
# =========================================================
|
||||||
fw-http:
|
fw-http:
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
conditions:
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- *can-be-global-docs-approved
|
- *can-be-global-docs-approved
|
||||||
- >
|
- >
|
||||||
contains_any_globs(files, [
|
contains_any_globs(files, [
|
||||||
'packages/common/http/**',
|
'packages/common/http/**',
|
||||||
|
'packages/http/**',
|
||||||
'packages/examples/http/**',
|
'packages/examples/http/**',
|
||||||
'aio/content/guide/http.md',
|
'aio/content/guide/http.md',
|
||||||
'aio/content/examples/http/**',
|
'aio/content/examples/http/**',
|
||||||
@ -429,7 +373,6 @@ groups:
|
|||||||
# Framework: Elements
|
# Framework: Elements
|
||||||
# =========================================================
|
# =========================================================
|
||||||
fw-elements:
|
fw-elements:
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
conditions:
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- *can-be-global-docs-approved
|
- *can-be-global-docs-approved
|
||||||
@ -450,7 +393,6 @@ groups:
|
|||||||
# Framework: Forms
|
# Framework: Forms
|
||||||
# =========================================================
|
# =========================================================
|
||||||
fw-forms:
|
fw-forms:
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
conditions:
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- *can-be-global-docs-approved
|
- *can-be-global-docs-approved
|
||||||
@ -483,7 +425,6 @@ groups:
|
|||||||
# Framework: i18n
|
# Framework: i18n
|
||||||
# =========================================================
|
# =========================================================
|
||||||
fw-i18n:
|
fw-i18n:
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
conditions:
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- *can-be-global-docs-approved
|
- *can-be-global-docs-approved
|
||||||
@ -517,7 +458,6 @@ groups:
|
|||||||
# Framework: Platform Server
|
# Framework: Platform Server
|
||||||
# =========================================================
|
# =========================================================
|
||||||
fw-platform-server:
|
fw-platform-server:
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
conditions:
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- *can-be-global-docs-approved
|
- *can-be-global-docs-approved
|
||||||
@ -537,7 +477,6 @@ groups:
|
|||||||
# Framework: Router
|
# Framework: Router
|
||||||
# =========================================================
|
# =========================================================
|
||||||
fw-router:
|
fw-router:
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
conditions:
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- *can-be-global-docs-approved
|
- *can-be-global-docs-approved
|
||||||
@ -546,9 +485,6 @@ groups:
|
|||||||
'packages/router/**',
|
'packages/router/**',
|
||||||
'packages/examples/router/**',
|
'packages/examples/router/**',
|
||||||
'aio/content/guide/router.md',
|
'aio/content/guide/router.md',
|
||||||
'aio/content/guide/router-tutorial.md',
|
|
||||||
'aio/content/guide/router-tutorial-toh.md',
|
|
||||||
'aio/content/examples/router-tutorial/**',
|
|
||||||
'aio/content/examples/router/**',
|
'aio/content/examples/router/**',
|
||||||
'aio/content/images/guide/router/**'
|
'aio/content/images/guide/router/**'
|
||||||
])
|
])
|
||||||
@ -560,8 +496,7 @@ groups:
|
|||||||
# =========================================================
|
# =========================================================
|
||||||
# Framework: Service Worker
|
# Framework: Service Worker
|
||||||
# =========================================================
|
# =========================================================
|
||||||
fw-service-worker:
|
fw-server-worker:
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
conditions:
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- *can-be-global-docs-approved
|
- *can-be-global-docs-approved
|
||||||
@ -589,7 +524,6 @@ groups:
|
|||||||
# Framework: Upgrade
|
# Framework: Upgrade
|
||||||
# =========================================================
|
# =========================================================
|
||||||
fw-upgrade:
|
fw-upgrade:
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
conditions:
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- *can-be-global-docs-approved
|
- *can-be-global-docs-approved
|
||||||
@ -620,29 +554,20 @@ groups:
|
|||||||
# Framework: Testing
|
# Framework: Testing
|
||||||
# =========================================================
|
# =========================================================
|
||||||
fw-testing:
|
fw-testing:
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
conditions:
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- *can-be-global-docs-approved
|
- *can-be-global-docs-approved
|
||||||
- >
|
- >
|
||||||
contains_any_globs(files.exclude('packages/compiler-cli/**'), [
|
contains_any_globs(files, [
|
||||||
'**/testing/**',
|
'**/testing/**',
|
||||||
'aio/content/guide/testing.md',
|
'aio/content/guide/testing.md',
|
||||||
'aio/content/guide/test-debugging.md',
|
|
||||||
'aio/content/guide/testing-attribute-directives.md',
|
|
||||||
'aio/content/guide/testing-code-coverage.md',
|
|
||||||
'aio/content/guide/testing-components-basics.md',
|
|
||||||
'aio/content/guide/testing-components-scenarios.md',
|
|
||||||
'aio/content/guide/testing-pipes.md',
|
|
||||||
'aio/content/guide/testing-services.md',
|
|
||||||
'aio/content/guide/testing-utility-apis.md',
|
|
||||||
'aio/content/examples/testing/**',
|
'aio/content/examples/testing/**',
|
||||||
'aio/content/images/guide/testing/**'
|
'aio/content/images/guide/testing/**'
|
||||||
])
|
])
|
||||||
reviewers:
|
reviewers:
|
||||||
users:
|
users:
|
||||||
- AndrewKushnir
|
|
||||||
- IgorMinar
|
- IgorMinar
|
||||||
|
- kara
|
||||||
- pkozlowski-opensource
|
- pkozlowski-opensource
|
||||||
|
|
||||||
|
|
||||||
@ -650,7 +575,6 @@ groups:
|
|||||||
# Framework: Benchmarks
|
# Framework: Benchmarks
|
||||||
# =========================================================
|
# =========================================================
|
||||||
fw-benchmarks:
|
fw-benchmarks:
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
conditions:
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- >
|
- >
|
||||||
@ -660,6 +584,7 @@ groups:
|
|||||||
reviewers:
|
reviewers:
|
||||||
users:
|
users:
|
||||||
- IgorMinar
|
- IgorMinar
|
||||||
|
- kara
|
||||||
- pkozlowski-opensource
|
- pkozlowski-opensource
|
||||||
|
|
||||||
|
|
||||||
@ -667,7 +592,6 @@ groups:
|
|||||||
# Framework: Playground
|
# Framework: Playground
|
||||||
# =========================================================
|
# =========================================================
|
||||||
fw-playground:
|
fw-playground:
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
conditions:
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- >
|
- >
|
||||||
@ -677,15 +601,13 @@ groups:
|
|||||||
reviewers:
|
reviewers:
|
||||||
users:
|
users:
|
||||||
- IgorMinar
|
- IgorMinar
|
||||||
- jelbourn
|
- kara
|
||||||
- pkozlowski-opensource
|
|
||||||
|
|
||||||
|
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# Framework: Security
|
# Framework: Security
|
||||||
# =========================================================
|
# =========================================================
|
||||||
fw-security:
|
fw-security:
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
conditions:
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- *can-be-global-docs-approved
|
- *can-be-global-docs-approved
|
||||||
@ -703,25 +625,18 @@ groups:
|
|||||||
users:
|
users:
|
||||||
- IgorMinar
|
- IgorMinar
|
||||||
- mhevery
|
- mhevery
|
||||||
- jelbourn
|
|
||||||
- pkozlowski-opensource
|
|
||||||
reviews:
|
|
||||||
request: -1 # request reviews from everyone
|
|
||||||
required: 2 # require at least 2 approvals
|
|
||||||
reviewed_for: required
|
|
||||||
|
|
||||||
|
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# Bazel
|
# Bazel
|
||||||
# =========================================================
|
# =========================================================
|
||||||
bazel:
|
bazel:
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
conditions:
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- *can-be-global-docs-approved
|
- *can-be-global-docs-approved
|
||||||
- >
|
- >
|
||||||
contains_any_globs(files, [
|
contains_any_globs(files, [
|
||||||
'packages/bazel/**',
|
'packages/bazel/**',
|
||||||
|
'aio/content/guide/bazel.md'
|
||||||
])
|
])
|
||||||
reviewers:
|
reviewers:
|
||||||
users:
|
users:
|
||||||
@ -734,7 +649,6 @@ groups:
|
|||||||
# Language Service
|
# Language Service
|
||||||
# =========================================================
|
# =========================================================
|
||||||
language-service:
|
language-service:
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
conditions:
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- *can-be-global-docs-approved
|
- *can-be-global-docs-approved
|
||||||
@ -754,7 +668,6 @@ groups:
|
|||||||
# zone.js
|
# zone.js
|
||||||
# =========================================================
|
# =========================================================
|
||||||
zone-js:
|
zone-js:
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
conditions:
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- *can-be-global-docs-approved
|
- *can-be-global-docs-approved
|
||||||
@ -768,27 +681,11 @@ groups:
|
|||||||
- JiaLiPassion
|
- JiaLiPassion
|
||||||
- mhevery
|
- mhevery
|
||||||
|
|
||||||
# =========================================================
|
|
||||||
# in-memory-web-api
|
|
||||||
# =========================================================
|
|
||||||
in-memory-web-api:
|
|
||||||
conditions:
|
|
||||||
- *can-be-global-approved
|
|
||||||
- *can-be-global-docs-approved
|
|
||||||
- >
|
|
||||||
contains_any_globs(files, [
|
|
||||||
'packages/misc/angular-in-memory-web-api/**',
|
|
||||||
])
|
|
||||||
reviewers:
|
|
||||||
users:
|
|
||||||
- IgorMinar
|
|
||||||
- crisbeto
|
|
||||||
|
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# Benchpress
|
# Benchpress
|
||||||
# =========================================================
|
# =========================================================
|
||||||
benchpress:
|
benchpress:
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
conditions:
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- *can-be-global-docs-approved
|
- *can-be-global-docs-approved
|
||||||
@ -799,14 +696,12 @@ groups:
|
|||||||
reviewers:
|
reviewers:
|
||||||
users:
|
users:
|
||||||
- alxhub
|
- alxhub
|
||||||
- josephperrott
|
|
||||||
|
|
||||||
|
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# Integration Tests
|
# Integration Tests
|
||||||
# =========================================================
|
# =========================================================
|
||||||
integration-tests:
|
integration-tests:
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
conditions:
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- >
|
- >
|
||||||
@ -817,6 +712,7 @@ groups:
|
|||||||
users:
|
users:
|
||||||
- IgorMinar
|
- IgorMinar
|
||||||
- josephperrott
|
- josephperrott
|
||||||
|
- kara
|
||||||
- mhevery
|
- mhevery
|
||||||
|
|
||||||
|
|
||||||
@ -824,7 +720,6 @@ groups:
|
|||||||
# Docs: Gettings Started & Tutorial
|
# Docs: Gettings Started & Tutorial
|
||||||
# =========================================================
|
# =========================================================
|
||||||
docs-getting-started-and-tutorial:
|
docs-getting-started-and-tutorial:
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
conditions:
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- *can-be-global-docs-approved
|
- *can-be-global-docs-approved
|
||||||
@ -857,7 +752,6 @@ groups:
|
|||||||
# Docs: Marketing
|
# Docs: Marketing
|
||||||
# =========================================================
|
# =========================================================
|
||||||
docs-marketing:
|
docs-marketing:
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
conditions:
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- *can-be-global-docs-approved
|
- *can-be-global-docs-approved
|
||||||
@ -872,15 +766,14 @@ groups:
|
|||||||
])
|
])
|
||||||
reviewers:
|
reviewers:
|
||||||
users:
|
users:
|
||||||
- aikidave
|
|
||||||
- IgorMinar
|
- IgorMinar
|
||||||
- StephenFluin
|
- StephenFluin
|
||||||
|
|
||||||
|
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# Docs: Observables
|
# Docs: Observables
|
||||||
# =========================================================
|
# =========================================================
|
||||||
docs-observables:
|
docs-observables:
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
conditions:
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- *can-be-global-docs-approved
|
- *can-be-global-docs-approved
|
||||||
@ -906,7 +799,6 @@ groups:
|
|||||||
# Docs: Packaging, Tooling, Releasing
|
# Docs: Packaging, Tooling, Releasing
|
||||||
# =========================================================
|
# =========================================================
|
||||||
docs-packaging-and-releasing:
|
docs-packaging-and-releasing:
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
conditions:
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- *can-be-global-docs-approved
|
- *can-be-global-docs-approved
|
||||||
@ -926,47 +818,20 @@ groups:
|
|||||||
'aio/content/guide/migration-localize.md',
|
'aio/content/guide/migration-localize.md',
|
||||||
'aio/content/guide/migration-module-with-providers.md',
|
'aio/content/guide/migration-module-with-providers.md',
|
||||||
'aio/content/guide/static-query-migration.md',
|
'aio/content/guide/static-query-migration.md',
|
||||||
'aio/content/guide/updating-to-version-10.md',
|
'aio/content/guide/updating-to-version-9.md',
|
||||||
'aio/content/guide/ivy-compatibility.md',
|
'aio/content/guide/ivy-compatibility.md',
|
||||||
'aio/content/guide/ivy-compatibility-examples.md'
|
'aio/content/guide/ivy-compatibility-examples.md'
|
||||||
])
|
])
|
||||||
reviewers:
|
reviewers:
|
||||||
users:
|
users:
|
||||||
- IgorMinar
|
- IgorMinar
|
||||||
- jelbourn
|
- kara
|
||||||
|
|
||||||
|
|
||||||
# =========================================================
|
|
||||||
# Tooling: Compiler API shared with Angular CLI
|
|
||||||
#
|
|
||||||
# Changing this API might break Angular CLI, so we require
|
|
||||||
# the CLI team to approve changes here.
|
|
||||||
# =========================================================
|
|
||||||
tooling-cli-shared-api:
|
|
||||||
conditions:
|
|
||||||
- *can-be-global-approved
|
|
||||||
- *can-be-global-docs-approved
|
|
||||||
- >
|
|
||||||
contains_any_globs(files, [
|
|
||||||
'packages/compiler-cli/src/tooling.ts'
|
|
||||||
])
|
|
||||||
reviewers:
|
|
||||||
users:
|
|
||||||
- alan-agius4
|
|
||||||
- clydin
|
|
||||||
- kyliau
|
|
||||||
- IgorMinar
|
|
||||||
reviews:
|
|
||||||
request: -1 # request reviews from everyone
|
|
||||||
required: 2 # require at least 2 approvals
|
|
||||||
reviewed_for: required
|
|
||||||
|
|
||||||
|
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# Docs: CLI
|
# Docs: CLI
|
||||||
# =========================================================
|
# =========================================================
|
||||||
docs-cli:
|
docs-cli:
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
conditions:
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- *can-be-global-docs-approved
|
- *can-be-global-docs-approved
|
||||||
@ -983,12 +848,8 @@ groups:
|
|||||||
'aio/content/images/guide/deployment/**',
|
'aio/content/images/guide/deployment/**',
|
||||||
'aio/content/guide/file-structure.md',
|
'aio/content/guide/file-structure.md',
|
||||||
'aio/content/guide/ivy.md',
|
'aio/content/guide/ivy.md',
|
||||||
'aio/content/guide/strict-mode.md',
|
'aio/content/guide/web-worker.md'
|
||||||
'aio/content/guide/web-worker.md',
|
|
||||||
'aio/content/guide/workspace-config.md',
|
'aio/content/guide/workspace-config.md',
|
||||||
'aio/content/guide/migration-solution-style-tsconfig.md',
|
|
||||||
'aio/content/guide/migration-update-module-and-target-compiler-options.md',
|
|
||||||
'aio/content/guide/migration-update-libraries-tslib.md',
|
|
||||||
])
|
])
|
||||||
reviewers:
|
reviewers:
|
||||||
users:
|
users:
|
||||||
@ -1001,7 +862,6 @@ groups:
|
|||||||
# Docs: CLI Libraries
|
# Docs: CLI Libraries
|
||||||
# =========================================================
|
# =========================================================
|
||||||
docs-libraries:
|
docs-libraries:
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
conditions:
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- *can-be-global-docs-approved
|
- *can-be-global-docs-approved
|
||||||
@ -1022,7 +882,6 @@ groups:
|
|||||||
# Docs: Schematics
|
# Docs: Schematics
|
||||||
# =========================================================
|
# =========================================================
|
||||||
docs-schematics:
|
docs-schematics:
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
conditions:
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- *can-be-global-docs-approved
|
- *can-be-global-docs-approved
|
||||||
@ -1045,7 +904,6 @@ groups:
|
|||||||
# Docs-infra
|
# Docs-infra
|
||||||
# =========================================================
|
# =========================================================
|
||||||
docs-infra:
|
docs-infra:
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
conditions:
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- *can-be-global-docs-approved
|
- *can-be-global-docs-approved
|
||||||
@ -1075,16 +933,14 @@ groups:
|
|||||||
# Dev-infra
|
# Dev-infra
|
||||||
# =========================================================
|
# =========================================================
|
||||||
dev-infra:
|
dev-infra:
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
conditions:
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- >
|
- >
|
||||||
contains_any_globs(files.exclude("CHANGELOG.md").exclude("packages/compiler-cli/**/BUILD.bazel"), [
|
contains_any_globs(files, [
|
||||||
'*',
|
'*',
|
||||||
'.circleci/**',
|
'.circleci/**',
|
||||||
'.devcontainer/**',
|
'.devcontainer/**',
|
||||||
'.github/**',
|
'.github/**',
|
||||||
'.ng-dev/**',
|
|
||||||
'.vscode/**',
|
'.vscode/**',
|
||||||
'.yarn/**',
|
'.yarn/**',
|
||||||
'dev-infra/**',
|
'dev-infra/**',
|
||||||
@ -1100,6 +956,8 @@ groups:
|
|||||||
'docs/TOOLS.md',
|
'docs/TOOLS.md',
|
||||||
'docs/TRIAGE_AND_LABELS.md',
|
'docs/TRIAGE_AND_LABELS.md',
|
||||||
'goldens/*',
|
'goldens/*',
|
||||||
|
'modules/e2e_util/e2e_util.ts',
|
||||||
|
'modules/e2e_util/perf_util.ts',
|
||||||
'modules/*',
|
'modules/*',
|
||||||
'packages/*',
|
'packages/*',
|
||||||
'packages/examples/test-utils/**',
|
'packages/examples/test-utils/**',
|
||||||
@ -1107,10 +965,15 @@ groups:
|
|||||||
'packages/examples/*',
|
'packages/examples/*',
|
||||||
'scripts/**',
|
'scripts/**',
|
||||||
'third_party/**',
|
'third_party/**',
|
||||||
|
'tools/brotli-cli/**',
|
||||||
|
'tools/browsers/**',
|
||||||
'tools/build/**',
|
'tools/build/**',
|
||||||
'tools/circular_dependency_test/**',
|
'tools/circular_dependency_test/**',
|
||||||
'tools/contributing-stats/**',
|
'tools/contributing-stats/**',
|
||||||
|
'tools/components/**',
|
||||||
'tools/gulp-tasks/**',
|
'tools/gulp-tasks/**',
|
||||||
|
'tools/ng_rollup_bundle/**',
|
||||||
|
'tools/ngcontainer/**',
|
||||||
'tools/npm/**',
|
'tools/npm/**',
|
||||||
'tools/npm_integration_test/**',
|
'tools/npm_integration_test/**',
|
||||||
'tools/rxjs/**',
|
'tools/rxjs/**',
|
||||||
@ -1140,13 +1003,11 @@ groups:
|
|||||||
# Public API
|
# Public API
|
||||||
# =========================================================
|
# =========================================================
|
||||||
public-api:
|
public-api:
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
conditions:
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- >
|
- >
|
||||||
contains_any_globs(files, [
|
contains_any_globs(files, [
|
||||||
'goldens/public-api/**',
|
'goldens/public-api/**',
|
||||||
'CHANGELOG.md',
|
|
||||||
'docs/NAMING.md',
|
'docs/NAMING.md',
|
||||||
'aio/content/guide/glossary.md',
|
'aio/content/guide/glossary.md',
|
||||||
'aio/content/guide/styleguide.md',
|
'aio/content/guide/styleguide.md',
|
||||||
@ -1156,58 +1017,40 @@ groups:
|
|||||||
reviewers:
|
reviewers:
|
||||||
users:
|
users:
|
||||||
- IgorMinar
|
- IgorMinar
|
||||||
- alxhub
|
|
||||||
- jelbourn
|
|
||||||
- petebacondarwin
|
|
||||||
- pkozlowski-opensource
|
|
||||||
reviews:
|
|
||||||
request: -1 # request reviews from everyone
|
|
||||||
required: 3 # require at least 3 approvals
|
|
||||||
reviewed_for: required
|
|
||||||
|
|
||||||
|
|
||||||
# ================================================
|
# ================================================
|
||||||
# Size tracking
|
# Size tracking
|
||||||
# ================================================
|
# ================================================
|
||||||
size-tracking:
|
size-tracking:
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
conditions:
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- >
|
- >
|
||||||
contains_any_globs(files, [
|
contains_any_globs(files, [
|
||||||
'goldens/size-tracking/**'
|
'aio/scripts/_payload-limits.json',
|
||||||
|
'integration/_payload-limits.json'
|
||||||
])
|
])
|
||||||
reviewers:
|
reviewers:
|
||||||
users:
|
users:
|
||||||
- IgorMinar
|
- IgorMinar
|
||||||
- alxhub
|
- kara
|
||||||
- jelbourn
|
|
||||||
- petebacondarwin
|
|
||||||
- pkozlowski-opensource
|
|
||||||
reviews:
|
|
||||||
request: -1 # request reviews from everyone
|
|
||||||
required: 2 # require at least 2 approvals
|
|
||||||
reviewed_for: required
|
|
||||||
|
|
||||||
|
|
||||||
# ================================================
|
# ================================================
|
||||||
# Circular dependencies
|
# Circular dependencies
|
||||||
# ================================================
|
# ================================================
|
||||||
circular-dependencies:
|
circular-dependencies:
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
conditions:
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- >
|
- >
|
||||||
contains_any_globs(files, [
|
contains_any_globs(files, [
|
||||||
'goldens/circular-deps/packages.json'
|
'goldens/packages-circular-deps.json'
|
||||||
])
|
])
|
||||||
reviewers:
|
reviewers:
|
||||||
users:
|
users:
|
||||||
- IgorMinar
|
- IgorMinar
|
||||||
- jelbourn
|
|
||||||
- josephperrott
|
- josephperrott
|
||||||
- petebacondarwin
|
- kara
|
||||||
- pkozlowski-opensource
|
|
||||||
|
|
||||||
|
|
||||||
####################################################################################
|
####################################################################################
|
||||||
@ -1218,7 +1061,6 @@ groups:
|
|||||||
# Code Ownership
|
# Code Ownership
|
||||||
# =========================================================
|
# =========================================================
|
||||||
code-ownership:
|
code-ownership:
|
||||||
<<: *defaults
|
|
||||||
conditions:
|
conditions:
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- >
|
- >
|
||||||
@ -1228,46 +1070,18 @@ groups:
|
|||||||
reviewers:
|
reviewers:
|
||||||
users:
|
users:
|
||||||
- IgorMinar
|
- IgorMinar
|
||||||
- jelbourn
|
|
||||||
- josephperrott
|
|
||||||
- mhevery
|
|
||||||
|
|
||||||
|
|
||||||
# ====================================================
|
# ====================================================
|
||||||
# Catch all for if no groups match the code change
|
# Catch all for if no groups match the code change
|
||||||
# ====================================================
|
# ====================================================
|
||||||
fallback:
|
fallback:
|
||||||
<<: *defaults
|
|
||||||
# A group is considered to be `active` for a PR if at least one of group's
|
|
||||||
# conditions matches the PR.
|
|
||||||
#
|
|
||||||
# The PullApprove CI check should fail if a PR has no `active` groups, as
|
|
||||||
# this indicates the PR is modifying a file that has no owner.
|
|
||||||
#
|
|
||||||
# This is enforced through the pullapprove verification check done
|
|
||||||
# as part of the CircleCI lint job. Failures in this lint job should be
|
|
||||||
# fixed as part of the PR. This can be done by updating the
|
|
||||||
# `.pullapprove.yml` file cover the unmatched path.
|
|
||||||
# The pullapprove verification script is part of the ng-dev tool and can be
|
|
||||||
# run locally with the command: `yarn -s ng-dev pullapprove verify`
|
|
||||||
#
|
|
||||||
# For cases in which the verification check fails to ensure coverage, this
|
|
||||||
# group will be active. The expectation is that this should be remedied
|
|
||||||
# before merging the PR as described above. In an emergency situation
|
|
||||||
# `global-approvers` can still approve PRs that match this `fallback` rule,
|
|
||||||
# but that should be an exception and not an expectation.
|
|
||||||
conditions:
|
conditions:
|
||||||
# The following groups have no file based conditions and will be initially `active` on all PRs
|
|
||||||
# - `global-approvers`
|
|
||||||
# - `global-docs-approvers`
|
|
||||||
# - `required-minimum-review`
|
|
||||||
#
|
|
||||||
# By checking the number of active groups when these are excluded, we can determine
|
|
||||||
# if any other groups are matched.
|
|
||||||
- len(groups.active.exclude("required-minimum-review").exclude("global-approvers").exclude("global-docs-approvers")) == 0
|
|
||||||
# When any of the `global-*` groups is approved, they cause other groups to deactivate.
|
|
||||||
# In those cases, the condition above would evaluate to `true` while in reality, only a global
|
|
||||||
# approval has been provided. To ensure we don't activate the fallback group in such cases,
|
|
||||||
# ensure that no explicit global approval has been provided.
|
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- *can-be-global-docs-approved
|
# Groups which are found to have matching conditions are `active`
|
||||||
|
# according to PullApprove. If no groups are matched and considered
|
||||||
|
# active, we still want to have a review occur.
|
||||||
|
- len(groups.active) == 0
|
||||||
|
reviewers:
|
||||||
|
users:
|
||||||
|
- IgorMinar
|
||||||
|
3
.vscode/recommended-settings.json
vendored
3
.vscode/recommended-settings.json
vendored
@ -26,7 +26,6 @@
|
|||||||
"**/bazel-out": true,
|
"**/bazel-out": true,
|
||||||
"**/dist": true,
|
"**/dist": true,
|
||||||
"**/aio/src/generated": true,
|
"**/aio/src/generated": true,
|
||||||
".history": true,
|
|
||||||
},
|
},
|
||||||
"git.ignoreLimitWarning": true,
|
"git.ignoreLimitWarning": true,
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package(default_visibility = ["//visibility:public"])
|
|||||||
|
|
||||||
exports_files([
|
exports_files([
|
||||||
"LICENSE",
|
"LICENSE",
|
||||||
|
"protractor-perf.conf.js",
|
||||||
"karma-js.conf.js",
|
"karma-js.conf.js",
|
||||||
"browser-providers.conf.js",
|
"browser-providers.conf.js",
|
||||||
"scripts/ci/track-payload-size.sh",
|
"scripts/ci/track-payload-size.sh",
|
||||||
@ -20,11 +21,11 @@ filegroup(
|
|||||||
# do not sort
|
# do not sort
|
||||||
srcs = [
|
srcs = [
|
||||||
"@npm//:node_modules/core-js/client/core.js",
|
"@npm//:node_modules/core-js/client/core.js",
|
||||||
"//packages/zone.js/bundles:zone.umd.js",
|
"//packages/zone.js/dist:zone.js",
|
||||||
"//packages/zone.js/bundles:zone-testing.umd.js",
|
"//packages/zone.js/dist:zone-testing.js",
|
||||||
"//packages/zone.js/bundles:task-tracking.umd.js",
|
"//packages/zone.js/dist:task-tracking.js",
|
||||||
"//:test-events.js",
|
"//:test-events.js",
|
||||||
"//:third_party/shims_for_IE.js",
|
"//:shims_for_IE.js",
|
||||||
# Including systemjs because it defines `__eval`, which produces correct stack traces.
|
# Including systemjs because it defines `__eval`, which produces correct stack traces.
|
||||||
"@npm//:node_modules/systemjs/dist/system.src.js",
|
"@npm//:node_modules/systemjs/dist/system.src.js",
|
||||||
"@npm//:node_modules/reflect-metadata/Reflect.js",
|
"@npm//:node_modules/reflect-metadata/Reflect.js",
|
||||||
|
762
CHANGELOG.md
762
CHANGELOG.md
File diff suppressed because it is too large
Load Diff
297
CONTRIBUTING.md
297
CONTRIBUTING.md
@ -1,7 +1,7 @@
|
|||||||
# Contributing to Angular
|
# Contributing to Angular
|
||||||
|
|
||||||
We would love for you to contribute to Angular and help make it even better than it is today!
|
We would love for you to contribute to Angular and help make it even better than it is
|
||||||
As a contributor, here are the guidelines we would like you to follow:
|
today! As a contributor, here are the guidelines we would like you to follow:
|
||||||
|
|
||||||
- [Code of Conduct](#coc)
|
- [Code of Conduct](#coc)
|
||||||
- [Question or Problem?](#question)
|
- [Question or Problem?](#question)
|
||||||
@ -12,63 +12,50 @@ As a contributor, here are the guidelines we would like you to follow:
|
|||||||
- [Commit Message Guidelines](#commit)
|
- [Commit Message Guidelines](#commit)
|
||||||
- [Signing the CLA](#cla)
|
- [Signing the CLA](#cla)
|
||||||
|
|
||||||
|
|
||||||
## <a name="coc"></a> Code of Conduct
|
## <a name="coc"></a> Code of Conduct
|
||||||
|
Help us keep Angular open and inclusive. Please read and follow our [Code of Conduct][coc].
|
||||||
Help us keep Angular open and inclusive.
|
|
||||||
Please read and follow our [Code of Conduct][coc].
|
|
||||||
|
|
||||||
|
|
||||||
## <a name="question"></a> Got a Question or Problem?
|
## <a name="question"></a> Got a Question or Problem?
|
||||||
|
|
||||||
Do not open issues for general support questions as we want to keep GitHub issues for bug reports and feature requests.
|
Do not open issues for general support questions as we want to keep GitHub issues for bug reports and feature requests. You've got much better chances of getting your question answered on [Stack Overflow](https://stackoverflow.com/questions/tagged/angular) where the questions should be tagged with tag `angular`.
|
||||||
Instead, we recommend using [Stack Overflow](https://stackoverflow.com/questions/tagged/angular) to ask support-related questions. When creating a new question on Stack Overflow, make sure to add the `angular` tag.
|
|
||||||
|
|
||||||
Stack Overflow is a much better place to ask questions since:
|
Stack Overflow is a much better place to ask questions since:
|
||||||
|
|
||||||
- there are thousands of people willing to help on Stack Overflow
|
- there are thousands of people willing to help on Stack Overflow
|
||||||
- questions and answers stay available for public viewing so your question/answer might help someone else
|
- questions and answers stay available for public viewing so your question / answer might help someone else
|
||||||
- Stack Overflow's voting system assures that the best answers are prominently visible.
|
- Stack Overflow's voting system assures that the best answers are prominently visible.
|
||||||
|
|
||||||
To save your and our time, we will systematically close all issues that are requests for general support and redirect people to Stack Overflow.
|
To save your and our time, we will systematically close all issues that are requests for general support and redirect people to Stack Overflow.
|
||||||
|
|
||||||
If you would like to chat about the question in real-time, you can reach out via [our gitter channel][gitter].
|
If you would like to chat about the question in real-time, you can reach out via [our gitter channel][gitter].
|
||||||
|
|
||||||
|
|
||||||
## <a name="issue"></a> Found a Bug?
|
## <a name="issue"></a> Found a Bug?
|
||||||
|
If you find a bug in the source code, you can help us by
|
||||||
If you find a bug in the source code, you can help us by [submitting an issue](#submit-issue) to our [GitHub Repository][github].
|
[submitting an issue](#submit-issue) to our [GitHub Repository][github]. Even better, you can
|
||||||
Even better, you can [submit a Pull Request](#submit-pr) with a fix.
|
[submit a Pull Request](#submit-pr) with a fix.
|
||||||
|
|
||||||
|
|
||||||
## <a name="feature"></a> Missing a Feature?
|
## <a name="feature"></a> Missing a Feature?
|
||||||
You can *request* a new feature by [submitting an issue](#submit-issue) to our GitHub Repository.
|
You can *request* a new feature by [submitting an issue](#submit-issue) to our GitHub
|
||||||
If you would like to *implement* a new feature, please consider the size of the change in order to determine the right steps to proceed:
|
Repository. If you would like to *implement* a new feature, please submit an issue with
|
||||||
|
a proposal for your work first, to be sure that we can use it.
|
||||||
* For a **Major Feature**, first open an issue and outline your proposal so that it can be discussed.
|
Please consider what kind of change it is:
|
||||||
This process allows us to better coordinate our efforts, prevent duplication of work, and help you to craft the change so that it is successfully accepted into the project.
|
|
||||||
|
|
||||||
**Note**: Adding a new topic to the documentation, or significantly re-writing a topic, counts as a major feature.
|
|
||||||
|
|
||||||
|
* For a **Major Feature**, first open an issue and outline your proposal so that it can be
|
||||||
|
discussed. This will also allow us to better coordinate our efforts, prevent duplication of work,
|
||||||
|
and help you to craft the change so that it is successfully accepted into the project.
|
||||||
* **Small Features** can be crafted and directly [submitted as a Pull Request](#submit-pr).
|
* **Small Features** can be crafted and directly [submitted as a Pull Request](#submit-pr).
|
||||||
|
|
||||||
|
|
||||||
## <a name="submit"></a> Submission Guidelines
|
## <a name="submit"></a> Submission Guidelines
|
||||||
|
|
||||||
|
|
||||||
### <a name="submit-issue"></a> Submitting an Issue
|
### <a name="submit-issue"></a> Submitting an Issue
|
||||||
|
|
||||||
Before you submit an issue, please search the issue tracker, maybe an issue for your problem already exists and the discussion might inform you of workarounds readily available.
|
Before you submit an issue, please search the issue tracker, maybe an issue for your problem already exists and the discussion might inform you of workarounds readily available.
|
||||||
|
|
||||||
We want to fix all the issues as soon as possible, but before fixing a bug we need to reproduce and confirm it.
|
We want to fix all the issues as soon as possible, but before fixing a bug we need to reproduce and confirm it. In order to reproduce bugs, we will systematically ask you to provide a minimal reproduction. Having a minimal reproducible scenario gives us a wealth of important information without going back & forth to you with additional questions.
|
||||||
In order to reproduce bugs, we require that you provide a minimal reproduction.
|
|
||||||
Having a minimal reproducible scenario gives us a wealth of important information without going back and forth to you with additional questions.
|
|
||||||
|
|
||||||
A minimal reproduction allows us to quickly confirm a bug (or point out a coding problem) as well as confirm that we are fixing the right problem.
|
A minimal reproduction allows us to quickly confirm a bug (or point out a coding problem) as well as confirm that we are fixing the right problem.
|
||||||
|
|
||||||
We require a minimal reproduction to save maintainers' time and ultimately be able to fix more bugs.
|
We will be insisting on a minimal reproduction scenario in order to save maintainers time and ultimately be able to fix more bugs. Interestingly, from our experience, users often find coding problems themselves while preparing a minimal reproduction. We understand that sometimes it might be hard to extract essential bits of code from a larger codebase but we really need to isolate the problem before we can fix it.
|
||||||
Often, developers find coding problems themselves while preparing a minimal reproduction.
|
|
||||||
We understand that sometimes it might be hard to extract essential bits of code from a larger codebase but we really need to isolate the problem before we can fix it.
|
|
||||||
|
|
||||||
Unfortunately, we are not able to investigate / fix bugs without a minimal reproduction, so if we don't hear back from you, we are going to close an issue that doesn't have enough info to be reproduced.
|
Unfortunately, we are not able to investigate / fix bugs without a minimal reproduction, so if we don't hear back from you, we are going to close an issue that doesn't have enough info to be reproduced.
|
||||||
|
|
||||||
@ -76,66 +63,57 @@ You can file new issues by selecting from our [new issue templates](https://gith
|
|||||||
|
|
||||||
|
|
||||||
### <a name="submit-pr"></a> Submitting a Pull Request (PR)
|
### <a name="submit-pr"></a> Submitting a Pull Request (PR)
|
||||||
|
|
||||||
Before you submit your Pull Request (PR) consider the following guidelines:
|
Before you submit your Pull Request (PR) consider the following guidelines:
|
||||||
|
|
||||||
1. Search [GitHub](https://github.com/angular/angular/pulls) for an open or closed PR that relates to your submission.
|
1. Search [GitHub](https://github.com/angular/angular/pulls) for an open or closed PR
|
||||||
You don't want to duplicate existing efforts.
|
that relates to your submission. You don't want to duplicate effort.
|
||||||
|
1. Be sure that an issue describes the problem you're fixing, or documents the design for the feature you'd like to add.
|
||||||
2. Be sure that an issue describes the problem you're fixing, or documents the design for the feature you'd like to add.
|
Discussing the design up front helps to ensure that we're ready to accept your work.
|
||||||
Discussing the design upfront helps to ensure that we're ready to accept your work.
|
1. Please sign our [Contributor License Agreement (CLA)](#cla) before sending PRs.
|
||||||
|
We cannot accept code without this. Make sure you sign with the primary email address of the Git identity that has been granted access to the Angular repository.
|
||||||
3. Please sign our [Contributor License Agreement (CLA)](#cla) before sending PRs.
|
1. Fork the angular/angular repo.
|
||||||
We cannot accept code without a signed CLA.
|
1. Make your changes in a new git branch:
|
||||||
Make sure you author all contributed Git commits with email address associated with your CLA signature.
|
|
||||||
|
|
||||||
4. Fork the angular/angular repo.
|
|
||||||
|
|
||||||
5. Make your changes in a new git branch:
|
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
git checkout -b my-fix-branch master
|
git checkout -b my-fix-branch master
|
||||||
```
|
```
|
||||||
|
|
||||||
6. Create your patch, **including appropriate test cases**.
|
1. Create your patch, **including appropriate test cases**.
|
||||||
|
1. Follow our [Coding Rules](#rules).
|
||||||
7. Follow our [Coding Rules](#rules).
|
1. Run the full Angular test suite, as described in the [developer documentation][dev-doc],
|
||||||
|
and ensure that all tests pass.
|
||||||
8. Run the full Angular test suite, as described in the [developer documentation][dev-doc], and ensure that all tests pass.
|
1. Commit your changes using a descriptive commit message that follows our
|
||||||
|
[commit message conventions](#commit). Adherence to these conventions
|
||||||
9. Commit your changes using a descriptive commit message that follows our [commit message conventions](#commit).
|
is necessary because release notes are automatically generated from these messages.
|
||||||
Adherence to these conventions is necessary because release notes are automatically generated from these messages.
|
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
git commit -a
|
git commit -a
|
||||||
```
|
```
|
||||||
Note: the optional commit `-a` command line option will automatically "add" and "rm" edited files.
|
Note: the optional commit `-a` command line option will automatically "add" and "rm" edited files.
|
||||||
|
|
||||||
10. Push your branch to GitHub:
|
1. Push your branch to GitHub:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
git push origin my-fix-branch
|
git push origin my-fix-branch
|
||||||
```
|
```
|
||||||
|
|
||||||
11. In GitHub, send a pull request to `angular:master`.
|
1. In GitHub, send a pull request to `angular:master`.
|
||||||
|
* If we suggest changes then:
|
||||||
|
* Make the required updates.
|
||||||
|
* Re-run the Angular test suites to ensure tests are still passing.
|
||||||
|
* Rebase your branch and force push to your GitHub repository (this will update your Pull Request):
|
||||||
|
|
||||||
If we ask for changes via code reviews then:
|
```shell
|
||||||
|
git rebase master -i
|
||||||
* Make the required updates.
|
git push -f
|
||||||
* Re-run the Angular test suites to ensure tests are still passing.
|
```
|
||||||
* Rebase your branch and force push to your GitHub repository (this will update your Pull Request):
|
|
||||||
|
|
||||||
```shell
|
|
||||||
git rebase master -i
|
|
||||||
git push -f
|
|
||||||
```
|
|
||||||
|
|
||||||
That's it! Thank you for your contribution!
|
That's it! Thank you for your contribution!
|
||||||
|
|
||||||
|
|
||||||
#### After your pull request is merged
|
#### After your pull request is merged
|
||||||
|
|
||||||
After your pull request is merged, you can safely delete your branch and pull the changes from the main (upstream) repository:
|
After your pull request is merged, you can safely delete your branch and pull the changes
|
||||||
|
from the main (upstream) repository:
|
||||||
|
|
||||||
* Delete the remote branch on GitHub either through the GitHub web UI or your local shell as follows:
|
* Delete the remote branch on GitHub either through the GitHub web UI or your local shell as follows:
|
||||||
|
|
||||||
@ -161,66 +139,55 @@ After your pull request is merged, you can safely delete your branch and pull th
|
|||||||
git pull --ff upstream master
|
git pull --ff upstream master
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## <a name="rules"></a> Coding Rules
|
## <a name="rules"></a> Coding Rules
|
||||||
To ensure consistency throughout the source code, keep these rules in mind as you are working:
|
To ensure consistency throughout the source code, keep these rules in mind as you are working:
|
||||||
|
|
||||||
* All features or bug fixes **must be tested** by one or more specs (unit-tests).
|
* All features or bug fixes **must be tested** by one or more specs (unit-tests).
|
||||||
* All public API methods **must be documented**.
|
* All public API methods **must be documented**. (Details TBC).
|
||||||
* We follow [Google's JavaScript Style Guide][js-style-guide], but wrap all code at **100 characters**.
|
* We follow [Google's JavaScript Style Guide][js-style-guide], but wrap all code at
|
||||||
|
**100 characters**. An automated formatter is available, see
|
||||||
|
[DEVELOPER.md](docs/DEVELOPER.md#clang-format).
|
||||||
|
|
||||||
An automated formatter is available, see [DEVELOPER.md](docs/DEVELOPER.md#clang-format).
|
## <a name="commit"></a> Commit Message Guidelines
|
||||||
|
|
||||||
|
We have very precise rules over how our git commit messages can be formatted. This leads to **more
|
||||||
|
readable messages** that are easy to follow when looking through the **project history**. But also,
|
||||||
|
we use the git commit messages to **generate the Angular change log**.
|
||||||
|
|
||||||
## <a name="commit"></a> Commit Message Format
|
### Commit Message Format
|
||||||
|
Each commit message consists of a **header**, a **body** and a **footer**. The header has a special
|
||||||
*This specification is inspired and supersedes the [AngularJS commit message format][commit-message-format].*
|
format that includes a **type**, a **scope** and a **subject**:
|
||||||
|
|
||||||
We have very precise rules over how our Git commit messages must be formatted.
|
|
||||||
This format leads to **easier to read commit history**.
|
|
||||||
|
|
||||||
Each commit message consists of a **header**, a **body**, and a **footer**.
|
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
<header>
|
<type>(<scope>): <subject>
|
||||||
<BLANK LINE>
|
<BLANK LINE>
|
||||||
<body>
|
<body>
|
||||||
<BLANK LINE>
|
<BLANK LINE>
|
||||||
<footer>
|
<footer>
|
||||||
```
|
```
|
||||||
|
|
||||||
The `header` is mandatory and must conform to the [Commit Message Header](#commit-header) format.
|
The **header** is mandatory and the **scope** of the header is optional.
|
||||||
|
|
||||||
The `body` is mandatory for all commits except for those of scope "docs".
|
Any line of the commit message cannot be longer than 100 characters! This allows the message to be easier
|
||||||
When the body is required it must be at least 20 characters long.
|
to read on GitHub as well as in various git tools.
|
||||||
|
|
||||||
The `footer` is optional.
|
The footer should contain a [closing reference to an issue](https://help.github.com/articles/closing-issues-via-commit-messages/) if any.
|
||||||
|
|
||||||
Any line of the commit message cannot be longer than 100 characters.
|
Samples: (even more [samples](https://github.com/angular/angular/commits/master))
|
||||||
|
|
||||||
|
|
||||||
#### <a href="commit-header"></a>Commit Message Header
|
|
||||||
|
|
||||||
```
|
```
|
||||||
<type>(<scope>): <short summary>
|
docs(changelog): update changelog to beta.5
|
||||||
│ │ │
|
```
|
||||||
│ │ └─⫸ Summary in present tense. Not capitalized. No period at the end.
|
```
|
||||||
│ │
|
fix(release): need to depend on latest rxjs and zone.js
|
||||||
│ └─⫸ Commit Scope: animations|bazel|benchpress|common|compiler|compiler-cli|core|
|
|
||||||
│ elements|forms|http|language-service|localize|platform-browser|
|
The version in our package.json gets copied to the one we publish, and users need the latest of these.
|
||||||
│ platform-browser-dynamic|platform-server|platform-webworker|
|
|
||||||
│ platform-webworker-dynamic|router|service-worker|upgrade|zone.js|
|
|
||||||
│ packaging|changelog|dev-infra|docs-infra|migrations|ngcc|ve
|
|
||||||
│
|
|
||||||
└─⫸ Commit Type: build|ci|docs|feat|fix|perf|refactor|style|test
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The `<type>` and `<summary>` fields are mandatory, the `(<scope>)` field is optional.
|
### Revert
|
||||||
|
If the commit reverts a previous commit, it should begin with `revert: `, followed by the header of the reverted commit. In the body it should say: `This reverts commit <hash>.`, where the hash is the SHA of the commit being reverted.
|
||||||
|
|
||||||
##### Type
|
|
||||||
|
|
||||||
|
### Type
|
||||||
Must be one of the following:
|
Must be one of the following:
|
||||||
|
|
||||||
* **build**: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
|
* **build**: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
|
||||||
@ -233,95 +200,66 @@ Must be one of the following:
|
|||||||
* **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
|
* **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
|
||||||
* **test**: Adding missing tests or correcting existing tests
|
* **test**: Adding missing tests or correcting existing tests
|
||||||
|
|
||||||
|
### Scope
|
||||||
##### Scope
|
|
||||||
The scope should be the name of the npm package affected (as perceived by the person reading the changelog generated from commit messages).
|
The scope should be the name of the npm package affected (as perceived by the person reading the changelog generated from commit messages).
|
||||||
|
|
||||||
The following is the list of supported scopes:
|
The following is the list of supported scopes:
|
||||||
|
|
||||||
* `animations`
|
* **animations**
|
||||||
* `bazel`
|
* **bazel**
|
||||||
* `benchpress`
|
* **benchpress**
|
||||||
* `common`
|
* **common**
|
||||||
* `compiler`
|
* **compiler**
|
||||||
* `compiler-cli`
|
* **compiler-cli**
|
||||||
* `core`
|
* **core**
|
||||||
* `elements`
|
* **elements**
|
||||||
* `forms`
|
* **forms**
|
||||||
* `http`
|
* **http**
|
||||||
* `language-service`
|
* **language-service**
|
||||||
* `localize`
|
* **localize**
|
||||||
* `platform-browser`
|
* **platform-browser**
|
||||||
* `platform-browser-dynamic`
|
* **platform-browser-dynamic**
|
||||||
* `platform-server`
|
* **platform-server**
|
||||||
* `platform-webworker`
|
* **platform-webworker**
|
||||||
* `platform-webworker-dynamic`
|
* **platform-webworker-dynamic**
|
||||||
* `router`
|
* **router**
|
||||||
* `service-worker`
|
* **service-worker**
|
||||||
* `upgrade`
|
* **upgrade**
|
||||||
* `zone.js`
|
* **zone.js**
|
||||||
|
|
||||||
There are currently a few exceptions to the "use package name" rule:
|
There are currently a few exceptions to the "use package name" rule:
|
||||||
|
|
||||||
* `packaging`: used for changes that change the npm package layout in all of our packages, e.g. public path changes, package.json changes done to all packages, d.ts file/format changes, changes to bundles, etc.
|
* **packaging**: used for changes that change the npm package layout in all of our packages, e.g.
|
||||||
|
public path changes, package.json changes done to all packages, d.ts file/format changes, changes
|
||||||
|
to bundles, etc.
|
||||||
|
* **changelog**: used for updating the release notes in CHANGELOG.md
|
||||||
|
* **docs-infra**: used for docs-app (angular.io) related changes within the /aio directory of the
|
||||||
|
repo
|
||||||
|
* **dev-infra**: used for dev-infra related changes within the directories /scripts, /tools and /dev-infra
|
||||||
|
* **ngcc**: used for changes to the [Angular Compatibility Compiler](./packages/compiler-cli/ngcc/README.md)
|
||||||
|
* **ve**: used for changes specific to ViewEngine (legacy compiler/renderer).
|
||||||
|
* none/empty string: useful for `style`, `test` and `refactor` changes that are done across all
|
||||||
|
packages (e.g. `style: add missing semicolons`) and for docs changes that are not related to a
|
||||||
|
specific package (e.g. `docs: fix typo in tutorial`).
|
||||||
|
|
||||||
* `changelog`: used for updating the release notes in CHANGELOG.md
|
### Subject
|
||||||
|
The subject contains a succinct description of the change:
|
||||||
* `dev-infra`: used for dev-infra related changes within the directories /scripts, /tools and /dev-infra
|
|
||||||
|
|
||||||
* `docs-infra`: used for docs-app (angular.io) related changes within the /aio directory of the repo
|
|
||||||
|
|
||||||
* `migrations`: used for changes to the `ng update` migrations.
|
|
||||||
|
|
||||||
* `ngcc`: used for changes to the [Angular Compatibility Compiler](./packages/compiler-cli/ngcc/README.md)
|
|
||||||
|
|
||||||
* `ve`: used for changes specific to ViewEngine (legacy compiler/renderer).
|
|
||||||
|
|
||||||
* none/empty string: useful for `style`, `test` and `refactor` changes that are done across all packages (e.g. `style: add missing semicolons`) and for docs changes that are not related to a specific package (e.g. `docs: fix typo in tutorial`).
|
|
||||||
|
|
||||||
|
|
||||||
##### Summary
|
|
||||||
|
|
||||||
Use the summary field to provide a succinct description of the change:
|
|
||||||
|
|
||||||
* use the imperative, present tense: "change" not "changed" nor "changes"
|
* use the imperative, present tense: "change" not "changed" nor "changes"
|
||||||
* don't capitalize the first letter
|
* don't capitalize the first letter
|
||||||
* no dot (.) at the end
|
* no dot (.) at the end
|
||||||
|
|
||||||
|
### Body
|
||||||
|
Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes".
|
||||||
|
The body should include the motivation for the change and contrast this with previous behavior.
|
||||||
|
|
||||||
#### Commit Message Body
|
### Footer
|
||||||
|
The footer should contain any information about **Breaking Changes** and is also the place to
|
||||||
|
reference GitHub issues that this commit **Closes**.
|
||||||
|
|
||||||
Just as in the summary, use the imperative, present tense: "fix" not "fixed" nor "fixes".
|
**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines. The rest of the commit message is then used for this.
|
||||||
|
|
||||||
Explain the motivation for the change in the commit message body. This commit message should explain _why_ you are making the change.
|
|
||||||
You can include a comparison of the previous behavior with the new behavior in order to illustrate the impact of the change.
|
|
||||||
|
|
||||||
|
|
||||||
#### Commit Message Footer
|
|
||||||
|
|
||||||
The footer can contain information about breaking changes and is also the place to reference GitHub issues, Jira tickets, and other PRs that this commit closes or is related to.
|
|
||||||
|
|
||||||
```
|
|
||||||
BREAKING CHANGE: <breaking change summary>
|
|
||||||
<BLANK LINE>
|
|
||||||
<breaking change description + migration instructions>
|
|
||||||
<BLANK LINE>
|
|
||||||
<BLANK LINE>
|
|
||||||
Fixes #<issue number>
|
|
||||||
```
|
|
||||||
|
|
||||||
Breaking Change section should start with the phrase "BREAKING CHANGE: " followed by a summary of the breaking change, a blank line, and a detailed description of the breaking change that also includes migration instructions.
|
|
||||||
|
|
||||||
|
|
||||||
### Revert commits
|
|
||||||
|
|
||||||
If the commit reverts a previous commit, it should begin with `revert: `, followed by the header of the reverted commit.
|
|
||||||
|
|
||||||
The content of the commit message body should contain:
|
|
||||||
|
|
||||||
- information about the SHA of the commit being reverted in the following format: `This reverts commit <SHA>`,
|
|
||||||
- a clear description of the reason for reverting the commit message.
|
|
||||||
|
|
||||||
|
A detailed explanation can be found in this [document][commit-message-format].
|
||||||
|
|
||||||
## <a name="cla"></a> Signing the CLA
|
## <a name="cla"></a> Signing the CLA
|
||||||
|
|
||||||
@ -332,17 +270,18 @@ changes to be accepted, the CLA must be signed. It's a quick process, we promise
|
|||||||
* For corporations, we'll need you to
|
* For corporations, we'll need you to
|
||||||
[print, sign and one of scan+email, fax or mail the form][corporate-cla].
|
[print, sign and one of scan+email, fax or mail the form][corporate-cla].
|
||||||
|
|
||||||
If you have more than one GitHub accounts, or multiple email addresses associated with a single GitHub account, you must sign the CLA using the primary email address of the GitHub account used to author Git commits and send pull requests.
|
<hr>
|
||||||
|
|
||||||
The following documents can help you sort out issues with GitHub accounts and multiple email addresses:
|
If you have more than one Git identity, you must make sure that you sign the CLA using the primary email address associated with the ID that has been granted access to the Angular repository. Git identities can be associated with more than one email address, and only one is primary. Here are some links to help you sort out multiple Git identities and email addresses:
|
||||||
|
|
||||||
* https://help.github.com/articles/setting-your-commit-email-address-in-git/
|
* https://help.github.com/articles/setting-your-commit-email-address-in-git/
|
||||||
* https://stackoverflow.com/questions/37245303/what-does-usera-committed-with-userb-13-days-ago-on-github-mean
|
* https://stackoverflow.com/questions/37245303/what-does-usera-committed-with-userb-13-days-ago-on-github-mean
|
||||||
* https://help.github.com/articles/about-commit-email-addresses/
|
* https://help.github.com/articles/about-commit-email-addresses/
|
||||||
* https://help.github.com/articles/blocking-command-line-pushes-that-expose-your-personal-email-address/
|
* https://help.github.com/articles/blocking-command-line-pushes-that-expose-your-personal-email-address/
|
||||||
|
|
||||||
|
Note that if you have more than one Git identity, it is important to verify that you are logged in with the same ID with which you signed the CLA, before you commit changes. If not, your PR will fail the CLA check.
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
[angular-group]: https://groups.google.com/forum/#!forum/angular
|
[angular-group]: https://groups.google.com/forum/#!forum/angular
|
||||||
[coc]: https://github.com/angular/code-of-conduct/blob/master/CODE_OF_CONDUCT.md
|
[coc]: https://github.com/angular/code-of-conduct/blob/master/CODE_OF_CONDUCT.md
|
||||||
|
21
README.md
21
README.md
@ -5,21 +5,22 @@
|
|||||||
|
|
||||||
# Angular
|
# Angular
|
||||||
|
|
||||||
Angular es una plataforma de desarrollo para construir aplicaciones web y móviles que usa TypeScript/JavaScript y otros lenguajes de programación.
|
Angular is a development platform for building mobile and desktop web applications using TypeScript/JavaScript and other languages.
|
||||||
|
|
||||||
## Guía rápida
|
## Quickstart
|
||||||
|
|
||||||
[Comienza a usarlo en 5 minutos][quickstart].
|
[Get started in 5 minutes][quickstart].
|
||||||
|
|
||||||
## Registro de cambios (Changelog)
|
## Changelog
|
||||||
|
|
||||||
[Últimas mejoras realizadas][changelog].
|
[Learn about the latest improvements][changelog].
|
||||||
|
|
||||||
## ¿Quieres ayudar?
|
## Want to help?
|
||||||
|
|
||||||
¿Quieres encontrar fallos, colaborar con código, o mejorar la documentación? ¡Excelente! Lee nuestras
|
Want to file a bug, contribute some code, or improve documentation? Excellent! Read up on our
|
||||||
pautas para [colaborar][contributing] y luego revisa algunos de nuestras incidencias (issues) en [ayuda comunitaria](https://github.com/angular-hispano/angular/labels/ayuda%20comunitaria).
|
guidelines for [contributing][contributing] and then check out one of our issues in the [hotlist: community-help](https://github.com/angular/angular/labels/hotlist%3A%20community-help).
|
||||||
|
|
||||||
[contributing]: https://github.com/angular-hispano/angular/blob/master/CONTRIBUTING.md
|
[contributing]: https://github.com/angular/angular/blob/master/CONTRIBUTING.md
|
||||||
[quickstart]: https://docs.angular.lat/start
|
[quickstart]: https://angular.io/start
|
||||||
[changelog]: https://github.com/angular/angular/blob/master/CHANGELOG.md
|
[changelog]: https://github.com/angular/angular/blob/master/CHANGELOG.md
|
||||||
|
[ng]: https://angular.io
|
||||||
|
15
WORKSPACE
15
WORKSPACE
@ -8,8 +8,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
|||||||
# Fetch rules_nodejs so we can install our npm dependencies
|
# Fetch rules_nodejs so we can install our npm dependencies
|
||||||
http_archive(
|
http_archive(
|
||||||
name = "build_bazel_rules_nodejs",
|
name = "build_bazel_rules_nodejs",
|
||||||
sha256 = "84abf7ac4234a70924628baa9a73a5a5cbad944c4358cf9abdb4aab29c9a5b77",
|
sha256 = "f9e7b9f42ae202cc2d2ce6d698ccb49a9f7f7ea572a78fd451696d03ef2ee116",
|
||||||
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/1.7.0/rules_nodejs-1.7.0.tar.gz"],
|
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/1.6.0/rules_nodejs-1.6.0.tar.gz"],
|
||||||
)
|
)
|
||||||
|
|
||||||
# Check the rules_nodejs version and download npm dependencies
|
# Check the rules_nodejs version and download npm dependencies
|
||||||
@ -17,7 +17,7 @@ http_archive(
|
|||||||
# assert on that.
|
# assert on that.
|
||||||
load("@build_bazel_rules_nodejs//:index.bzl", "check_rules_nodejs_version", "node_repositories", "yarn_install")
|
load("@build_bazel_rules_nodejs//:index.bzl", "check_rules_nodejs_version", "node_repositories", "yarn_install")
|
||||||
|
|
||||||
check_rules_nodejs_version(minimum_version_string = "1.7.0")
|
check_rules_nodejs_version(minimum_version_string = "1.6.0")
|
||||||
|
|
||||||
# Setup the Node.js toolchain
|
# Setup the Node.js toolchain
|
||||||
node_repositories(
|
node_repositories(
|
||||||
@ -64,7 +64,7 @@ load("@io_bazel_rules_webtesting//web:repositories.bzl", "web_test_repositories"
|
|||||||
|
|
||||||
web_test_repositories()
|
web_test_repositories()
|
||||||
|
|
||||||
load("//dev-infra/browsers:browser_repositories.bzl", "browser_repositories")
|
load("//tools/browsers:browser_repositories.bzl", "browser_repositories")
|
||||||
|
|
||||||
browser_repositories()
|
browser_repositories()
|
||||||
|
|
||||||
@ -91,18 +91,17 @@ rbe_autoconfig(
|
|||||||
# Need to specify a base container digest in order to ensure that we can use the checked-in
|
# Need to specify a base container digest in order to ensure that we can use the checked-in
|
||||||
# platform configurations for the "ubuntu16_04" image. Otherwise the autoconfig rule would
|
# platform configurations for the "ubuntu16_04" image. Otherwise the autoconfig rule would
|
||||||
# need to pull the image and run it in order determine the toolchain configuration. See:
|
# need to pull the image and run it in order determine the toolchain configuration. See:
|
||||||
# https://github.com/bazelbuild/bazel-toolchains/blob/3.2.0/configs/ubuntu16_04_clang/versions.bzl
|
# https://github.com/bazelbuild/bazel-toolchains/blob/1.1.2/configs/ubuntu16_04_clang/versions.bzl
|
||||||
base_container_digest = "sha256:5e750dd878df9fcf4e185c6f52b9826090f6e532b097f286913a428290622332",
|
base_container_digest = "sha256:1ab40405810effefa0b2f45824d6d608634ccddbf06366760c341ef6fbead011",
|
||||||
# Note that if you change the `digest`, you might also need to update the
|
# Note that if you change the `digest`, you might also need to update the
|
||||||
# `base_container_digest` to make sure marketplace.gcr.io/google/rbe-ubuntu16-04-webtest:<digest>
|
# `base_container_digest` to make sure marketplace.gcr.io/google/rbe-ubuntu16-04-webtest:<digest>
|
||||||
# and marketplace.gcr.io/google/rbe-ubuntu16-04:<base_container_digest> have
|
# and marketplace.gcr.io/google/rbe-ubuntu16-04:<base_container_digest> have
|
||||||
# the same Clang and JDK installed. Clang is needed because of the dependency on
|
# the same Clang and JDK installed. Clang is needed because of the dependency on
|
||||||
# @com_google_protobuf. Java is needed for the Bazel's test executor Java tool.
|
# @com_google_protobuf. Java is needed for the Bazel's test executor Java tool.
|
||||||
digest = "sha256:f743114235a43355bf8324e2ba0fa6a597236fe06f7bc99aaa9ac703631c306b",
|
digest = "sha256:0b8fa87db4b8e5366717a7164342a029d1348d2feea7ecc4b18c780bc2507059",
|
||||||
env = clang_env(),
|
env = clang_env(),
|
||||||
registry = "marketplace.gcr.io",
|
registry = "marketplace.gcr.io",
|
||||||
# We can't use the default "ubuntu16_04" RBE image provided by the autoconfig because we need
|
# We can't use the default "ubuntu16_04" RBE image provided by the autoconfig because we need
|
||||||
# a specific Linux kernel that comes with "libx11" in order to run headless browser tests.
|
# a specific Linux kernel that comes with "libx11" in order to run headless browser tests.
|
||||||
repository = "google/rbe-ubuntu16-04-webtest",
|
repository = "google/rbe-ubuntu16-04-webtest",
|
||||||
use_checked_in_confs = "Force",
|
|
||||||
)
|
)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# Image metadata and config
|
# Image metadata and config
|
||||||
FROM debian:buster
|
FROM debian:stretch
|
||||||
|
|
||||||
LABEL name="angular.io PR preview" \
|
LABEL name="angular.io PR preview" \
|
||||||
description="This image implements the PR preview functionality for angular.io." \
|
description="This image implements the PR preview functionality for angular.io." \
|
||||||
@ -37,9 +37,9 @@ ARG TEST_AIO_NGINX_PORT_HTTPS=4433
|
|||||||
ARG AIO_SIGNIFICANT_FILES_PATTERN='^(?:aio|packages)/(?!.*[._]spec\\.[jt]s$)'
|
ARG AIO_SIGNIFICANT_FILES_PATTERN='^(?:aio|packages)/(?!.*[._]spec\\.[jt]s$)'
|
||||||
ARG TEST_AIO_SIGNIFICANT_FILES_PATTERN=$AIO_SIGNIFICANT_FILES_PATTERN
|
ARG TEST_AIO_SIGNIFICANT_FILES_PATTERN=$AIO_SIGNIFICANT_FILES_PATTERN
|
||||||
ARG AIO_TRUSTED_PR_LABEL="aio: preview"
|
ARG AIO_TRUSTED_PR_LABEL="aio: preview"
|
||||||
ARG TEST_AIO_TRUSTED_PR_LABEL=$AIO_TRUSTED_PR_LABEL
|
ARG TEST_AIO_TRUSTED_PR_LABEL="aio: preview"
|
||||||
ARG AIO_PREVIEW_SERVER_HOSTNAME=preview.localhost
|
ARG AIO_PREVIEW_SERVER_HOSTNAME=preview.localhost
|
||||||
ARG TEST_AIO_PREVIEW_SERVER_HOSTNAME=$AIO_PREVIEW_SERVER_HOSTNAME
|
ARG TEST_AIO_PREVIEW_SERVER_HOSTNAME=preview.localhost
|
||||||
ARG AIO_ARTIFACT_MAX_SIZE=26214400
|
ARG AIO_ARTIFACT_MAX_SIZE=26214400
|
||||||
ARG TEST_AIO_ARTIFACT_MAX_SIZE=200
|
ARG TEST_AIO_ARTIFACT_MAX_SIZE=200
|
||||||
ARG AIO_PREVIEW_SERVER_PORT=3000
|
ARG AIO_PREVIEW_SERVER_PORT=3000
|
||||||
@ -72,29 +72,24 @@ RUN mkdir /var/log/aio
|
|||||||
|
|
||||||
|
|
||||||
# Add extra package sources
|
# Add extra package sources
|
||||||
RUN apt-get update -y && apt-get install -y curl=7.64.0-4+deb10u1
|
RUN apt-get update -y && apt-get install -y curl
|
||||||
RUN curl --silent --show-error --location https://deb.nodesource.com/setup_12.x | bash -
|
RUN curl --silent --show-error --location https://deb.nodesource.com/setup_10.x | bash -
|
||||||
RUN curl --silent --show-error https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
|
RUN curl --silent --show-error https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
|
||||||
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
|
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
|
||||||
|
RUN echo "deb http://ftp.debian.org/debian stretch-backports main" | tee /etc/apt/sources.list.d/backports.list
|
||||||
|
|
||||||
|
|
||||||
# Install packages
|
# Install packages
|
||||||
# NOTE: Some packages (such as `nginx`, `nodejs`, `openssl`) make older versions unavailable on the
|
|
||||||
# repositories, so we cannot pin to specific versions for these packages :(
|
|
||||||
# See for example:
|
|
||||||
# - https://github.com/nodesource/distributions/issues/33
|
|
||||||
# - https://askubuntu.com/questions/715104/how-can-i-downgrade-openssl-via-apt-get
|
|
||||||
RUN apt-get update -y && apt-get install -y \
|
RUN apt-get update -y && apt-get install -y \
|
||||||
cron=3.0pl1-134+deb10u1 \
|
cron=3.0pl1-128+deb9u1 \
|
||||||
dnsmasq=2.80-1 \
|
dnsmasq=2.76-5+deb9u2 \
|
||||||
nano=3.2-3 \
|
nano=2.7.4-1 \
|
||||||
nginx \
|
nginx=1.10.3-1+deb9u2 \
|
||||||
nodejs \
|
nodejs=10.15.3-1nodesource1 \
|
||||||
openssl \
|
openssl=1.1.0j-1~deb9u1 \
|
||||||
rsyslog=8.1901.0-1 \
|
rsyslog=8.24.0-1 \
|
||||||
vim=2:8.1.0875-5 \
|
yarn=1.15.2-1
|
||||||
yarn=1.22.4-1
|
RUN yarn global add pm2@3.5.0
|
||||||
RUN yarn global add pm2@4.4.0
|
|
||||||
|
|
||||||
|
|
||||||
# Set up log rotation
|
# Set up log rotation
|
||||||
@ -167,7 +162,8 @@ RUN find $AIO_SCRIPTS_SH_DIR -maxdepth 1 -type f -printf "%P\n" \
|
|||||||
|
|
||||||
# Set up the Node.js scripts
|
# Set up the Node.js scripts
|
||||||
COPY scripts-js/ $AIO_SCRIPTS_JS_DIR/
|
COPY scripts-js/ $AIO_SCRIPTS_JS_DIR/
|
||||||
RUN yarn --cwd="$AIO_SCRIPTS_JS_DIR/" install --production --frozen-lockfile
|
WORKDIR $AIO_SCRIPTS_JS_DIR/
|
||||||
|
RUN yarn install --production --frozen-lockfile
|
||||||
|
|
||||||
|
|
||||||
# Set up health check
|
# Set up health check
|
||||||
|
@ -35,7 +35,6 @@ export class BuildCleaner {
|
|||||||
]);
|
]);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.error('ERROR:', error);
|
this.logger.error('ERROR:', error);
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import * as express from 'express';
|
import * as express from 'express';
|
||||||
|
import {promisify} from 'util';
|
||||||
import {PreviewServerError} from './preview-error';
|
import {PreviewServerError} from './preview-error';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -12,7 +13,7 @@ export async function respondWithError(res: express.Response, err: any): Promise
|
|||||||
}
|
}
|
||||||
|
|
||||||
res.status(err.status);
|
res.status(err.status);
|
||||||
return new Promise(resolve => res.end(err.message, resolve));
|
await promisify(res.end.bind(res))(err.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -93,7 +93,7 @@ class Helper {
|
|||||||
return fs.readFileSync(absFilePath, 'utf8');
|
return fs.readFileSync(absFilePath, 'utf8');
|
||||||
}
|
}
|
||||||
|
|
||||||
public runCmd(cmd: string, opts: cp.ExecOptions = {}): Promise<CmdResult> {
|
public runCmd(cmd: string, opts: cp.ExecFileOptions = {}): Promise<CmdResult> {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
const proc = cp.exec(cmd, opts, (err, stdout, stderr) => resolve({success: !err, err, stdout, stderr}));
|
const proc = cp.exec(cmd, opts, (err, stdout, stderr) => resolve({success: !err, err, stdout, stderr}));
|
||||||
this.createCleanUpFn(() => proc.kill());
|
this.createCleanUpFn(() => proc.kill());
|
||||||
@ -101,7 +101,7 @@ class Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public runForAllSupportedSchemes(suiteFactory: TestSuiteFactory): void {
|
public runForAllSupportedSchemes(suiteFactory: TestSuiteFactory): void {
|
||||||
Object.entries(this.portPerScheme).forEach(([scheme, port]) => suiteFactory(scheme, port));
|
Object.keys(this.portPerScheme).forEach(scheme => suiteFactory(scheme, this.portPerScheme[scheme]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public verifyResponse(status: number, regex: string | RegExp = /^/): VerifyCmdResultFn {
|
public verifyResponse(status: number, regex: string | RegExp = /^/): VerifyCmdResultFn {
|
||||||
|
@ -15,7 +15,7 @@ describe(`nginx`, () => {
|
|||||||
afterEach(() => h.cleanUp());
|
afterEach(() => h.cleanUp());
|
||||||
|
|
||||||
|
|
||||||
it('should redirect HTTP to HTTPS', async () => {
|
it('should redirect HTTP to HTTPS', done => {
|
||||||
const httpHost = `${AIO_NGINX_HOSTNAME}:${AIO_NGINX_PORT_HTTP}`;
|
const httpHost = `${AIO_NGINX_HOSTNAME}:${AIO_NGINX_PORT_HTTP}`;
|
||||||
const httpsHost = `${AIO_NGINX_HOSTNAME}:${AIO_NGINX_PORT_HTTPS}`;
|
const httpsHost = `${AIO_NGINX_HOSTNAME}:${AIO_NGINX_PORT_HTTPS}`;
|
||||||
const urlMap = {
|
const urlMap = {
|
||||||
@ -24,15 +24,16 @@ describe(`nginx`, () => {
|
|||||||
[`http://foo.${httpHost}/`]: `https://foo.${httpsHost}/`,
|
[`http://foo.${httpHost}/`]: `https://foo.${httpsHost}/`,
|
||||||
};
|
};
|
||||||
|
|
||||||
const verifyRedirection = async (fromUrl: string, toUrl: string) => {
|
const verifyRedirection = (httpUrl: string) => h.runCmd(`curl -i ${httpUrl}`).then(result => {
|
||||||
const result = await h.runCmd(`curl -i ${fromUrl}`);
|
|
||||||
h.verifyResponse(307)(result);
|
h.verifyResponse(307)(result);
|
||||||
|
|
||||||
const headers = result.stdout.split(/(?:\r?\n){2,}/)[0];
|
const headers = result.stdout.split(/(?:\r?\n){2,}/)[0];
|
||||||
expect(headers).toContain(`Location: ${toUrl}`);
|
expect(headers).toContain(`Location: ${urlMap[httpUrl]}`);
|
||||||
};
|
});
|
||||||
|
|
||||||
await Promise.all(Object.entries(urlMap).map(urls => verifyRedirection(...urls)));
|
Promise.
|
||||||
|
all(Object.keys(urlMap).map(verifyRedirection)).
|
||||||
|
then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -61,15 +62,15 @@ describe(`nginx`, () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should return /index.html', async () => {
|
it('should return /index.html', done => {
|
||||||
const origin = `${scheme}://pr${pr}-${shortSha9}.${host}`;
|
const origin = `${scheme}://pr${pr}-${shortSha9}.${host}`;
|
||||||
const bodyRegex = new RegExp(`^PR: ${pr} | SHA: ${sha9} | File: /index\\.html$`);
|
const bodyRegex = new RegExp(`^PR: ${pr} | SHA: ${sha9} | File: /index\\.html$`);
|
||||||
|
|
||||||
await Promise.all([
|
Promise.all([
|
||||||
h.runCmd(`curl -iL ${origin}/index.html`).then(h.verifyResponse(200, bodyRegex)),
|
h.runCmd(`curl -iL ${origin}/index.html`).then(h.verifyResponse(200, bodyRegex)),
|
||||||
h.runCmd(`curl -iL ${origin}/`).then(h.verifyResponse(200, bodyRegex)),
|
h.runCmd(`curl -iL ${origin}/`).then(h.verifyResponse(200, bodyRegex)),
|
||||||
h.runCmd(`curl -iL ${origin}`).then(h.verifyResponse(200, bodyRegex)),
|
h.runCmd(`curl -iL ${origin}`).then(h.verifyResponse(200, bodyRegex)),
|
||||||
]);
|
]).then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -89,11 +90,12 @@ describe(`nginx`, () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should return /foo/bar.js', async () => {
|
it('should return /foo/bar.js', done => {
|
||||||
const bodyRegex = new RegExp(`^PR: ${pr} | SHA: ${sha9} | File: /foo/bar\\.js$`);
|
const bodyRegex = new RegExp(`^PR: ${pr} | SHA: ${sha9} | File: /foo/bar\\.js$`);
|
||||||
|
|
||||||
await h.runCmd(`curl -iL ${scheme}://pr${pr}-${shortSha9}.${host}/foo/bar.js`).
|
h.runCmd(`curl -iL ${scheme}://pr${pr}-${shortSha9}.${host}/foo/bar.js`).
|
||||||
then(h.verifyResponse(200, bodyRegex));
|
then(h.verifyResponse(200, bodyRegex)).
|
||||||
|
then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -109,46 +111,47 @@ describe(`nginx`, () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should respond with 403 for directories', async () => {
|
it('should respond with 403 for directories', done => {
|
||||||
await Promise.all([
|
Promise.all([
|
||||||
h.runCmd(`curl -iL ${scheme}://pr${pr}-${shortSha9}.${host}/foo/`).then(h.verifyResponse(403)),
|
h.runCmd(`curl -iL ${scheme}://pr${pr}-${shortSha9}.${host}/foo/`).then(h.verifyResponse(403)),
|
||||||
h.runCmd(`curl -iL ${scheme}://pr${pr}-${shortSha9}.${host}/foo`).then(h.verifyResponse(403)),
|
h.runCmd(`curl -iL ${scheme}://pr${pr}-${shortSha9}.${host}/foo`).then(h.verifyResponse(403)),
|
||||||
]);
|
]).then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should respond with 404 for unknown paths to files', async () => {
|
it('should respond with 404 for unknown paths to files', done => {
|
||||||
await h.runCmd(`curl -iL ${scheme}://pr${pr}-${shortSha9}.${host}/foo/baz.css`).
|
h.runCmd(`curl -iL ${scheme}://pr${pr}-${shortSha9}.${host}/foo/baz.css`).
|
||||||
then(h.verifyResponse(404));
|
then(h.verifyResponse(404)).
|
||||||
|
then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should rewrite to \'index.html\' for unknown paths that don\'t look like files', async () => {
|
it('should rewrite to \'index.html\' for unknown paths that don\'t look like files', done => {
|
||||||
const origin = `${scheme}://pr${pr}-${shortSha9}.${host}`;
|
const origin = `${scheme}://pr${pr}-${shortSha9}.${host}`;
|
||||||
const bodyRegex = new RegExp(`^PR: ${pr} | SHA: ${sha9} | File: /index\\.html$`);
|
const bodyRegex = new RegExp(`^PR: ${pr} | SHA: ${sha9} | File: /index\\.html$`);
|
||||||
|
|
||||||
await Promise.all([
|
Promise.all([
|
||||||
h.runCmd(`curl -iL ${origin}/foo/baz`).then(h.verifyResponse(200, bodyRegex)),
|
h.runCmd(`curl -iL ${origin}/foo/baz`).then(h.verifyResponse(200, bodyRegex)),
|
||||||
h.runCmd(`curl -iL ${origin}/foo/baz/`).then(h.verifyResponse(200, bodyRegex)),
|
h.runCmd(`curl -iL ${origin}/foo/baz/`).then(h.verifyResponse(200, bodyRegex)),
|
||||||
]);
|
]).then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should respond with 404 for unknown PRs/SHAs', async () => {
|
it('should respond with 404 for unknown PRs/SHAs', done => {
|
||||||
const otherPr = 54321;
|
const otherPr = 54321;
|
||||||
const otherShortSha = computeShortSha('8'.repeat(40));
|
const otherShortSha = computeShortSha('8'.repeat(40));
|
||||||
|
|
||||||
await Promise.all([
|
Promise.all([
|
||||||
h.runCmd(`curl -iL ${scheme}://pr${pr}9-${shortSha9}.${host}`).then(h.verifyResponse(404)),
|
h.runCmd(`curl -iL ${scheme}://pr${pr}9-${shortSha9}.${host}`).then(h.verifyResponse(404)),
|
||||||
h.runCmd(`curl -iL ${scheme}://pr${otherPr}-${shortSha9}.${host}`).then(h.verifyResponse(404)),
|
h.runCmd(`curl -iL ${scheme}://pr${otherPr}-${shortSha9}.${host}`).then(h.verifyResponse(404)),
|
||||||
h.runCmd(`curl -iL ${scheme}://pr${pr}-${shortSha9}9.${host}`).then(h.verifyResponse(404)),
|
h.runCmd(`curl -iL ${scheme}://pr${pr}-${shortSha9}9.${host}`).then(h.verifyResponse(404)),
|
||||||
h.runCmd(`curl -iL ${scheme}://pr${pr}-${otherShortSha}.${host}`).then(h.verifyResponse(404)),
|
h.runCmd(`curl -iL ${scheme}://pr${pr}-${otherShortSha}.${host}`).then(h.verifyResponse(404)),
|
||||||
]);
|
]).then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should respond with 404 if the subdomain format is wrong', async () => {
|
it('should respond with 404 if the subdomain format is wrong', done => {
|
||||||
await Promise.all([
|
Promise.all([
|
||||||
h.runCmd(`curl -iL ${scheme}://xpr${pr}-${shortSha9}.${host}`).then(h.verifyResponse(404)),
|
h.runCmd(`curl -iL ${scheme}://xpr${pr}-${shortSha9}.${host}`).then(h.verifyResponse(404)),
|
||||||
h.runCmd(`curl -iL ${scheme}://prx${pr}-${shortSha9}.${host}`).then(h.verifyResponse(404)),
|
h.runCmd(`curl -iL ${scheme}://prx${pr}-${shortSha9}.${host}`).then(h.verifyResponse(404)),
|
||||||
h.runCmd(`curl -iL ${scheme}://xx${pr}-${shortSha9}.${host}`).then(h.verifyResponse(404)),
|
h.runCmd(`curl -iL ${scheme}://xx${pr}-${shortSha9}.${host}`).then(h.verifyResponse(404)),
|
||||||
@ -157,25 +160,26 @@ describe(`nginx`, () => {
|
|||||||
h.runCmd(`curl -iL ${scheme}://${pr}-${shortSha9}.${host}`).then(h.verifyResponse(404)),
|
h.runCmd(`curl -iL ${scheme}://${pr}-${shortSha9}.${host}`).then(h.verifyResponse(404)),
|
||||||
h.runCmd(`curl -iL ${scheme}://pr${pr}${shortSha9}.${host}`).then(h.verifyResponse(404)),
|
h.runCmd(`curl -iL ${scheme}://pr${pr}${shortSha9}.${host}`).then(h.verifyResponse(404)),
|
||||||
h.runCmd(`curl -iL ${scheme}://pr${pr}_${shortSha9}.${host}`).then(h.verifyResponse(404)),
|
h.runCmd(`curl -iL ${scheme}://pr${pr}_${shortSha9}.${host}`).then(h.verifyResponse(404)),
|
||||||
]);
|
]).then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should reject PRs with leading zeros', async () => {
|
it('should reject PRs with leading zeros', done => {
|
||||||
await h.runCmd(`curl -iL ${scheme}://pr0${pr}-${shortSha9}.${host}`).
|
h.runCmd(`curl -iL ${scheme}://pr0${pr}-${shortSha9}.${host}`).
|
||||||
then(h.verifyResponse(404));
|
then(h.verifyResponse(404)).
|
||||||
|
then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should accept SHAs with leading zeros (but not trim the zeros)', async () => {
|
it('should accept SHAs with leading zeros (but not trim the zeros)', done => {
|
||||||
const bodyRegex9 = new RegExp(`^PR: ${pr} | SHA: ${sha9} | File: /index\\.html$`);
|
const bodyRegex9 = new RegExp(`^PR: ${pr} | SHA: ${sha9} | File: /index\\.html$`);
|
||||||
const bodyRegex0 = new RegExp(`^PR: ${pr} | SHA: ${sha0} | File: /index\\.html$`);
|
const bodyRegex0 = new RegExp(`^PR: ${pr} | SHA: ${sha0} | File: /index\\.html$`);
|
||||||
|
|
||||||
await Promise.all([
|
Promise.all([
|
||||||
h.runCmd(`curl -iL ${scheme}://pr${pr}-0${shortSha9}.${host}`).then(h.verifyResponse(404)),
|
h.runCmd(`curl -iL ${scheme}://pr${pr}-0${shortSha9}.${host}`).then(h.verifyResponse(404)),
|
||||||
h.runCmd(`curl -iL ${scheme}://pr${pr}-${shortSha9}.${host}`).then(h.verifyResponse(200, bodyRegex9)),
|
h.runCmd(`curl -iL ${scheme}://pr${pr}-${shortSha9}.${host}`).then(h.verifyResponse(200, bodyRegex9)),
|
||||||
h.runCmd(`curl -iL ${scheme}://pr${pr}-${shortSha0}.${host}`).then(h.verifyResponse(200, bodyRegex0)),
|
h.runCmd(`curl -iL ${scheme}://pr${pr}-${shortSha0}.${host}`).then(h.verifyResponse(200, bodyRegex0)),
|
||||||
]);
|
]).then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -227,23 +231,23 @@ describe(`nginx`, () => {
|
|||||||
|
|
||||||
describe(`${host}/health-check`, () => {
|
describe(`${host}/health-check`, () => {
|
||||||
|
|
||||||
it('should respond with 200', async () => {
|
it('should respond with 200', done => {
|
||||||
await Promise.all([
|
Promise.all([
|
||||||
h.runCmd(`curl -iL ${scheme}://${host}/health-check`).then(h.verifyResponse(200)),
|
h.runCmd(`curl -iL ${scheme}://${host}/health-check`).then(h.verifyResponse(200)),
|
||||||
h.runCmd(`curl -iL ${scheme}://${host}/health-check/`).then(h.verifyResponse(200)),
|
h.runCmd(`curl -iL ${scheme}://${host}/health-check/`).then(h.verifyResponse(200)),
|
||||||
]);
|
]).then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should respond with 404 if the path does not match exactly', async () => {
|
it('should respond with 404 if the path does not match exactly', done => {
|
||||||
await Promise.all([
|
Promise.all([
|
||||||
h.runCmd(`curl -iL ${scheme}://${host}/health-check/foo`).then(h.verifyResponse(404)),
|
h.runCmd(`curl -iL ${scheme}://${host}/health-check/foo`).then(h.verifyResponse(404)),
|
||||||
h.runCmd(`curl -iL ${scheme}://${host}/health-check-foo`).then(h.verifyResponse(404)),
|
h.runCmd(`curl -iL ${scheme}://${host}/health-check-foo`).then(h.verifyResponse(404)),
|
||||||
h.runCmd(`curl -iL ${scheme}://${host}/health-checknfoo`).then(h.verifyResponse(404)),
|
h.runCmd(`curl -iL ${scheme}://${host}/health-checknfoo`).then(h.verifyResponse(404)),
|
||||||
h.runCmd(`curl -iL ${scheme}://${host}/foo/health-check`).then(h.verifyResponse(404)),
|
h.runCmd(`curl -iL ${scheme}://${host}/foo/health-check`).then(h.verifyResponse(404)),
|
||||||
h.runCmd(`curl -iL ${scheme}://${host}/foo-health-check`).then(h.verifyResponse(404)),
|
h.runCmd(`curl -iL ${scheme}://${host}/foo-health-check`).then(h.verifyResponse(404)),
|
||||||
h.runCmd(`curl -iL ${scheme}://${host}/foonhealth-check`).then(h.verifyResponse(404)),
|
h.runCmd(`curl -iL ${scheme}://${host}/foonhealth-check`).then(h.verifyResponse(404)),
|
||||||
]);
|
]).then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -287,28 +291,29 @@ describe(`nginx`, () => {
|
|||||||
|
|
||||||
describe(`${host}/circle-build`, () => {
|
describe(`${host}/circle-build`, () => {
|
||||||
|
|
||||||
it('should disallow non-POST requests', async () => {
|
it('should disallow non-POST requests', done => {
|
||||||
const url = `${scheme}://${host}/circle-build`;
|
const url = `${scheme}://${host}/circle-build`;
|
||||||
|
|
||||||
await Promise.all([
|
Promise.all([
|
||||||
h.runCmd(`curl -iLX GET ${url}`).then(h.verifyResponse(405)),
|
h.runCmd(`curl -iLX GET ${url}`).then(h.verifyResponse(405)),
|
||||||
h.runCmd(`curl -iLX PUT ${url}`).then(h.verifyResponse(405)),
|
h.runCmd(`curl -iLX PUT ${url}`).then(h.verifyResponse(405)),
|
||||||
h.runCmd(`curl -iLX PATCH ${url}`).then(h.verifyResponse(405)),
|
h.runCmd(`curl -iLX PATCH ${url}`).then(h.verifyResponse(405)),
|
||||||
h.runCmd(`curl -iLX DELETE ${url}`).then(h.verifyResponse(405)),
|
h.runCmd(`curl -iLX DELETE ${url}`).then(h.verifyResponse(405)),
|
||||||
]);
|
]).then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should pass requests through to the preview server', async () => {
|
it('should pass requests through to the preview server', done => {
|
||||||
await h.runCmd(`curl -iLX POST ${scheme}://${host}/circle-build`).
|
h.runCmd(`curl -iLX POST ${scheme}://${host}/circle-build`).
|
||||||
then(h.verifyResponse(400, /Incorrect body content. Expected JSON/));
|
then(h.verifyResponse(400, /Incorrect body content. Expected JSON/)).
|
||||||
|
then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should respond with 404 for unknown paths', async () => {
|
it('should respond with 404 for unknown paths', done => {
|
||||||
const cmdPrefix = `curl -iLX POST ${scheme}://${host}`;
|
const cmdPrefix = `curl -iLX POST ${scheme}://${host}`;
|
||||||
|
|
||||||
await Promise.all([
|
Promise.all([
|
||||||
h.runCmd(`${cmdPrefix}/foo/circle-build/`).then(h.verifyResponse(404)),
|
h.runCmd(`${cmdPrefix}/foo/circle-build/`).then(h.verifyResponse(404)),
|
||||||
h.runCmd(`${cmdPrefix}/foo-circle-build/`).then(h.verifyResponse(404)),
|
h.runCmd(`${cmdPrefix}/foo-circle-build/`).then(h.verifyResponse(404)),
|
||||||
h.runCmd(`${cmdPrefix}/fooncircle-build/`).then(h.verifyResponse(404)),
|
h.runCmd(`${cmdPrefix}/fooncircle-build/`).then(h.verifyResponse(404)),
|
||||||
@ -317,7 +322,7 @@ describe(`nginx`, () => {
|
|||||||
h.runCmd(`${cmdPrefix}/circle-buildnfoo/`).then(h.verifyResponse(404)),
|
h.runCmd(`${cmdPrefix}/circle-buildnfoo/`).then(h.verifyResponse(404)),
|
||||||
h.runCmd(`${cmdPrefix}/circle-build/pr`).then(h.verifyResponse(404)),
|
h.runCmd(`${cmdPrefix}/circle-build/pr`).then(h.verifyResponse(404)),
|
||||||
h.runCmd(`${cmdPrefix}/circle-build/42`).then(h.verifyResponse(404)),
|
h.runCmd(`${cmdPrefix}/circle-build/42`).then(h.verifyResponse(404)),
|
||||||
]);
|
]).then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -327,33 +332,38 @@ describe(`nginx`, () => {
|
|||||||
const url = `${scheme}://${host}/pr-updated`;
|
const url = `${scheme}://${host}/pr-updated`;
|
||||||
|
|
||||||
|
|
||||||
it('should disallow non-POST requests', async () => {
|
it('should disallow non-POST requests', done => {
|
||||||
await Promise.all([
|
Promise.all([
|
||||||
h.runCmd(`curl -iLX GET ${url}`).then(h.verifyResponse(405)),
|
h.runCmd(`curl -iLX GET ${url}`).then(h.verifyResponse(405)),
|
||||||
h.runCmd(`curl -iLX PUT ${url}`).then(h.verifyResponse(405)),
|
h.runCmd(`curl -iLX PUT ${url}`).then(h.verifyResponse(405)),
|
||||||
h.runCmd(`curl -iLX PATCH ${url}`).then(h.verifyResponse(405)),
|
h.runCmd(`curl -iLX PATCH ${url}`).then(h.verifyResponse(405)),
|
||||||
h.runCmd(`curl -iLX DELETE ${url}`).then(h.verifyResponse(405)),
|
h.runCmd(`curl -iLX DELETE ${url}`).then(h.verifyResponse(405)),
|
||||||
]);
|
]).then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should pass requests through to the preview server', async () => {
|
it('should pass requests through to the preview server', done => {
|
||||||
await h.runCmd(`curl -iLX POST --header "Content-Type: application/json" ${url}`).
|
const cmdPrefix = `curl -iLX POST --header "Content-Type: application/json"`;
|
||||||
then(h.verifyResponse(400, /Missing or empty 'number' field/));
|
|
||||||
|
const cmd1 = `${cmdPrefix} ${url}`;
|
||||||
|
|
||||||
|
Promise.all([
|
||||||
|
h.runCmd(cmd1).then(h.verifyResponse(400, /Missing or empty 'number' field/)),
|
||||||
|
]).then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should respond with 404 for unknown paths', async () => {
|
it('should respond with 404 for unknown paths', done => {
|
||||||
const cmdPrefix = `curl -iLX POST ${scheme}://${host}`;
|
const cmdPrefix = `curl -iLX POST ${scheme}://${host}`;
|
||||||
|
|
||||||
await Promise.all([
|
Promise.all([
|
||||||
h.runCmd(`${cmdPrefix}/foo/pr-updated`).then(h.verifyResponse(404)),
|
h.runCmd(`${cmdPrefix}/foo/pr-updated`).then(h.verifyResponse(404)),
|
||||||
h.runCmd(`${cmdPrefix}/foo-pr-updated`).then(h.verifyResponse(404)),
|
h.runCmd(`${cmdPrefix}/foo-pr-updated`).then(h.verifyResponse(404)),
|
||||||
h.runCmd(`${cmdPrefix}/foonpr-updated`).then(h.verifyResponse(404)),
|
h.runCmd(`${cmdPrefix}/foonpr-updated`).then(h.verifyResponse(404)),
|
||||||
h.runCmd(`${cmdPrefix}/pr-updated/foo`).then(h.verifyResponse(404)),
|
h.runCmd(`${cmdPrefix}/pr-updated/foo`).then(h.verifyResponse(404)),
|
||||||
h.runCmd(`${cmdPrefix}/pr-updated-foo`).then(h.verifyResponse(404)),
|
h.runCmd(`${cmdPrefix}/pr-updated-foo`).then(h.verifyResponse(404)),
|
||||||
h.runCmd(`${cmdPrefix}/pr-updatednfoo`).then(h.verifyResponse(404)),
|
h.runCmd(`${cmdPrefix}/pr-updatednfoo`).then(h.verifyResponse(404)),
|
||||||
]);
|
]).then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -364,7 +374,7 @@ describe(`nginx`, () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
['index.html', 'foo.js', 'foo/index.html'].forEach(relFilePath => {
|
['index.html', 'foo.js', 'foo/index.html'].forEach(relFilePath => {
|
||||||
const absFilePath = path.join(AIO_BUILDS_DIR, relFilePath);
|
const absFilePath = path.join(AIO_BUILDS_DIR, relFilePath);
|
||||||
h.writeFile(absFilePath, {content: `File: /${relFilePath}`});
|
return h.writeFile(absFilePath, {content: `File: /${relFilePath}`});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -105,8 +105,8 @@ describe('preview-server', () => {
|
|||||||
|
|
||||||
|
|
||||||
describe(`${host}/circle-build`, () => {
|
describe(`${host}/circle-build`, () => {
|
||||||
const curl = makeCurl(`${host}/circle-build`);
|
|
||||||
|
|
||||||
|
const curl = makeCurl(`${host}/circle-build`);
|
||||||
|
|
||||||
it('should disallow non-POST requests', async () => {
|
it('should disallow non-POST requests', async () => {
|
||||||
const bodyRegex = /^Unknown resource/;
|
const bodyRegex = /^Unknown resource/;
|
||||||
@ -189,7 +189,8 @@ describe('preview-server', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should respond with 201 if a new public build is created', async () => {
|
it('should respond with 201 if a new public build is created', async () => {
|
||||||
await curl(payload(BuildNums.TRUST_CHECK_ACTIVE_TRUSTED_USER)).then(h.verifyResponse(201));
|
await curl(payload(BuildNums.TRUST_CHECK_ACTIVE_TRUSTED_USER))
|
||||||
|
.then(h.verifyResponse(201));
|
||||||
expect({ prNum: PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER }).toExistAsABuild();
|
expect({ prNum: PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER }).toExistAsABuild();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -198,7 +199,7 @@ describe('preview-server', () => {
|
|||||||
expect({ prNum: PrNums.TRUST_CHECK_UNTRUSTED, isPublic: false }).toExistAsABuild();
|
expect({ prNum: PrNums.TRUST_CHECK_UNTRUSTED, isPublic: false }).toExistAsABuild();
|
||||||
});
|
});
|
||||||
|
|
||||||
[true, false].forEach(isPublic => {
|
[true].forEach(isPublic => {
|
||||||
const build = isPublic ? BuildNums.TRUST_CHECK_ACTIVE_TRUSTED_USER : BuildNums.TRUST_CHECK_UNTRUSTED;
|
const build = isPublic ? BuildNums.TRUST_CHECK_ACTIVE_TRUSTED_USER : BuildNums.TRUST_CHECK_UNTRUSTED;
|
||||||
const prNum = isPublic ? PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER : PrNums.TRUST_CHECK_UNTRUSTED;
|
const prNum = isPublic ? PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER : PrNums.TRUST_CHECK_UNTRUSTED;
|
||||||
const label = isPublic ? 'public' : 'non-public';
|
const label = isPublic ? 'public' : 'non-public';
|
||||||
@ -363,23 +364,23 @@ describe('preview-server', () => {
|
|||||||
|
|
||||||
describe(`${host}/health-check`, () => {
|
describe(`${host}/health-check`, () => {
|
||||||
|
|
||||||
it('should respond with 200', async () => {
|
it('should respond with 200', done => {
|
||||||
await Promise.all([
|
Promise.all([
|
||||||
h.runCmd(`curl -iL ${host}/health-check`).then(h.verifyResponse(200)),
|
h.runCmd(`curl -iL ${host}/health-check`).then(h.verifyResponse(200)),
|
||||||
h.runCmd(`curl -iL ${host}/health-check/`).then(h.verifyResponse(200)),
|
h.runCmd(`curl -iL ${host}/health-check/`).then(h.verifyResponse(200)),
|
||||||
]);
|
]).then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should respond with 404 if the path does not match exactly', async () => {
|
it('should respond with 404 if the path does not match exactly', done => {
|
||||||
await Promise.all([
|
Promise.all([
|
||||||
h.runCmd(`curl -iL ${host}/health-check/foo`).then(h.verifyResponse(404)),
|
h.runCmd(`curl -iL ${host}/health-check/foo`).then(h.verifyResponse(404)),
|
||||||
h.runCmd(`curl -iL ${host}/health-check-foo`).then(h.verifyResponse(404)),
|
h.runCmd(`curl -iL ${host}/health-check-foo`).then(h.verifyResponse(404)),
|
||||||
h.runCmd(`curl -iL ${host}/health-checknfoo`).then(h.verifyResponse(404)),
|
h.runCmd(`curl -iL ${host}/health-checknfoo`).then(h.verifyResponse(404)),
|
||||||
h.runCmd(`curl -iL ${host}/foo/health-check`).then(h.verifyResponse(404)),
|
h.runCmd(`curl -iL ${host}/foo/health-check`).then(h.verifyResponse(404)),
|
||||||
h.runCmd(`curl -iL ${host}/foo-health-check`).then(h.verifyResponse(404)),
|
h.runCmd(`curl -iL ${host}/foo-health-check`).then(h.verifyResponse(404)),
|
||||||
h.runCmd(`curl -iL ${host}/foonhealth-check`).then(h.verifyResponse(404)),
|
h.runCmd(`curl -iL ${host}/foonhealth-check`).then(h.verifyResponse(404)),
|
||||||
]);
|
]).then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -425,18 +426,18 @@ describe('preview-server', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should respond with 404 for unknown paths', async () => {
|
it('should respond with 404 for unknown paths', done => {
|
||||||
const mockPayload = JSON.stringify({number: 1}); // MockExternalApiFlags.TRUST_CHECK_ACTIVE_TRUSTED_USER });
|
const mockPayload = JSON.stringify({number: 1}); // MockExternalApiFlags.TRUST_CHECK_ACTIVE_TRUSTED_USER });
|
||||||
const cmdPrefix = `curl -iLX POST --data "${mockPayload}" ${host}`;
|
const cmdPrefix = `curl -iLX POST --data "${mockPayload}" ${host}`;
|
||||||
|
|
||||||
await Promise.all([
|
Promise.all([
|
||||||
h.runCmd(`${cmdPrefix}/foo/pr-updated`).then(h.verifyResponse(404)),
|
h.runCmd(`${cmdPrefix}/foo/pr-updated`).then(h.verifyResponse(404)),
|
||||||
h.runCmd(`${cmdPrefix}/foo-pr-updated`).then(h.verifyResponse(404)),
|
h.runCmd(`${cmdPrefix}/foo-pr-updated`).then(h.verifyResponse(404)),
|
||||||
h.runCmd(`${cmdPrefix}/foonpr-updated`).then(h.verifyResponse(404)),
|
h.runCmd(`${cmdPrefix}/foonpr-updated`).then(h.verifyResponse(404)),
|
||||||
h.runCmd(`${cmdPrefix}/pr-updated/foo`).then(h.verifyResponse(404)),
|
h.runCmd(`${cmdPrefix}/pr-updated/foo`).then(h.verifyResponse(404)),
|
||||||
h.runCmd(`${cmdPrefix}/pr-updated-foo`).then(h.verifyResponse(404)),
|
h.runCmd(`${cmdPrefix}/pr-updated-foo`).then(h.verifyResponse(404)),
|
||||||
h.runCmd(`${cmdPrefix}/pr-updatednfoo`).then(h.verifyResponse(404)),
|
h.runCmd(`${cmdPrefix}/pr-updatednfoo`).then(h.verifyResponse(404)),
|
||||||
]);
|
]).then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -550,10 +551,10 @@ describe('preview-server', () => {
|
|||||||
|
|
||||||
describe(`${host}/*`, () => {
|
describe(`${host}/*`, () => {
|
||||||
|
|
||||||
it('should respond with 404 for requests to unknown URLs', async () => {
|
it('should respond with 404 for requests to unknown URLs', done => {
|
||||||
const bodyRegex = /^Unknown resource/;
|
const bodyRegex = /^Unknown resource/;
|
||||||
|
|
||||||
await Promise.all([
|
Promise.all([
|
||||||
h.runCmd(`curl -iL ${host}/index.html`).then(h.verifyResponse(404, bodyRegex)),
|
h.runCmd(`curl -iL ${host}/index.html`).then(h.verifyResponse(404, bodyRegex)),
|
||||||
h.runCmd(`curl -iL ${host}/`).then(h.verifyResponse(404, bodyRegex)),
|
h.runCmd(`curl -iL ${host}/`).then(h.verifyResponse(404, bodyRegex)),
|
||||||
h.runCmd(`curl -iL ${host}`).then(h.verifyResponse(404, bodyRegex)),
|
h.runCmd(`curl -iL ${host}`).then(h.verifyResponse(404, bodyRegex)),
|
||||||
@ -561,7 +562,7 @@ describe('preview-server', () => {
|
|||||||
h.runCmd(`curl -iLX POST ${host}`).then(h.verifyResponse(404, bodyRegex)),
|
h.runCmd(`curl -iLX POST ${host}`).then(h.verifyResponse(404, bodyRegex)),
|
||||||
h.runCmd(`curl -iLX PATCH ${host}`).then(h.verifyResponse(404, bodyRegex)),
|
h.runCmd(`curl -iLX PATCH ${host}`).then(h.verifyResponse(404, bodyRegex)),
|
||||||
h.runCmd(`curl -iLX DELETE ${host}`).then(h.verifyResponse(404, bodyRegex)),
|
h.runCmd(`curl -iLX DELETE ${host}`).then(h.verifyResponse(404, bodyRegex)),
|
||||||
]);
|
]).then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -14,41 +14,42 @@
|
|||||||
"predev": "yarn build || true",
|
"predev": "yarn build || true",
|
||||||
"dev": "run-p ~~build-watch ~~test-watch",
|
"dev": "run-p ~~build-watch ~~test-watch",
|
||||||
"lint": "tslint --project tsconfig.json",
|
"lint": "tslint --project tsconfig.json",
|
||||||
"pretest": "run-s build lint",
|
"pretest": "yarn build",
|
||||||
"test": "yarn ~~test-only",
|
"test": "yarn ~~test-only",
|
||||||
"pretest-watch": "yarn pretest",
|
"pretest-watch": "yarn pretest",
|
||||||
"test-watch": "yarn ~~test-watch",
|
"test-watch": "yarn ~~test-watch",
|
||||||
"~~build": "tsc",
|
"~~build": "tsc",
|
||||||
"~~build-watch": "yarn ~~build --watch",
|
"~~build-watch": "yarn ~~build --watch",
|
||||||
|
"pre~~test-only": "yarn lint",
|
||||||
"~~test-only": "node dist/test",
|
"~~test-only": "node dist/test",
|
||||||
"~~test-watch": "nodemon --delay 1 --exec \"yarn ~~test-only\" --watch dist"
|
"~~test-watch": "nodemon --delay 1 --exec \"yarn ~~test-only\" --watch dist"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.18.3",
|
||||||
"delete-empty": "^3.0.0",
|
"delete-empty": "^2.0.0",
|
||||||
"express": "^4.17.1",
|
"express": "^4.16.3",
|
||||||
"jasmine": "^3.5.0",
|
"jasmine": "^3.2.0",
|
||||||
"nock": "^12.0.3",
|
"nock": "^9.6.1",
|
||||||
"node-fetch": "^2.6.0",
|
"node-fetch": "^2.2.0",
|
||||||
"shelljs": "^0.8.4",
|
"shelljs": "^0.8.2",
|
||||||
"source-map-support": "^0.5.19",
|
"source-map-support": "^0.5.9",
|
||||||
"tar-stream": "^2.1.2",
|
"tar-stream": "^1.6.1",
|
||||||
"tslib": "^1.11.1"
|
"tslib": "^1.10.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/body-parser": "^1.19.0",
|
"@types/body-parser": "^1.17.0",
|
||||||
"@types/express": "^4.17.6",
|
"@types/express": "^4.16.0",
|
||||||
"@types/jasmine": "^3.5.10",
|
"@types/jasmine": "^2.8.8",
|
||||||
"@types/nock": "^11.1.0",
|
"@types/nock": "^9.3.0",
|
||||||
"@types/node": "^13.13.2",
|
"@types/node": "^10.9.2",
|
||||||
"@types/node-fetch": "^2.5.7",
|
"@types/node-fetch": "^2.1.2",
|
||||||
"@types/shelljs": "^0.8.7",
|
"@types/shelljs": "^0.8.0",
|
||||||
"@types/supertest": "^2.0.8",
|
"@types/supertest": "^2.0.5",
|
||||||
"nodemon": "^2.0.3",
|
"nodemon": "^1.18.3",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"supertest": "^4.0.2",
|
"supertest": "^3.1.0",
|
||||||
"tslint": "^6.1.1",
|
"tslint": "^5.11.0",
|
||||||
"tslint-jasmine-noSkipOrFocus": "^1.0.9",
|
"tslint-jasmine-noSkipOrFocus": "^1.0.9",
|
||||||
"typescript": "^3.8.3"
|
"typescript": "^3.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ const EXISTING_DOWNLOADS = [
|
|||||||
'20-1234567-build.zip',
|
'20-1234567-build.zip',
|
||||||
];
|
];
|
||||||
const OPEN_PRS = [10, 40];
|
const OPEN_PRS = [10, 40];
|
||||||
|
const ANY_DATE = jasmine.any(String);
|
||||||
|
|
||||||
// Tests
|
// Tests
|
||||||
describe('BuildCleaner', () => {
|
describe('BuildCleaner', () => {
|
||||||
@ -76,18 +77,22 @@ describe('BuildCleaner', () => {
|
|||||||
let cleanerRemoveUnnecessaryDownloadsSpy: jasmine.Spy;
|
let cleanerRemoveUnnecessaryDownloadsSpy: jasmine.Spy;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cleanerGetExistingBuildNumbersSpy = spyOn(cleaner, 'getExistingBuildNumbers').and.resolveTo(EXISTING_BUILDS);
|
cleanerGetExistingBuildNumbersSpy = spyOn(cleaner, 'getExistingBuildNumbers')
|
||||||
cleanerGetOpenPrNumbersSpy = spyOn(cleaner, 'getOpenPrNumbers').and.resolveTo(OPEN_PRS);
|
.and.callFake(() => Promise.resolve(EXISTING_BUILDS));
|
||||||
cleanerGetExistingDownloadsSpy = spyOn(cleaner, 'getExistingDownloads').and.resolveTo(EXISTING_DOWNLOADS);
|
cleanerGetOpenPrNumbersSpy = spyOn(cleaner, 'getOpenPrNumbers')
|
||||||
|
.and.callFake(() => Promise.resolve(OPEN_PRS));
|
||||||
|
cleanerGetExistingDownloadsSpy = spyOn(cleaner, 'getExistingDownloads')
|
||||||
|
.and.callFake(() => Promise.resolve(EXISTING_DOWNLOADS));
|
||||||
|
|
||||||
cleanerRemoveUnnecessaryBuildsSpy = spyOn(cleaner, 'removeUnnecessaryBuilds');
|
cleanerRemoveUnnecessaryBuildsSpy = spyOn(cleaner, 'removeUnnecessaryBuilds');
|
||||||
cleanerRemoveUnnecessaryDownloadsSpy = spyOn(cleaner, 'removeUnnecessaryDownloads');
|
cleanerRemoveUnnecessaryDownloadsSpy = spyOn(cleaner, 'removeUnnecessaryDownloads');
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should return a promise', async () => {
|
it('should return a promise', async () => {
|
||||||
const promise = cleaner.cleanUp();
|
const promise = cleaner.cleanUp();
|
||||||
expect(promise).toBeInstanceOf(Promise);
|
expect(promise).toEqual(jasmine.any(Promise));
|
||||||
|
|
||||||
// Do not complete the test and release the spies synchronously, to avoid running the actual implementations.
|
// Do not complete the test and release the spies synchronously, to avoid running the actual implementations.
|
||||||
await promise;
|
await promise;
|
||||||
@ -125,32 +130,52 @@ describe('BuildCleaner', () => {
|
|||||||
|
|
||||||
|
|
||||||
it('should reject if \'getOpenPrNumbers()\' rejects', async () => {
|
it('should reject if \'getOpenPrNumbers()\' rejects', async () => {
|
||||||
cleanerGetOpenPrNumbersSpy.and.rejectWith('Test');
|
try {
|
||||||
await expectAsync(cleaner.cleanUp()).toBeRejectedWith('Test');
|
cleanerGetOpenPrNumbersSpy.and.callFake(() => Promise.reject('Test'));
|
||||||
|
await cleaner.cleanUp();
|
||||||
|
} catch (err) {
|
||||||
|
expect(err).toBe('Test');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should reject if \'getExistingBuildNumbers()\' rejects', async () => {
|
it('should reject if \'getExistingBuildNumbers()\' rejects', async () => {
|
||||||
cleanerGetExistingBuildNumbersSpy.and.rejectWith('Test');
|
try {
|
||||||
await expectAsync(cleaner.cleanUp()).toBeRejectedWith('Test');
|
cleanerGetExistingBuildNumbersSpy.and.callFake(() => Promise.reject('Test'));
|
||||||
|
await cleaner.cleanUp();
|
||||||
|
} catch (err) {
|
||||||
|
expect(err).toBe('Test');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should reject if \'getExistingDownloads()\' rejects', async () => {
|
it('should reject if \'getExistingDownloads()\' rejects', async () => {
|
||||||
cleanerGetExistingDownloadsSpy.and.rejectWith('Test');
|
try {
|
||||||
await expectAsync(cleaner.cleanUp()).toBeRejectedWith('Test');
|
cleanerGetExistingDownloadsSpy.and.callFake(() => Promise.reject('Test'));
|
||||||
|
await cleaner.cleanUp();
|
||||||
|
} catch (err) {
|
||||||
|
expect(err).toBe('Test');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should reject if \'removeUnnecessaryBuilds()\' rejects', async () => {
|
it('should reject if \'removeUnnecessaryBuilds()\' rejects', async () => {
|
||||||
cleanerRemoveUnnecessaryBuildsSpy.and.rejectWith('Test');
|
try {
|
||||||
await expectAsync(cleaner.cleanUp()).toBeRejectedWith('Test');
|
cleanerRemoveUnnecessaryBuildsSpy.and.callFake(() => Promise.reject('Test'));
|
||||||
|
await cleaner.cleanUp();
|
||||||
|
} catch (err) {
|
||||||
|
expect(err).toBe('Test');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should reject if \'removeUnnecessaryDownloads()\' rejects', async () => {
|
it('should reject if \'removeUnnecessaryDownloads()\' rejects', async () => {
|
||||||
cleanerRemoveUnnecessaryDownloadsSpy.and.rejectWith('Test');
|
try {
|
||||||
await expectAsync(cleaner.cleanUp()).toBeRejectedWith('Test');
|
cleanerRemoveUnnecessaryDownloadsSpy.and.callFake(() => Promise.reject('Test'));
|
||||||
|
await cleaner.cleanUp();
|
||||||
|
} catch (err) {
|
||||||
|
expect(err).toBe('Test');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -162,15 +187,13 @@ describe('BuildCleaner', () => {
|
|||||||
let promise: Promise<number[]>;
|
let promise: Promise<number[]>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fsReaddirSpy = spyOn(fs, 'readdir').and.callFake(
|
fsReaddirSpy = spyOn(fs, 'readdir').and.callFake((_: string, cb: typeof readdirCb) => readdirCb = cb);
|
||||||
((_: string, cb: typeof readdirCb) => readdirCb = cb) as unknown as typeof fs.readdir,
|
|
||||||
);
|
|
||||||
promise = cleaner.getExistingBuildNumbers();
|
promise = cleaner.getExistingBuildNumbers();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should return a promise', () => {
|
it('should return a promise', () => {
|
||||||
expect(promise).toBeInstanceOf(Promise);
|
expect(promise).toEqual(jasmine.any(Promise));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -180,27 +203,43 @@ describe('BuildCleaner', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should reject if an error occurs while getting the files', async () => {
|
it('should reject if an error occurs while getting the files', done => {
|
||||||
|
promise.catch(err => {
|
||||||
|
expect(err).toBe('Test');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
readdirCb('Test');
|
readdirCb('Test');
|
||||||
await expectAsync(promise).toBeRejectedWith('Test');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should resolve with the returned files (as numbers)', async () => {
|
it('should resolve with the returned files (as numbers)', done => {
|
||||||
|
promise.then(result => {
|
||||||
|
expect(result).toEqual([12, 34, 56]);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
readdirCb(null, ['12', '34', '56']);
|
readdirCb(null, ['12', '34', '56']);
|
||||||
await expectAsync(promise).toBeResolvedTo([12, 34, 56]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should remove `HIDDEN_DIR_PREFIX` from the filenames', async () => {
|
it('should remove `HIDDEN_DIR_PREFIX` from the filenames', done => {
|
||||||
|
promise.then(result => {
|
||||||
|
expect(result).toEqual([12, 34, 56]);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
readdirCb(null, [`${HIDDEN_DIR_PREFIX}12`, '34', `${HIDDEN_DIR_PREFIX}56`]);
|
readdirCb(null, [`${HIDDEN_DIR_PREFIX}12`, '34', `${HIDDEN_DIR_PREFIX}56`]);
|
||||||
await expectAsync(promise).toBeResolvedTo([12, 34, 56]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should ignore files with non-numeric (or zero) names', async () => {
|
it('should ignore files with non-numeric (or zero) names', done => {
|
||||||
|
promise.then(result => {
|
||||||
|
expect(result).toEqual([12, 34, 56]);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
readdirCb(null, ['12', 'foo', '34', 'bar', '56', '000']);
|
readdirCb(null, ['12', 'foo', '34', 'bar', '56', '000']);
|
||||||
await expectAsync(promise).toBeResolvedTo([12, 34, 56]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -220,7 +259,7 @@ describe('BuildCleaner', () => {
|
|||||||
|
|
||||||
|
|
||||||
it('should return a promise', () => {
|
it('should return a promise', () => {
|
||||||
expect(promise).toBeInstanceOf(Promise);
|
expect(promise).toEqual(jasmine.any(Promise));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -229,15 +268,31 @@ describe('BuildCleaner', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should reject if an error occurs while fetching PRs', async () => {
|
it('should reject if an error occurs while fetching PRs', done => {
|
||||||
|
promise.catch(err => {
|
||||||
|
expect(err).toBe('Test');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
prDeferred.reject('Test');
|
prDeferred.reject('Test');
|
||||||
await expectAsync(promise).toBeRejectedWith('Test');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should resolve with the numbers of the fetched PRs', async () => {
|
it('should resolve with the numbers of the fetched PRs', done => {
|
||||||
|
promise.then(prNumbers => {
|
||||||
|
expect(prNumbers).toEqual([1, 2, 3]);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
prDeferred.resolve([{id: 0, number: 1}, {id: 1, number: 2}, {id: 2, number: 3}]);
|
prDeferred.resolve([{id: 0, number: 1}, {id: 1, number: 2}, {id: 2, number: 3}]);
|
||||||
await expectAsync(promise).toBeResolvedTo([1, 2, 3]);
|
});
|
||||||
|
|
||||||
|
|
||||||
|
it('should log the number of open PRs', () => {
|
||||||
|
promise.then(prNumbers => {
|
||||||
|
expect(loggerLogSpy).toHaveBeenCalledWith(
|
||||||
|
ANY_DATE, 'BuildCleaner: ', `Open pull requests: ${prNumbers}`);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -249,15 +304,13 @@ describe('BuildCleaner', () => {
|
|||||||
let promise: Promise<string[]>;
|
let promise: Promise<string[]>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fsReaddirSpy = spyOn(fs, 'readdir').and.callFake(
|
fsReaddirSpy = spyOn(fs, 'readdir').and.callFake((_: string, cb: typeof readdirCb) => readdirCb = cb);
|
||||||
((_: string, cb: typeof readdirCb) => readdirCb = cb) as unknown as typeof fs.readdir,
|
|
||||||
);
|
|
||||||
promise = cleaner.getExistingDownloads();
|
promise = cleaner.getExistingDownloads();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should return a promise', () => {
|
it('should return a promise', () => {
|
||||||
expect(promise).toBeInstanceOf(Promise);
|
expect(promise).toEqual(jasmine.any(Promise));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -267,21 +320,33 @@ describe('BuildCleaner', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should reject if an error occurs while getting the files', async () => {
|
it('should reject if an error occurs while getting the files', done => {
|
||||||
|
promise.catch(err => {
|
||||||
|
expect(err).toBe('Test');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
readdirCb('Test');
|
readdirCb('Test');
|
||||||
await expectAsync(promise).toBeRejectedWith('Test');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should resolve with the returned file names', async () => {
|
it('should resolve with the returned file names', done => {
|
||||||
|
promise.then(result => {
|
||||||
|
expect(result).toEqual(EXISTING_DOWNLOADS);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
readdirCb(null, EXISTING_DOWNLOADS);
|
readdirCb(null, EXISTING_DOWNLOADS);
|
||||||
await expectAsync(promise).toBeResolvedTo(EXISTING_DOWNLOADS);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should ignore files that do not match the artifactPath', async () => {
|
it('should ignore files that do not match the artifactPath', done => {
|
||||||
|
promise.then(result => {
|
||||||
|
expect(result).toEqual(['10-ABCDEF-build.zip', '30-FFFFFFF-build.zip']);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
readdirCb(null, ['10-ABCDEF-build.zip', '20-AAAAAAA-otherfile.zip', '30-FFFFFFF-build.zip']);
|
readdirCb(null, ['10-ABCDEF-build.zip', '20-AAAAAAA-otherfile.zip', '30-FFFFFFF-build.zip']);
|
||||||
await expectAsync(promise).toBeResolvedTo(['10-ABCDEF-build.zip', '30-FFFFFFF-build.zip']);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -299,7 +364,7 @@ describe('BuildCleaner', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should test if the directory exists (and return if it does not)', () => {
|
it('should test if the directory exists (and return if is does not)', () => {
|
||||||
shellTestSpy.and.returnValue(false);
|
shellTestSpy.and.returnValue(false);
|
||||||
cleaner.removeDir('/foo/bar');
|
cleaner.removeDir('/foo/bar');
|
||||||
|
|
||||||
@ -316,19 +381,22 @@ describe('BuildCleaner', () => {
|
|||||||
|
|
||||||
|
|
||||||
it('should make the directory and its content writable before removing', () => {
|
it('should make the directory and its content writable before removing', () => {
|
||||||
|
shellRmSpy.and.callFake(() => expect(shellChmodSpy).toHaveBeenCalledWith('-R', 'a+w', '/foo/bar'));
|
||||||
cleaner.removeDir('/foo/bar');
|
cleaner.removeDir('/foo/bar');
|
||||||
|
|
||||||
expect(shellChmodSpy).toHaveBeenCalledBefore(shellRmSpy);
|
|
||||||
expect(shellChmodSpy).toHaveBeenCalledWith('-R', 'a+w', '/foo/bar');
|
|
||||||
expect(shellRmSpy).toHaveBeenCalled();
|
expect(shellRmSpy).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should catch errors and log them', () => {
|
it('should catch errors and log them', () => {
|
||||||
shellRmSpy.and.throwError('Test');
|
shellRmSpy.and.callFake(() => {
|
||||||
|
// tslint:disable-next-line: no-string-throw
|
||||||
|
throw 'Test';
|
||||||
|
});
|
||||||
|
|
||||||
cleaner.removeDir('/foo/bar');
|
cleaner.removeDir('/foo/bar');
|
||||||
|
|
||||||
expect(loggerErrorSpy).toHaveBeenCalledWith('ERROR: Unable to remove \'/foo/bar\' due to:', new Error('Test'));
|
expect(loggerErrorSpy).toHaveBeenCalledWith('ERROR: Unable to remove \'/foo/bar\' due to:', 'Test');
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -381,7 +449,7 @@ describe('BuildCleaner', () => {
|
|||||||
expect(cleanerRemoveDirSpy).toHaveBeenCalledTimes(0);
|
expect(cleanerRemoveDirSpy).toHaveBeenCalledTimes(0);
|
||||||
cleanerRemoveDirSpy.calls.reset();
|
cleanerRemoveDirSpy.calls.reset();
|
||||||
|
|
||||||
cleaner.removeUnnecessaryBuilds([1, 2, 3, 4], []);
|
(cleaner as any).removeUnnecessaryBuilds([1, 2, 3, 4], []);
|
||||||
expect(cleanerRemoveDirSpy).toHaveBeenCalledTimes(8);
|
expect(cleanerRemoveDirSpy).toHaveBeenCalledTimes(8);
|
||||||
expect(cleanerRemoveDirSpy).toHaveBeenCalledWith(normalize('/foo/bar/1'));
|
expect(cleanerRemoveDirSpy).toHaveBeenCalledWith(normalize('/foo/bar/1'));
|
||||||
expect(cleanerRemoveDirSpy).toHaveBeenCalledWith(normalize('/foo/bar/2'));
|
expect(cleanerRemoveDirSpy).toHaveBeenCalledWith(normalize('/foo/bar/2'));
|
||||||
|
@ -45,15 +45,25 @@ describe('CircleCIApi', () => {
|
|||||||
const errorMessage = 'Invalid request';
|
const errorMessage = 'Invalid request';
|
||||||
const request = nock(BASE_URL).get(`/${buildNum}?circle-token=${TOKEN}`);
|
const request = nock(BASE_URL).get(`/${buildNum}?circle-token=${TOKEN}`);
|
||||||
|
|
||||||
request.replyWithError(errorMessage);
|
try {
|
||||||
await expectAsync(api.getBuildInfo(buildNum)).toBeRejectedWithError(
|
request.replyWithError(errorMessage);
|
||||||
|
await api.getBuildInfo(buildNum);
|
||||||
|
throw new Error('Exception Expected');
|
||||||
|
} catch (err) {
|
||||||
|
expect(err.message).toEqual(
|
||||||
`CircleCI build info request failed ` +
|
`CircleCI build info request failed ` +
|
||||||
`(request to ${BASE_URL}/${buildNum}?circle-token=${TOKEN} failed, reason: ${errorMessage})`);
|
`(request to ${BASE_URL}/${buildNum}?circle-token=${TOKEN} failed, reason: ${errorMessage})`);
|
||||||
|
}
|
||||||
|
|
||||||
request.reply(404, errorMessage);
|
try {
|
||||||
await expectAsync(api.getBuildInfo(buildNum)).toBeRejectedWithError(
|
request.reply(404, errorMessage);
|
||||||
|
await api.getBuildInfo(buildNum);
|
||||||
|
throw new Error('Exception Expected');
|
||||||
|
} catch (err) {
|
||||||
|
expect(err.message).toEqual(
|
||||||
`CircleCI build info request failed ` +
|
`CircleCI build info request failed ` +
|
||||||
`(request to ${BASE_URL}/${buildNum}?circle-token=${TOKEN} failed, reason: ${errorMessage})`);
|
`(request to ${BASE_URL}/${buildNum}?circle-token=${TOKEN} failed, reason: ${errorMessage})`);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -68,7 +78,8 @@ describe('CircleCIApi', () => {
|
|||||||
.get(`/${buildNum}/artifacts?circle-token=${TOKEN}`)
|
.get(`/${buildNum}/artifacts?circle-token=${TOKEN}`)
|
||||||
.reply(200, [artifact0, artifact1, artifact2]);
|
.reply(200, [artifact0, artifact1, artifact2]);
|
||||||
|
|
||||||
await expectAsync(api.getBuildArtifactUrl(buildNum, 'some/path/1')).toBeResolvedTo('https://url/1');
|
const artifactUrl = await api.getBuildArtifactUrl(buildNum, 'some/path/1');
|
||||||
|
expect(artifactUrl).toEqual('https://url/1');
|
||||||
request.done();
|
request.done();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -79,15 +90,25 @@ describe('CircleCIApi', () => {
|
|||||||
const errorMessage = 'Invalid request';
|
const errorMessage = 'Invalid request';
|
||||||
const request = nock(BASE_URL).get(`/${buildNum}/artifacts?circle-token=${TOKEN}`);
|
const request = nock(BASE_URL).get(`/${buildNum}/artifacts?circle-token=${TOKEN}`);
|
||||||
|
|
||||||
request.replyWithError(errorMessage);
|
try {
|
||||||
await expectAsync(api.getBuildArtifactUrl(buildNum, 'some/path/1')).toBeRejectedWithError(
|
request.replyWithError(errorMessage);
|
||||||
|
await api.getBuildArtifactUrl(buildNum, 'some/path/1');
|
||||||
|
throw new Error('Exception Expected');
|
||||||
|
} catch (err) {
|
||||||
|
expect(err.message).toEqual(
|
||||||
`CircleCI artifact URL request failed ` +
|
`CircleCI artifact URL request failed ` +
|
||||||
`(request to ${BASE_URL}/${buildNum}/artifacts?circle-token=${TOKEN} failed, reason: ${errorMessage})`);
|
`(request to ${BASE_URL}/${buildNum}/artifacts?circle-token=${TOKEN} failed, reason: ${errorMessage})`);
|
||||||
|
}
|
||||||
|
|
||||||
request.reply(404, errorMessage);
|
try {
|
||||||
await expectAsync(api.getBuildArtifactUrl(buildNum, 'some/path/1')).toBeRejectedWithError(
|
request.reply(404, errorMessage);
|
||||||
|
await api.getBuildArtifactUrl(buildNum, 'some/path/1');
|
||||||
|
throw new Error('Exception Expected');
|
||||||
|
} catch (err) {
|
||||||
|
expect(err.message).toEqual(
|
||||||
`CircleCI artifact URL request failed ` +
|
`CircleCI artifact URL request failed ` +
|
||||||
`(request to ${BASE_URL}/${buildNum}/artifacts?circle-token=${TOKEN} failed, reason: ${errorMessage})`);
|
`(request to ${BASE_URL}/${buildNum}/artifacts?circle-token=${TOKEN} failed, reason: ${errorMessage})`);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw an error if the response does not contain the specified artifact', async () => {
|
it('should throw an error if the response does not contain the specified artifact', async () => {
|
||||||
@ -100,9 +121,14 @@ describe('CircleCIApi', () => {
|
|||||||
.get(`/${buildNum}/artifacts?circle-token=${TOKEN}`)
|
.get(`/${buildNum}/artifacts?circle-token=${TOKEN}`)
|
||||||
.reply(200, [artifact0, artifact1, artifact2]);
|
.reply(200, [artifact0, artifact1, artifact2]);
|
||||||
|
|
||||||
await expectAsync(api.getBuildArtifactUrl(buildNum, 'some/path/3')).toBeRejectedWithError(
|
try {
|
||||||
|
await api.getBuildArtifactUrl(buildNum, 'some/path/3');
|
||||||
|
throw new Error('Exception Expected');
|
||||||
|
} catch (err) {
|
||||||
|
expect(err.message).toEqual(
|
||||||
`CircleCI artifact URL request failed ` +
|
`CircleCI artifact URL request failed ` +
|
||||||
`(Missing artifact (some/path/3) for CircleCI build: ${buildNum})`);
|
`(Missing artifact (some/path/3) for CircleCI build: ${buildNum})`);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -118,7 +118,7 @@ describe('GithubApi', () => {
|
|||||||
|
|
||||||
|
|
||||||
it('should return a promise', () => {
|
it('should return a promise', () => {
|
||||||
expect((api as any).getPaginated()).toBeInstanceOf(Promise);
|
expect((api as any).getPaginated()).toEqual(jasmine.any(Promise));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -131,30 +131,45 @@ describe('GithubApi', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should reject if the request fails', async () => {
|
it('should reject if the request fails', done => {
|
||||||
const responsePromise = (api as any).getPaginated('/foo/bar');
|
(api as any).getPaginated('/foo/bar').catch((err: any) => {
|
||||||
|
expect(err).toBe('Test');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
deferreds[0].reject('Test');
|
deferreds[0].reject('Test');
|
||||||
|
|
||||||
await expectAsync(responsePromise).toBeRejectedWith('Test');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should resolve with the returned items', async () => {
|
it('should resolve with the returned items', done => {
|
||||||
const items = [{id: 1}, {id: 2}];
|
const items = [{id: 1}, {id: 2}];
|
||||||
const responsePromise = (api as any).getPaginated('/foo/bar');
|
|
||||||
deferreds[0].resolve(items);
|
|
||||||
|
|
||||||
await expectAsync(responsePromise).toBeResolvedTo(items);
|
(api as any).getPaginated('/foo/bar').then((data: any) => {
|
||||||
|
expect(data).toEqual(items);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
deferreds[0].resolve(items);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should iteratively call \'get()\' to fetch all items', async () => {
|
it('should iteratively call \'get()\' to fetch all items', done => {
|
||||||
// Create an array or 250 objects.
|
// Create an array or 250 objects.
|
||||||
const allItems = new Array(250).fill(null).map((_, i) => ({id: i}));
|
const allItems = '.'.repeat(250).split('').map((_, i) => ({id: i}));
|
||||||
const apiGetSpy = api.get as jasmine.Spy;
|
const apiGetSpy = api.get as jasmine.Spy;
|
||||||
const paramsForPage = (page: number) => ({baz: 'qux', page, per_page: 100});
|
|
||||||
|
|
||||||
const responsePromise = (api as any).getPaginated('/foo/bar', {baz: 'qux'});
|
(api as any).getPaginated('/foo/bar', {baz: 'qux'}).then((data: any) => {
|
||||||
|
const paramsForPage = (page: number) => ({baz: 'qux', page, per_page: 100});
|
||||||
|
|
||||||
|
expect(apiGetSpy).toHaveBeenCalledTimes(3);
|
||||||
|
expect(apiGetSpy.calls.argsFor(0)).toEqual(['/foo/bar', paramsForPage(1)]);
|
||||||
|
expect(apiGetSpy.calls.argsFor(1)).toEqual(['/foo/bar', paramsForPage(2)]);
|
||||||
|
expect(apiGetSpy.calls.argsFor(2)).toEqual(['/foo/bar', paramsForPage(3)]);
|
||||||
|
|
||||||
|
expect(data).toEqual(allItems);
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
deferreds[0].resolve(allItems.slice(0, 100));
|
deferreds[0].resolve(allItems.slice(0, 100));
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@ -163,13 +178,6 @@ describe('GithubApi', () => {
|
|||||||
deferreds[2].resolve(allItems.slice(200));
|
deferreds[2].resolve(allItems.slice(200));
|
||||||
}, 0);
|
}, 0);
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
await expectAsync(responsePromise).toBeResolvedTo(allItems);
|
|
||||||
|
|
||||||
expect(apiGetSpy).toHaveBeenCalledTimes(3);
|
|
||||||
expect(apiGetSpy.calls.argsFor(0)).toEqual(['/foo/bar', paramsForPage(1)]);
|
|
||||||
expect(apiGetSpy.calls.argsFor(1)).toEqual(['/foo/bar', paramsForPage(2)]);
|
|
||||||
expect(apiGetSpy.calls.argsFor(2)).toEqual(['/foo/bar', paramsForPage(3)]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -209,8 +217,8 @@ describe('GithubApi', () => {
|
|||||||
|
|
||||||
describe('request()', () => {
|
describe('request()', () => {
|
||||||
it('should return a promise', () => {
|
it('should return a promise', () => {
|
||||||
nock('https://api.github.com').get('/').reply(200);
|
nock('https://api.github.com').get('').reply(200);
|
||||||
expect((api as any).request()).toBeInstanceOf(Promise);
|
expect((api as any).request()).toEqual(jasmine.any(Promise));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -239,8 +247,9 @@ describe('GithubApi', () => {
|
|||||||
nock('https://api.github.com')
|
nock('https://api.github.com')
|
||||||
.intercept('/path', 'method')
|
.intercept('/path', 'method')
|
||||||
.replyWithError('Test');
|
.replyWithError('Test');
|
||||||
|
let message = 'Failed to reject error';
|
||||||
await expectAsync((api as any).request('method', '/path')).toBeRejectedWithError('Test');
|
await (api as any).request('method', '/path').catch((err: any) => message = err.message);
|
||||||
|
expect(message).toEqual('Test');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -254,69 +263,81 @@ describe('GithubApi', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should reject if response statusCode is <200', async () => {
|
it('should reject if response statusCode is <200', done => {
|
||||||
const requestHandler = nock('https://api.github.com')
|
const requestHandler = nock('https://api.github.com')
|
||||||
.intercept('/path', 'method')
|
.intercept('/path', 'method')
|
||||||
.reply(199);
|
.reply(199);
|
||||||
const responsePromise = (api as any).request('method', '/path');
|
|
||||||
|
|
||||||
await expectAsync(responsePromise).toBeRejectedWith(jasmine.stringMatching('failed'));
|
|
||||||
await expectAsync(responsePromise).toBeRejectedWith(jasmine.stringMatching('status: 199'));
|
|
||||||
|
|
||||||
|
(api as any).request('method', '/path')
|
||||||
|
.catch((err: string) => {
|
||||||
|
expect(err).toContain('failed');
|
||||||
|
expect(err).toContain('status: 199');
|
||||||
|
done();
|
||||||
|
});
|
||||||
requestHandler.done();
|
requestHandler.done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should reject if response statusCode is >=400', async () => {
|
it('should reject if response statusCode is >=400', done => {
|
||||||
const requestHandler = nock('https://api.github.com')
|
const requestHandler = nock('https://api.github.com')
|
||||||
.intercept('/path', 'method')
|
.intercept('/path', 'method')
|
||||||
.reply(400);
|
.reply(400);
|
||||||
const responsePromise = (api as any).request('method', '/path');
|
|
||||||
|
|
||||||
await expectAsync(responsePromise).toBeRejectedWith(jasmine.stringMatching('failed'));
|
|
||||||
await expectAsync(responsePromise).toBeRejectedWith(jasmine.stringMatching('status: 400'));
|
|
||||||
|
|
||||||
|
(api as any).request('method', '/path')
|
||||||
|
.catch((err: string) => {
|
||||||
|
expect(err).toContain('failed');
|
||||||
|
expect(err).toContain('status: 400');
|
||||||
|
done();
|
||||||
|
});
|
||||||
requestHandler.done();
|
requestHandler.done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should include the response text in the rejection message', async () => {
|
it('should include the response text in the rejection message', done => {
|
||||||
const requestHandler = nock('https://api.github.com')
|
const requestHandler = nock('https://api.github.com')
|
||||||
.intercept('/path', 'method')
|
.intercept('/path', 'method')
|
||||||
.reply(500, 'Test');
|
.reply(500, 'Test');
|
||||||
const responsePromise = (api as any).request('method', '/path');
|
|
||||||
|
|
||||||
await expectAsync(responsePromise).toBeRejectedWith(jasmine.stringMatching('Test'));
|
|
||||||
|
|
||||||
|
(api as any).request('method', '/path')
|
||||||
|
.catch((err: string) => {
|
||||||
|
expect(err).toContain('Test');
|
||||||
|
done();
|
||||||
|
});
|
||||||
requestHandler.done();
|
requestHandler.done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should resolve if returned statusCode is >=200 and <400', async () => {
|
it('should resolve if returned statusCode is >=200 and <400', done => {
|
||||||
const requestHandler = nock('https://api.github.com')
|
const requestHandler = nock('https://api.github.com')
|
||||||
.intercept('/path', 'method')
|
.intercept('/path', 'method')
|
||||||
.reply(200);
|
.reply(200);
|
||||||
|
|
||||||
await expectAsync((api as any).request('method', '/path')).toBeResolved();
|
(api as any).request('method', '/path').then(done);
|
||||||
requestHandler.done();
|
requestHandler.done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should parse the response body into an object using \'JSON.parse\'', async () => {
|
it('should parse the response body into an object using \'JSON.parse\'', done => {
|
||||||
const requestHandler = nock('https://api.github.com')
|
const requestHandler = nock('https://api.github.com')
|
||||||
.intercept('/path', 'method')
|
.intercept('/path', 'method')
|
||||||
.reply(300, '{"foo": "bar"}');
|
.reply(300, '{"foo": "bar"}');
|
||||||
|
|
||||||
await expectAsync((api as any).request('method', '/path')).toBeResolvedTo({foo: 'bar'});
|
(api as any).request('method', '/path').then((data: any) => {
|
||||||
|
expect(data).toEqual({foo: 'bar'});
|
||||||
|
done();
|
||||||
|
});
|
||||||
requestHandler.done();
|
requestHandler.done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should reject if the response text is malformed JSON', async () => {
|
it('should reject if the response text is malformed JSON', done => {
|
||||||
const requestHandler = nock('https://api.github.com')
|
const requestHandler = nock('https://api.github.com')
|
||||||
.intercept('/path', 'method')
|
.intercept('/path', 'method')
|
||||||
.reply(300, '}');
|
.reply(300, '}');
|
||||||
|
|
||||||
await expectAsync((api as any).request('method', '/path')).toBeRejectedWithError(SyntaxError);
|
(api as any).request('method', '/path').catch((err: any) => {
|
||||||
|
expect(err).toEqual(jasmine.any(SyntaxError));
|
||||||
|
done();
|
||||||
|
});
|
||||||
requestHandler.done();
|
requestHandler.done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Imports
|
// Imports
|
||||||
import {GithubApi} from '../../lib/common/github-api';
|
import {GithubApi} from '../../lib/common/github-api';
|
||||||
import {GithubPullRequests, PullRequest} from '../../lib/common/github-pull-requests';
|
import {GithubPullRequests} from '../../lib/common/github-pull-requests';
|
||||||
|
|
||||||
// Tests
|
// Tests
|
||||||
describe('GithubPullRequests', () => {
|
describe('GithubPullRequests', () => {
|
||||||
@ -47,21 +47,27 @@ describe('GithubPullRequests', () => {
|
|||||||
|
|
||||||
|
|
||||||
it('should make a POST request to Github with the correct pathname, params and data', () => {
|
it('should make a POST request to Github with the correct pathname, params and data', () => {
|
||||||
githubApi.post.and.resolveTo();
|
githubApi.post.and.callFake(() => Promise.resolve());
|
||||||
prs.addComment(42, 'body');
|
prs.addComment(42, 'body');
|
||||||
expect(githubApi.post).toHaveBeenCalledWith('/repos/foo/bar/issues/42/comments', null, {body: 'body'});
|
expect(githubApi.post).toHaveBeenCalledWith('/repos/foo/bar/issues/42/comments', null, {body: 'body'});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should reject if the request fails', async () => {
|
it('should reject if the request fails', done => {
|
||||||
githubApi.post.and.rejectWith('Test');
|
githubApi.post.and.callFake(() => Promise.reject('Test'));
|
||||||
await expectAsync(prs.addComment(42, 'body')).toBeRejectedWith('Test');
|
prs.addComment(42, 'body').catch(err => {
|
||||||
|
expect(err).toBe('Test');
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should resolve with the data from the Github POST', async () => {
|
it('should resolve with the data from the Github POST', done => {
|
||||||
githubApi.post.and.resolveTo('Test');
|
githubApi.post.and.callFake(() => Promise.resolve('Test'));
|
||||||
await expectAsync(prs.addComment(42, 'body')).toBeResolvedTo('Test');
|
prs.addComment(42, 'body').then(data => {
|
||||||
|
expect(data).toBe('Test');
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -81,11 +87,13 @@ describe('GithubPullRequests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should resolve with the data returned from GitHub', async () => {
|
it('should resolve with the data returned from GitHub', done => {
|
||||||
const expected: any = {number: 42};
|
const expected: any = {number: 42};
|
||||||
githubApi.get.and.resolveTo(expected);
|
githubApi.get.and.callFake(() => Promise.resolve(expected));
|
||||||
|
prs.fetch(42).then(data => {
|
||||||
await expectAsync(prs.fetch(42)).toBeResolvedTo(expected);
|
expect(data).toEqual(expected);
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -117,14 +125,9 @@ describe('GithubPullRequests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should forward the value returned by \'getPaginated()\'', async () => {
|
it('should forward the value returned by \'getPaginated()\'', () => {
|
||||||
const mockPrs: PullRequest[] = [
|
githubApi.getPaginated.and.returnValue('Test');
|
||||||
{number: 1, user: {login: 'foo'}, labels: []},
|
expect(prs.fetchAll() as any).toBe('Test');
|
||||||
{number: 2, user: {login: 'bar'}, labels: []},
|
|
||||||
];
|
|
||||||
|
|
||||||
githubApi.getPaginated.and.resolveTo(mockPrs);
|
|
||||||
expect(await prs.fetchAll()).toBe(mockPrs);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -144,11 +147,13 @@ describe('GithubPullRequests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should resolve with the data returned from GitHub', async () => {
|
it('should resolve with the data returned from GitHub', done => {
|
||||||
const expected: any = [{sha: 'ABCDE', filename: 'a/b/c'}, {sha: '12345', filename: 'x/y/z'}];
|
const expected: any = [{sha: 'ABCDE', filename: 'a/b/c'}, {sha: '12345', filename: 'x/y/z'}];
|
||||||
githubApi.getPaginated.and.resolveTo(expected);
|
githubApi.getPaginated.and.callFake(() => Promise.resolve(expected));
|
||||||
|
prs.fetchFiles(42).then(data => {
|
||||||
await expectAsync(prs.fetchFiles(42)).toBeResolvedTo(expected);
|
expect(data).toEqual(expected);
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import {GithubApi} from '../../lib/common/github-api';
|
import {GithubApi} from '../../lib/common/github-api';
|
||||||
import {GithubTeams, Team} from '../../lib/common/github-teams';
|
import {GithubTeams} from '../../lib/common/github-teams';
|
||||||
|
|
||||||
// Tests
|
// Tests
|
||||||
describe('GithubTeams', () => {
|
describe('GithubTeams', () => {
|
||||||
@ -16,7 +16,6 @@ describe('GithubTeams', () => {
|
|||||||
expect(() => new GithubTeams(githubApi, '')).
|
expect(() => new GithubTeams(githubApi, '')).
|
||||||
toThrowError('Missing or empty required parameter \'githubOrg\'!');
|
toThrowError('Missing or empty required parameter \'githubOrg\'!');
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -34,14 +33,9 @@ describe('GithubTeams', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should forward the value returned by \'getPaginated()\'', async () => {
|
it('should forward the value returned by \'getPaginated()\'', () => {
|
||||||
const mockTeams: Team[] = [
|
githubApi.getPaginated.and.returnValue('Test');
|
||||||
{id: 1, slug: 'foo'},
|
expect(teams.fetchAll() as any).toBe('Test');
|
||||||
{id: 2, slug: 'bar'},
|
|
||||||
];
|
|
||||||
|
|
||||||
githubApi.getPaginated.and.resolveTo(mockTeams);
|
|
||||||
expect(await teams.fetchAll()).toBe(mockTeams);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -56,77 +50,100 @@ describe('GithubTeams', () => {
|
|||||||
|
|
||||||
|
|
||||||
it('should return a promise', () => {
|
it('should return a promise', () => {
|
||||||
githubApi.get.and.resolveTo();
|
githubApi.get.and.callFake(() => Promise.resolve());
|
||||||
const promise = teams.isMemberById('user', [1]);
|
const promise = teams.isMemberById('user', [1]);
|
||||||
expect(promise).toBeInstanceOf(Promise);
|
expect(promise).toEqual(jasmine.any(Promise));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should resolve with false if called with an empty array', async () => {
|
it('should resolve with false if called with an empty array', done => {
|
||||||
await expectAsync(teams.isMemberById('user', [])).toBeResolvedTo(false);
|
teams.isMemberById('user', []).then(isMember => {
|
||||||
expect(githubApi.get).not.toHaveBeenCalled();
|
expect(isMember).toBe(false);
|
||||||
|
expect(githubApi.get).not.toHaveBeenCalled();
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should call \'get()\' with the correct pathname', async () => {
|
it('should call \'get()\' with the correct pathname', done => {
|
||||||
githubApi.get.and.resolveTo();
|
githubApi.get.and.callFake(() => Promise.resolve());
|
||||||
await teams.isMemberById('user', [1]);
|
teams.isMemberById('user', [1]).then(() => {
|
||||||
|
expect(githubApi.get).toHaveBeenCalledWith('/teams/1/memberships/user');
|
||||||
expect(githubApi.get).toHaveBeenCalledWith('/teams/1/memberships/user');
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should resolve with false if \'get()\' rejects', async () => {
|
it('should resolve with false if \'get()\' rejects', done => {
|
||||||
githubApi.get.and.rejectWith(null);
|
githubApi.get.and.callFake(() => Promise.reject(null));
|
||||||
|
teams.isMemberById('user', [1]).then(isMember => {
|
||||||
await expectAsync(teams.isMemberById('user', [1])).toBeResolvedTo(false);
|
expect(isMember).toBe(false);
|
||||||
expect(githubApi.get).toHaveBeenCalled();
|
expect(githubApi.get).toHaveBeenCalled();
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should resolve with false if the membership is not active', async () => {
|
it('should resolve with false if the membership is not active', done => {
|
||||||
githubApi.get.and.resolveTo({state: 'pending'});
|
githubApi.get.and.callFake(() => Promise.resolve({state: 'pending'}));
|
||||||
|
teams.isMemberById('user', [1]).then(isMember => {
|
||||||
await expectAsync(teams.isMemberById('user', [1])).toBeResolvedTo(false);
|
expect(isMember).toBe(false);
|
||||||
expect(githubApi.get).toHaveBeenCalled();
|
expect(githubApi.get).toHaveBeenCalled();
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should resolve with true if the membership is active', async () => {
|
it('should resolve with true if the membership is active', done => {
|
||||||
githubApi.get.and.resolveTo({state: 'active'});
|
githubApi.get.and.callFake(() => Promise.resolve({state: 'active'}));
|
||||||
await expectAsync(teams.isMemberById('user', [1])).toBeResolvedTo(true);
|
teams.isMemberById('user', [1]).then(isMember => {
|
||||||
|
expect(isMember).toBe(true);
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should sequentially call \'get()\' until an active membership is found', async () => {
|
it('should sequentially call \'get()\' until an active membership is found', done => {
|
||||||
githubApi.get.
|
const trainedResponses: {[pathname: string]: Promise<{state: string}>} = {
|
||||||
withArgs('/teams/1/memberships/user').and.resolveTo({state: 'pending'}).
|
'/teams/1/memberships/user': Promise.resolve({state: 'pending'}),
|
||||||
withArgs('/teams/2/memberships/user').and.rejectWith(null).
|
'/teams/2/memberships/user': Promise.reject(null),
|
||||||
withArgs('/teams/3/memberships/user').and.resolveTo({state: 'active'});
|
'/teams/3/memberships/user': Promise.resolve({state: 'active'}),
|
||||||
|
};
|
||||||
|
githubApi.get.and.callFake((pathname: string) => trainedResponses[pathname]);
|
||||||
|
|
||||||
await expectAsync(teams.isMemberById('user', [1, 2, 3, 4])).toBeResolvedTo(true);
|
teams.isMemberById('user', [1, 2, 3, 4]).then(isMember => {
|
||||||
|
expect(isMember).toBe(true);
|
||||||
|
|
||||||
expect(githubApi.get).toHaveBeenCalledTimes(3);
|
expect(githubApi.get).toHaveBeenCalledTimes(3);
|
||||||
expect(githubApi.get.calls.argsFor(0)[0]).toBe('/teams/1/memberships/user');
|
expect(githubApi.get.calls.argsFor(0)[0]).toBe('/teams/1/memberships/user');
|
||||||
expect(githubApi.get.calls.argsFor(1)[0]).toBe('/teams/2/memberships/user');
|
expect(githubApi.get.calls.argsFor(1)[0]).toBe('/teams/2/memberships/user');
|
||||||
expect(githubApi.get.calls.argsFor(2)[0]).toBe('/teams/3/memberships/user');
|
expect(githubApi.get.calls.argsFor(2)[0]).toBe('/teams/3/memberships/user');
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should resolve with false if no active membership is found', async () => {
|
it('should resolve with false if no active membership is found', done => {
|
||||||
githubApi.get.
|
const trainedResponses: {[pathname: string]: Promise<{state: string}>} = {
|
||||||
withArgs('/teams/1/memberships/user').and.resolveTo({state: 'pending'}).
|
'/teams/1/memberships/user': Promise.resolve({state: 'pending'}),
|
||||||
withArgs('/teams/2/memberships/user').and.rejectWith(null).
|
'/teams/2/memberships/user': Promise.reject(null),
|
||||||
withArgs('/teams/3/memberships/user').and.resolveTo({state: 'not active'}).
|
'/teams/3/memberships/user': Promise.resolve({state: 'not active'}),
|
||||||
withArgs('/teams/4/memberships/user').and.rejectWith(null);
|
'/teams/4/memberships/user': Promise.reject(null),
|
||||||
|
};
|
||||||
|
githubApi.get.and.callFake((pathname: string) => trainedResponses[pathname]);
|
||||||
|
|
||||||
await expectAsync(teams.isMemberById('user', [1, 2, 3, 4])).toBeResolvedTo(false);
|
teams.isMemberById('user', [1, 2, 3, 4]).then(isMember => {
|
||||||
|
expect(isMember).toBe(false);
|
||||||
|
|
||||||
expect(githubApi.get).toHaveBeenCalledTimes(4);
|
expect(githubApi.get).toHaveBeenCalledTimes(4);
|
||||||
expect(githubApi.get.calls.argsFor(0)[0]).toBe('/teams/1/memberships/user');
|
expect(githubApi.get.calls.argsFor(0)[0]).toBe('/teams/1/memberships/user');
|
||||||
expect(githubApi.get.calls.argsFor(1)[0]).toBe('/teams/2/memberships/user');
|
expect(githubApi.get.calls.argsFor(1)[0]).toBe('/teams/2/memberships/user');
|
||||||
expect(githubApi.get.calls.argsFor(2)[0]).toBe('/teams/3/memberships/user');
|
expect(githubApi.get.calls.argsFor(2)[0]).toBe('/teams/3/memberships/user');
|
||||||
expect(githubApi.get.calls.argsFor(3)[0]).toBe('/teams/4/memberships/user');
|
expect(githubApi.get.calls.argsFor(3)[0]).toBe('/teams/4/memberships/user');
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -140,13 +157,14 @@ describe('GithubTeams', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
teams = new GithubTeams(githubApi, 'foo');
|
teams = new GithubTeams(githubApi, 'foo');
|
||||||
|
|
||||||
teamsFetchAllSpy = spyOn(teams, 'fetchAll').and.resolveTo([{id: 1, slug: 'team1'}, {id: 2, slug: 'team2'}]);
|
const mockResponse = Promise.resolve([{id: 1, slug: 'team1'}, {id: 2, slug: 'team2'}]);
|
||||||
|
teamsFetchAllSpy = spyOn(teams, 'fetchAll').and.returnValue(mockResponse);
|
||||||
teamsIsMemberByIdSpy = spyOn(teams, 'isMemberById');
|
teamsIsMemberByIdSpy = spyOn(teams, 'isMemberById');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should return a promise', () => {
|
it('should return a promise', () => {
|
||||||
expect(teams.isMemberBySlug('user', ['team-slug'])).toBeInstanceOf(Promise);
|
expect(teams.isMemberBySlug('user', ['team-slug'])).toEqual(jasmine.any(Promise));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -156,46 +174,55 @@ describe('GithubTeams', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should resolve with false if \'fetchAll()\' rejects', async () => {
|
it('should resolve with false if \'fetchAll()\' rejects', done => {
|
||||||
teamsFetchAllSpy.and.rejectWith(null);
|
teamsFetchAllSpy.and.callFake(() => Promise.reject(null));
|
||||||
await expectAsync(teams.isMemberBySlug('user', ['team-slug'])).toBeResolvedTo(false);
|
teams.isMemberBySlug('user', ['team-slug']).then(isMember => {
|
||||||
|
expect(isMember).toBe(false);
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should call \'isMemberById()\' with the correct params if no team is found', async () => {
|
it('should call \'isMemberById()\' with the correct params if no team is found', done => {
|
||||||
await teams.isMemberBySlug('user', ['no-match']);
|
teams.isMemberBySlug('user', ['no-match']).then(() => {
|
||||||
expect(teamsIsMemberByIdSpy).toHaveBeenCalledWith('user', []);
|
expect(teamsIsMemberByIdSpy).toHaveBeenCalledWith('user', []);
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should call \'isMemberById()\' with the correct params if teams are found', async () => {
|
it('should call \'isMemberById()\' with the correct params if teams are found', done => {
|
||||||
await teams.isMemberBySlug('userA', ['team1']);
|
const spy = teamsIsMemberByIdSpy;
|
||||||
expect(teamsIsMemberByIdSpy).toHaveBeenCalledWith('userA', [1]);
|
|
||||||
|
|
||||||
await teams.isMemberBySlug('userB', ['team2']);
|
Promise.all([
|
||||||
expect(teamsIsMemberByIdSpy).toHaveBeenCalledWith('userB', [2]);
|
teams.isMemberBySlug('user', ['team1']).then(() => expect(spy).toHaveBeenCalledWith('user', [1])),
|
||||||
|
teams.isMemberBySlug('user', ['team2']).then(() => expect(spy).toHaveBeenCalledWith('user', [2])),
|
||||||
await teams.isMemberBySlug('userC', ['team1', 'team2']);
|
teams.isMemberBySlug('user', ['team1', 'team2']).then(() => expect(spy).toHaveBeenCalledWith('user', [1, 2])),
|
||||||
expect(teamsIsMemberByIdSpy).toHaveBeenCalledWith('userC', [1, 2]);
|
]).then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should resolve with false if \'isMemberById()\' rejects', async () => {
|
it('should resolve with false if \'isMemberById()\' rejects', done => {
|
||||||
teamsIsMemberByIdSpy.and.rejectWith(null);
|
teamsIsMemberByIdSpy.and.callFake(() => Promise.reject(null));
|
||||||
|
teams.isMemberBySlug('user', ['team1']).then(isMember => {
|
||||||
await expectAsync(teams.isMemberBySlug('user', ['team1'])).toBeResolvedTo(false);
|
expect(isMember).toBe(false);
|
||||||
expect(teamsIsMemberByIdSpy).toHaveBeenCalled();
|
expect(teamsIsMemberByIdSpy).toHaveBeenCalled();
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should resolve with the value \'isMemberById()\' resolves with', async () => {
|
it('should resolve with the value \'isMemberById()\' resolves with', async () => {
|
||||||
teamsIsMemberByIdSpy.and.resolveTo(true);
|
|
||||||
await expectAsync(teams.isMemberBySlug('userA', ['team1'])).toBeResolvedTo(true);
|
|
||||||
expect(teamsIsMemberByIdSpy).toHaveBeenCalledWith('userA', [1]);
|
|
||||||
|
|
||||||
teamsIsMemberByIdSpy.and.resolveTo(false);
|
teamsIsMemberByIdSpy.and.callFake(() => Promise.resolve(true));
|
||||||
await expectAsync(teams.isMemberBySlug('userB', ['team1'])).toBeResolvedTo(false);
|
const isMember1 = await teams.isMemberBySlug('user', ['team1']);
|
||||||
expect(teamsIsMemberByIdSpy).toHaveBeenCalledWith('userB', [1]);
|
expect(isMember1).toBe(true);
|
||||||
|
expect(teamsIsMemberByIdSpy).toHaveBeenCalledWith('user', [1]);
|
||||||
|
|
||||||
|
teamsIsMemberByIdSpy.and.callFake(() => Promise.resolve(false));
|
||||||
|
const isMember2 = await teams.isMemberBySlug('user', ['team1']);
|
||||||
|
expect(isMember2).toBe(false);
|
||||||
|
expect(teamsIsMemberByIdSpy).toHaveBeenCalledWith('user', [1]);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -9,8 +9,7 @@ import {Logger} from '../../lib/common/utils';
|
|||||||
import {BuildCreator} from '../../lib/preview-server/build-creator';
|
import {BuildCreator} from '../../lib/preview-server/build-creator';
|
||||||
import {ChangedPrVisibilityEvent, CreatedBuildEvent} from '../../lib/preview-server/build-events';
|
import {ChangedPrVisibilityEvent, CreatedBuildEvent} from '../../lib/preview-server/build-events';
|
||||||
import {PreviewServerError} from '../../lib/preview-server/preview-error';
|
import {PreviewServerError} from '../../lib/preview-server/preview-error';
|
||||||
import {customAsyncMatchers} from './jasmine-custom-async-matchers';
|
import {expectToBePreviewServerError} from './helpers';
|
||||||
|
|
||||||
|
|
||||||
// Tests
|
// Tests
|
||||||
describe('BuildCreator', () => {
|
describe('BuildCreator', () => {
|
||||||
@ -25,7 +24,6 @@ describe('BuildCreator', () => {
|
|||||||
const publicShaDir = path.join(publicPrDir, shortSha);
|
const publicShaDir = path.join(publicPrDir, shortSha);
|
||||||
let bc: BuildCreator;
|
let bc: BuildCreator;
|
||||||
|
|
||||||
beforeEach(() => jasmine.addAsyncMatchers(customAsyncMatchers));
|
|
||||||
beforeEach(() => bc = new BuildCreator(buildsDir));
|
beforeEach(() => bc = new BuildCreator(buildsDir));
|
||||||
|
|
||||||
|
|
||||||
@ -37,8 +35,8 @@ describe('BuildCreator', () => {
|
|||||||
|
|
||||||
|
|
||||||
it('should extend EventEmitter', () => {
|
it('should extend EventEmitter', () => {
|
||||||
expect(bc).toBeInstanceOf(BuildCreator);
|
expect(bc).toEqual(jasmine.any(BuildCreator));
|
||||||
expect(bc).toBeInstanceOf(EventEmitter);
|
expect(bc).toEqual(jasmine.any(EventEmitter));
|
||||||
|
|
||||||
expect(Object.getPrototypeOf(bc)).toBe(BuildCreator.prototype);
|
expect(Object.getPrototypeOf(bc)).toBe(BuildCreator.prototype);
|
||||||
});
|
});
|
||||||
@ -69,43 +67,47 @@ describe('BuildCreator', () => {
|
|||||||
const shaDir = isPublic ? publicShaDir : hiddenShaDir;
|
const shaDir = isPublic ? publicShaDir : hiddenShaDir;
|
||||||
|
|
||||||
|
|
||||||
it('should return a promise', async () => {
|
it('should return a promise', done => {
|
||||||
const promise = bc.create(pr, sha, archive, isPublic);
|
const promise = bc.create(pr, sha, archive, isPublic);
|
||||||
expect(promise).toBeInstanceOf(Promise);
|
promise.then(done); // Do not complete the test (and release the spies) synchronously
|
||||||
|
// to avoid running the actual `extractArchive()`.
|
||||||
|
|
||||||
// Do not complete the test (and release the spies) synchronously to avoid running the actual
|
expect(promise).toEqual(jasmine.any(Promise));
|
||||||
// `extractArchive()`.
|
|
||||||
await promise;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should update the PR\'s visibility first if necessary', async () => {
|
it('should update the PR\'s visibility first if necessary', done => {
|
||||||
await bc.create(pr, sha, archive, isPublic);
|
bcUpdatePrVisibilitySpy.and.callFake(() => expect(shellMkdirSpy).not.toHaveBeenCalled());
|
||||||
|
|
||||||
expect(bcUpdatePrVisibilitySpy).toHaveBeenCalledBefore(shellMkdirSpy);
|
bc.create(pr, sha, archive, isPublic).
|
||||||
expect(bcUpdatePrVisibilitySpy).toHaveBeenCalledWith(pr, isPublic);
|
then(() => {
|
||||||
expect(shellMkdirSpy).toHaveBeenCalled();
|
expect(bcUpdatePrVisibilitySpy).toHaveBeenCalledWith(pr, isPublic);
|
||||||
|
expect(shellMkdirSpy).toHaveBeenCalled();
|
||||||
|
}).
|
||||||
|
then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should create the build directory (and any parent directories)', async () => {
|
it('should create the build directory (and any parent directories)', done => {
|
||||||
await bc.create(pr, sha, archive, isPublic);
|
bc.create(pr, sha, archive, isPublic).
|
||||||
expect(shellMkdirSpy).toHaveBeenCalledWith('-p', shaDir);
|
then(() => expect(shellMkdirSpy).toHaveBeenCalledWith('-p', shaDir)).
|
||||||
|
then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should extract the archive contents into the build directory', async () => {
|
it('should extract the archive contents into the build directory', done => {
|
||||||
await bc.create(pr, sha, archive, isPublic);
|
bc.create(pr, sha, archive, isPublic).
|
||||||
expect(bcExtractArchiveSpy).toHaveBeenCalledWith(archive, shaDir);
|
then(() => expect(bcExtractArchiveSpy).toHaveBeenCalledWith(archive, shaDir)).
|
||||||
|
then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should emit a CreatedBuildEvent on success', async () => {
|
it('should emit a CreatedBuildEvent on success', done => {
|
||||||
let emitted = false;
|
let emitted = false;
|
||||||
|
|
||||||
bcEmitSpy.and.callFake((type: string, evt: CreatedBuildEvent) => {
|
bcEmitSpy.and.callFake((type: string, evt: CreatedBuildEvent) => {
|
||||||
expect(type).toBe(CreatedBuildEvent.type);
|
expect(type).toBe(CreatedBuildEvent.type);
|
||||||
expect(evt).toBeInstanceOf(CreatedBuildEvent);
|
expect(evt).toEqual(jasmine.any(CreatedBuildEvent));
|
||||||
expect(evt.pr).toBe(+pr);
|
expect(evt.pr).toBe(+pr);
|
||||||
expect(evt.sha).toBe(shortSha);
|
expect(evt.sha).toBe(shortSha);
|
||||||
expect(evt.isPublic).toBe(isPublic);
|
expect(evt.isPublic).toBe(isPublic);
|
||||||
@ -113,108 +115,130 @@ describe('BuildCreator', () => {
|
|||||||
emitted = true;
|
emitted = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
await bc.create(pr, sha, archive, isPublic);
|
bc.create(pr, sha, archive, isPublic).
|
||||||
expect(emitted).toBe(true);
|
then(() => expect(emitted).toBe(true)).
|
||||||
|
then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
describe('on error', () => {
|
describe('on error', () => {
|
||||||
|
let existsValues: {[dir: string]: boolean};
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
bcExistsSpy.and.returnValue(false);
|
existsValues = {
|
||||||
|
[prDir]: false,
|
||||||
|
[shaDir]: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
bcExistsSpy.and.callFake((dir: string) => existsValues[dir]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should abort and skip further operations if changing the PR\'s visibility fails', async () => {
|
it('should abort and skip further operations if changing the PR\'s visibility fails', done => {
|
||||||
const mockError = new PreviewServerError(543, 'Test');
|
const mockError = new PreviewServerError(543, 'Test');
|
||||||
bcUpdatePrVisibilitySpy.and.rejectWith(mockError);
|
bcUpdatePrVisibilitySpy.and.callFake(() => Promise.reject(mockError));
|
||||||
|
|
||||||
await expectAsync(bc.create(pr, sha, archive, isPublic)).toBeRejectedWith(mockError);
|
bc.create(pr, sha, archive, isPublic).catch(err => {
|
||||||
|
expect(err).toBe(mockError);
|
||||||
|
|
||||||
expect(bcExistsSpy).not.toHaveBeenCalled();
|
expect(bcExistsSpy).not.toHaveBeenCalled();
|
||||||
expect(shellMkdirSpy).not.toHaveBeenCalled();
|
expect(shellMkdirSpy).not.toHaveBeenCalled();
|
||||||
expect(bcExtractArchiveSpy).not.toHaveBeenCalled();
|
expect(bcExtractArchiveSpy).not.toHaveBeenCalled();
|
||||||
expect(bcEmitSpy).not.toHaveBeenCalled();
|
expect(bcEmitSpy).not.toHaveBeenCalled();
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should abort and skip further operations if the build does already exist', async () => {
|
it('should abort and skip further operations if the build does already exist', done => {
|
||||||
bcExistsSpy.withArgs(shaDir).and.returnValue(true);
|
existsValues[shaDir] = true;
|
||||||
|
bc.create(pr, sha, archive, isPublic).catch(err => {
|
||||||
await expectAsync(bc.create(pr, sha, archive, isPublic)).toBeRejectedWithPreviewServerError(
|
const publicOrNot = isPublic ? 'public' : 'non-public';
|
||||||
409, `Request to overwrite existing ${isPublic ? '' : 'non-'}public directory: ${shaDir}`);
|
expectToBePreviewServerError(err, 409, `Request to overwrite existing ${publicOrNot} directory: ${shaDir}`);
|
||||||
|
expect(shellMkdirSpy).not.toHaveBeenCalled();
|
||||||
expect(shellMkdirSpy).not.toHaveBeenCalled();
|
expect(bcExtractArchiveSpy).not.toHaveBeenCalled();
|
||||||
expect(bcExtractArchiveSpy).not.toHaveBeenCalled();
|
expect(bcEmitSpy).not.toHaveBeenCalled();
|
||||||
expect(bcEmitSpy).not.toHaveBeenCalled();
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should detect existing build directory after visibility change', async () => {
|
it('should detect existing build directory after visibility change', done => {
|
||||||
bcUpdatePrVisibilitySpy.and.callFake(() => bcExistsSpy.and.returnValue(true));
|
bcUpdatePrVisibilitySpy.and.callFake(() => existsValues[prDir] = existsValues[shaDir] = true);
|
||||||
|
|
||||||
expect(bcExistsSpy(prDir)).toBe(false);
|
expect(bcExistsSpy(prDir)).toBe(false);
|
||||||
expect(bcExistsSpy(shaDir)).toBe(false);
|
expect(bcExistsSpy(shaDir)).toBe(false);
|
||||||
|
|
||||||
await expectAsync(bc.create(pr, sha, archive, isPublic)).toBeRejectedWithPreviewServerError(
|
bc.create(pr, sha, archive, isPublic).catch(err => {
|
||||||
409, `Request to overwrite existing ${isPublic ? '' : 'non-'}public directory: ${shaDir}`);
|
const publicOrNot = isPublic ? 'public' : 'non-public';
|
||||||
|
expectToBePreviewServerError(err, 409, `Request to overwrite existing ${publicOrNot} directory: ${shaDir}`);
|
||||||
expect(shellMkdirSpy).not.toHaveBeenCalled();
|
expect(shellMkdirSpy).not.toHaveBeenCalled();
|
||||||
expect(bcExtractArchiveSpy).not.toHaveBeenCalled();
|
expect(bcExtractArchiveSpy).not.toHaveBeenCalled();
|
||||||
expect(bcEmitSpy).not.toHaveBeenCalled();
|
expect(bcEmitSpy).not.toHaveBeenCalled();
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should abort and skip further operations if it fails to create the directories', async () => {
|
it('should abort and skip further operations if it fails to create the directories', done => {
|
||||||
shellMkdirSpy.and.throwError('');
|
shellMkdirSpy.and.throwError('');
|
||||||
|
bc.create(pr, sha, archive, isPublic).catch(() => {
|
||||||
await expectAsync(bc.create(pr, sha, archive, isPublic)).toBeRejected();
|
expect(shellMkdirSpy).toHaveBeenCalled();
|
||||||
|
expect(bcExtractArchiveSpy).not.toHaveBeenCalled();
|
||||||
expect(shellMkdirSpy).toHaveBeenCalled();
|
expect(bcEmitSpy).not.toHaveBeenCalled();
|
||||||
expect(bcExtractArchiveSpy).not.toHaveBeenCalled();
|
done();
|
||||||
expect(bcEmitSpy).not.toHaveBeenCalled();
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should abort and skip further operations if it fails to extract the archive', async () => {
|
it('should abort and skip further operations if it fails to extract the archive', done => {
|
||||||
|
bcExtractArchiveSpy.and.throwError('');
|
||||||
|
bc.create(pr, sha, archive, isPublic).catch(() => {
|
||||||
|
expect(shellMkdirSpy).toHaveBeenCalled();
|
||||||
|
expect(bcExtractArchiveSpy).toHaveBeenCalled();
|
||||||
|
expect(bcEmitSpy).not.toHaveBeenCalled();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
it('should delete the PR directory (for new PR)', done => {
|
||||||
|
bcExtractArchiveSpy.and.throwError('');
|
||||||
|
bc.create(pr, sha, archive, isPublic).catch(() => {
|
||||||
|
expect(shellRmSpy).toHaveBeenCalledWith('-rf', prDir);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
it('should delete the SHA directory (for existing PR)', done => {
|
||||||
|
existsValues[prDir] = true;
|
||||||
bcExtractArchiveSpy.and.throwError('');
|
bcExtractArchiveSpy.and.throwError('');
|
||||||
|
|
||||||
await expectAsync(bc.create(pr, sha, archive, isPublic)).toBeRejected();
|
bc.create(pr, sha, archive, isPublic).catch(() => {
|
||||||
|
expect(shellRmSpy).toHaveBeenCalledWith('-rf', shaDir);
|
||||||
expect(shellMkdirSpy).toHaveBeenCalled();
|
done();
|
||||||
expect(bcExtractArchiveSpy).toHaveBeenCalled();
|
});
|
||||||
expect(bcEmitSpy).not.toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should delete the PR directory (for new PR)', async () => {
|
it('should reject with an PreviewServerError', done => {
|
||||||
bcExtractArchiveSpy.and.throwError('');
|
|
||||||
|
|
||||||
await expectAsync(bc.create(pr, sha, archive, isPublic)).toBeRejected();
|
|
||||||
expect(shellRmSpy).toHaveBeenCalledWith('-rf', prDir);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
it('should delete the SHA directory (for existing PR)', async () => {
|
|
||||||
bcExistsSpy.withArgs(prDir).and.returnValue(true);
|
|
||||||
bcExtractArchiveSpy.and.throwError('');
|
|
||||||
|
|
||||||
await expectAsync(bc.create(pr, sha, archive, isPublic)).toBeRejected();
|
|
||||||
expect(shellRmSpy).toHaveBeenCalledWith('-rf', shaDir);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
it('should reject with an PreviewServerError', async () => {
|
|
||||||
// tslint:disable-next-line: no-string-throw
|
// tslint:disable-next-line: no-string-throw
|
||||||
shellMkdirSpy.and.callFake(() => { throw 'Test'; });
|
shellMkdirSpy.and.callFake(() => { throw 'Test'; });
|
||||||
|
bc.create(pr, sha, archive, isPublic).catch(err => {
|
||||||
await expectAsync(bc.create(pr, sha, archive, isPublic)).toBeRejectedWithPreviewServerError(
|
expectToBePreviewServerError(err, 500, `Error while creating preview at: ${shaDir}\nTest`);
|
||||||
500, `Error while creating preview at: ${shaDir}\nTest`);
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should pass PreviewServerError instances unmodified', async () => {
|
it('should pass PreviewServerError instances unmodified', done => {
|
||||||
shellMkdirSpy.and.callFake(() => { throw new PreviewServerError(543, 'Test'); });
|
shellMkdirSpy.and.callFake(() => { throw new PreviewServerError(543, 'Test'); });
|
||||||
await expectAsync(bc.create(pr, sha, archive, isPublic)).toBeRejectedWithPreviewServerError(543, 'Test');
|
bc.create(pr, sha, archive, isPublic).catch(err => {
|
||||||
|
expectToBePreviewServerError(err, 543, 'Test');
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -241,12 +265,12 @@ describe('BuildCreator', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should return a promise', async () => {
|
it('should return a promise', done => {
|
||||||
const promise = bc.updatePrVisibility(pr, true);
|
const promise = bc.updatePrVisibility(pr, true);
|
||||||
expect(promise).toBeInstanceOf(Promise);
|
promise.then(done); // Do not complete the test (and release the spies) synchronously
|
||||||
|
// to avoid running the actual `extractArchive()`.
|
||||||
|
|
||||||
// Do not complete the test (and release the spies) synchronously to avoid running the actual `extractArchive()`.
|
expect(promise).toEqual(jasmine.any(Promise));
|
||||||
await promise;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -255,53 +279,58 @@ describe('BuildCreator', () => {
|
|||||||
const newPrDir = makePublic ? publicPrDir : hiddenPrDir;
|
const newPrDir = makePublic ? publicPrDir : hiddenPrDir;
|
||||||
|
|
||||||
|
|
||||||
it('should rename the directory', async () => {
|
it('should rename the directory', done => {
|
||||||
await bc.updatePrVisibility(pr, makePublic);
|
bc.updatePrVisibility(pr, makePublic).
|
||||||
expect(shellMvSpy).toHaveBeenCalledWith(oldPrDir, newPrDir);
|
then(() => expect(shellMvSpy).toHaveBeenCalledWith(oldPrDir, newPrDir)).
|
||||||
|
then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
describe('when the visibility is updated', () => {
|
describe('when the visibility is updated', () => {
|
||||||
|
|
||||||
it('should resolve to true', async () => {
|
it('should resolve to true', done => {
|
||||||
await expectAsync(bc.updatePrVisibility(pr, makePublic)).toBeResolvedTo(true);
|
bc.updatePrVisibility(pr, makePublic).
|
||||||
|
then(result => expect(result).toBe(true)).
|
||||||
|
then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should rename the directory', async () => {
|
it('should rename the directory', done => {
|
||||||
await bc.updatePrVisibility(pr, makePublic);
|
bc.updatePrVisibility(pr, makePublic).
|
||||||
expect(shellMvSpy).toHaveBeenCalledWith(oldPrDir, newPrDir);
|
then(() => expect(shellMvSpy).toHaveBeenCalledWith(oldPrDir, newPrDir)).
|
||||||
|
then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should emit a ChangedPrVisibilityEvent on success', async () => {
|
it('should emit a ChangedPrVisibilityEvent on success', done => {
|
||||||
let emitted = false;
|
let emitted = false;
|
||||||
|
|
||||||
bcEmitSpy.and.callFake((type: string, evt: ChangedPrVisibilityEvent) => {
|
bcEmitSpy.and.callFake((type: string, evt: ChangedPrVisibilityEvent) => {
|
||||||
expect(type).toBe(ChangedPrVisibilityEvent.type);
|
expect(type).toBe(ChangedPrVisibilityEvent.type);
|
||||||
expect(evt).toBeInstanceOf(ChangedPrVisibilityEvent);
|
expect(evt).toEqual(jasmine.any(ChangedPrVisibilityEvent));
|
||||||
expect(evt.pr).toBe(+pr);
|
expect(evt.pr).toBe(+pr);
|
||||||
expect(evt.shas).toBeInstanceOf(Array);
|
expect(evt.shas).toEqual(jasmine.any(Array));
|
||||||
expect(evt.isPublic).toBe(makePublic);
|
expect(evt.isPublic).toBe(makePublic);
|
||||||
|
|
||||||
emitted = true;
|
emitted = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
await bc.updatePrVisibility(pr, makePublic);
|
bc.updatePrVisibility(pr, makePublic).
|
||||||
expect(emitted).toBe(true);
|
then(() => expect(emitted).toBe(true)).
|
||||||
|
then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should include all shas in the emitted event', async () => {
|
it('should include all shas in the emitted event', done => {
|
||||||
const shas = ['foo', 'bar', 'baz'];
|
const shas = ['foo', 'bar', 'baz'];
|
||||||
let emitted = false;
|
let emitted = false;
|
||||||
|
|
||||||
bcListShasByDate.and.resolveTo(shas);
|
bcListShasByDate.and.callFake(() => Promise.resolve(shas));
|
||||||
bcEmitSpy.and.callFake((type: string, evt: ChangedPrVisibilityEvent) => {
|
bcEmitSpy.and.callFake((type: string, evt: ChangedPrVisibilityEvent) => {
|
||||||
expect(bcListShasByDate).toHaveBeenCalledWith(newPrDir);
|
expect(bcListShasByDate).toHaveBeenCalledWith(newPrDir);
|
||||||
|
|
||||||
expect(type).toBe(ChangedPrVisibilityEvent.type);
|
expect(type).toBe(ChangedPrVisibilityEvent.type);
|
||||||
expect(evt).toBeInstanceOf(ChangedPrVisibilityEvent);
|
expect(evt).toEqual(jasmine.any(ChangedPrVisibilityEvent));
|
||||||
expect(evt.pr).toBe(+pr);
|
expect(evt.pr).toBe(+pr);
|
||||||
expect(evt.shas).toBe(shas);
|
expect(evt.shas).toBe(shas);
|
||||||
expect(evt.isPublic).toBe(makePublic);
|
expect(evt.isPublic).toBe(makePublic);
|
||||||
@ -309,82 +338,94 @@ describe('BuildCreator', () => {
|
|||||||
emitted = true;
|
emitted = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
await bc.updatePrVisibility(pr, makePublic);
|
bc.updatePrVisibility(pr, makePublic).
|
||||||
expect(emitted).toBe(true);
|
then(() => expect(emitted).toBe(true)).
|
||||||
|
then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should do nothing if the visibility is already up-to-date', async () => {
|
it('should do nothing if the visibility is already up-to-date', done => {
|
||||||
bcExistsSpy.and.callFake((dir: string) => dir === newPrDir);
|
bcExistsSpy.and.callFake((dir: string) => dir === newPrDir);
|
||||||
|
bc.updatePrVisibility(pr, makePublic).
|
||||||
await expectAsync(bc.updatePrVisibility(pr, makePublic)).toBeResolvedTo(false);
|
then(result => {
|
||||||
|
expect(result).toBe(false);
|
||||||
expect(shellMvSpy).not.toHaveBeenCalled();
|
expect(shellMvSpy).not.toHaveBeenCalled();
|
||||||
expect(bcListShasByDate).not.toHaveBeenCalled();
|
expect(bcListShasByDate).not.toHaveBeenCalled();
|
||||||
expect(bcEmitSpy).not.toHaveBeenCalled();
|
expect(bcEmitSpy).not.toHaveBeenCalled();
|
||||||
|
}).
|
||||||
|
then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should do nothing if the PR directory does not exist', async () => {
|
it('should do nothing if the PR directory does not exist', done => {
|
||||||
bcExistsSpy.and.returnValue(false);
|
bcExistsSpy.and.returnValue(false);
|
||||||
|
bc.updatePrVisibility(pr, makePublic).
|
||||||
await expectAsync(bc.updatePrVisibility(pr, makePublic)).toBeResolvedTo(false);
|
then(result => {
|
||||||
|
expect(result).toBe(false);
|
||||||
expect(shellMvSpy).not.toHaveBeenCalled();
|
expect(shellMvSpy).not.toHaveBeenCalled();
|
||||||
expect(bcListShasByDate).not.toHaveBeenCalled();
|
expect(bcListShasByDate).not.toHaveBeenCalled();
|
||||||
expect(bcEmitSpy).not.toHaveBeenCalled();
|
expect(bcEmitSpy).not.toHaveBeenCalled();
|
||||||
|
}).
|
||||||
|
then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
describe('on error', () => {
|
describe('on error', () => {
|
||||||
|
|
||||||
it('should abort and skip further operations if both directories exist', async () => {
|
it('should abort and skip further operations if both directories exist', done => {
|
||||||
bcExistsSpy.and.returnValue(true);
|
bcExistsSpy.and.returnValue(true);
|
||||||
|
bc.updatePrVisibility(pr, makePublic).catch(err => {
|
||||||
await expectAsync(bc.updatePrVisibility(pr, makePublic)).toBeRejectedWithPreviewServerError(
|
expectToBePreviewServerError(err, 409,
|
||||||
409, `Request to move '${oldPrDir}' to existing directory '${newPrDir}'.`);
|
`Request to move '${oldPrDir}' to existing directory '${newPrDir}'.`);
|
||||||
|
expect(shellMvSpy).not.toHaveBeenCalled();
|
||||||
expect(shellMvSpy).not.toHaveBeenCalled();
|
expect(bcListShasByDate).not.toHaveBeenCalled();
|
||||||
expect(bcListShasByDate).not.toHaveBeenCalled();
|
expect(bcEmitSpy).not.toHaveBeenCalled();
|
||||||
expect(bcEmitSpy).not.toHaveBeenCalled();
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should abort and skip further operations if it fails to rename the directory', async () => {
|
it('should abort and skip further operations if it fails to rename the directory', done => {
|
||||||
shellMvSpy.and.throwError('');
|
shellMvSpy.and.throwError('');
|
||||||
|
bc.updatePrVisibility(pr, makePublic).catch(() => {
|
||||||
await expectAsync(bc.updatePrVisibility(pr, makePublic)).toBeRejected();
|
expect(shellMvSpy).toHaveBeenCalled();
|
||||||
|
expect(bcListShasByDate).not.toHaveBeenCalled();
|
||||||
expect(shellMvSpy).toHaveBeenCalled();
|
expect(bcEmitSpy).not.toHaveBeenCalled();
|
||||||
expect(bcListShasByDate).not.toHaveBeenCalled();
|
done();
|
||||||
expect(bcEmitSpy).not.toHaveBeenCalled();
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should abort and skip further operations if it fails to list the SHAs', async () => {
|
it('should abort and skip further operations if it fails to list the SHAs', done => {
|
||||||
bcListShasByDate.and.throwError('');
|
bcListShasByDate.and.throwError('');
|
||||||
|
bc.updatePrVisibility(pr, makePublic).catch(() => {
|
||||||
await expectAsync(bc.updatePrVisibility(pr, makePublic)).toBeRejected();
|
expect(shellMvSpy).toHaveBeenCalled();
|
||||||
|
expect(bcListShasByDate).toHaveBeenCalled();
|
||||||
expect(shellMvSpy).toHaveBeenCalled();
|
expect(bcEmitSpy).not.toHaveBeenCalled();
|
||||||
expect(bcListShasByDate).toHaveBeenCalled();
|
done();
|
||||||
expect(bcEmitSpy).not.toHaveBeenCalled();
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should reject with an PreviewServerError', async () => {
|
it('should reject with an PreviewServerError', done => {
|
||||||
// tslint:disable-next-line: no-string-throw
|
// tslint:disable-next-line: no-string-throw
|
||||||
shellMvSpy.and.callFake(() => { throw 'Test'; });
|
shellMvSpy.and.callFake(() => { throw 'Test'; });
|
||||||
await expectAsync(bc.updatePrVisibility(pr, makePublic)).toBeRejectedWithPreviewServerError(
|
bc.updatePrVisibility(pr, makePublic).catch(err => {
|
||||||
500, `Error while making PR ${pr} ${makePublic ? 'public' : 'hidden'}.\nTest`);
|
expectToBePreviewServerError(err, 500,
|
||||||
|
`Error while making PR ${pr} ${makePublic ? 'public' : 'hidden'}.\nTest`);
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should pass PreviewServerError instances unmodified', async () => {
|
it('should pass PreviewServerError instances unmodified', done => {
|
||||||
shellMvSpy.and.callFake(() => { throw new PreviewServerError(543, 'Test'); });
|
shellMvSpy.and.callFake(() => { throw new PreviewServerError(543, 'Test'); });
|
||||||
await expectAsync(bc.updatePrVisibility(pr, makePublic)).toBeRejectedWithPreviewServerError(543, 'Test');
|
bc.updatePrVisibility(pr, makePublic).catch(err => {
|
||||||
|
expectToBePreviewServerError(err, 543, 'Test');
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -402,14 +443,12 @@ describe('BuildCreator', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fsAccessCbs = [];
|
fsAccessCbs = [];
|
||||||
fsAccessSpy = spyOn(fs, 'access').and.callFake(
|
fsAccessSpy = spyOn(fs, 'access').and.callFake((_: string, cb: (v?: any) => void) => fsAccessCbs.push(cb));
|
||||||
((_: string, cb: (v?: any) => void) => fsAccessCbs.push(cb)) as unknown as typeof fs.access,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should return a promise', () => {
|
it('should return a promise', () => {
|
||||||
expect((bc as any).exists('foo')).toBeInstanceOf(Promise);
|
expect((bc as any).exists('foo')).toEqual(jasmine.any(Promise));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -419,29 +458,25 @@ describe('BuildCreator', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should resolve with \'true\' if \'fs.access()\' succeeds', async () => {
|
it('should resolve with \'true\' if \'fs.access()\' succeeds', done => {
|
||||||
const existsPromises = [
|
Promise.
|
||||||
(bc as any).exists('foo'),
|
all([(bc as any).exists('foo'), (bc as any).exists('bar')]).
|
||||||
(bc as any).exists('bar'),
|
then(results => expect(results).toEqual([true, true])).
|
||||||
];
|
then(done);
|
||||||
|
|
||||||
fsAccessCbs[0]();
|
fsAccessCbs[0]();
|
||||||
fsAccessCbs[1](null);
|
fsAccessCbs[1](null);
|
||||||
|
|
||||||
await expectAsync(Promise.all(existsPromises)).toBeResolvedTo([true, true]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should resolve with \'false\' if \'fs.access()\' errors', async () => {
|
it('should resolve with \'false\' if \'fs.access()\' errors', done => {
|
||||||
const existsPromises = [
|
Promise.
|
||||||
(bc as any).exists('foo'),
|
all([(bc as any).exists('foo'), (bc as any).exists('bar')]).
|
||||||
(bc as any).exists('bar'),
|
then(results => expect(results).toEqual([false, false])).
|
||||||
];
|
then(done);
|
||||||
|
|
||||||
fsAccessCbs[0]('Error');
|
fsAccessCbs[0]('Error');
|
||||||
fsAccessCbs[1](new Error());
|
fsAccessCbs[1](new Error());
|
||||||
|
|
||||||
await expectAsync(Promise.all(existsPromises)).toBeResolvedTo([false, false]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -460,15 +495,12 @@ describe('BuildCreator', () => {
|
|||||||
consoleWarnSpy = spyOn(Logger.prototype, 'warn');
|
consoleWarnSpy = spyOn(Logger.prototype, 'warn');
|
||||||
shellChmodSpy = spyOn(shell, 'chmod');
|
shellChmodSpy = spyOn(shell, 'chmod');
|
||||||
shellRmSpy = spyOn(shell, 'rm');
|
shellRmSpy = spyOn(shell, 'rm');
|
||||||
cpExecSpy = spyOn(cp, 'exec').and.callFake(
|
cpExecSpy = spyOn(cp, 'exec').and.callFake((_: string, cb: (...args: any[]) => void) => cpExecCbs.push(cb));
|
||||||
((_: string, cb: (...args: any[]) => void) =>
|
|
||||||
cpExecCbs.push(cb)) as unknown as typeof cp.exec,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should return a promise', () => {
|
it('should return a promise', () => {
|
||||||
expect((bc as any).extractArchive('foo', 'bar')).toBeInstanceOf(Promise);
|
expect((bc as any).extractArchive('foo', 'bar')).toEqual(jasmine.any(Promise));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -480,68 +512,78 @@ describe('BuildCreator', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should log (as a warning) any stderr output if extracting succeeded', async () => {
|
it('should log (as a warning) any stderr output if extracting succeeded', done => {
|
||||||
const extractPromise = (bc as any).extractArchive('foo', 'bar');
|
(bc as any).extractArchive('foo', 'bar').
|
||||||
|
then(() => expect(consoleWarnSpy).toHaveBeenCalledWith('This is stderr')).
|
||||||
|
then(done);
|
||||||
|
|
||||||
cpExecCbs[0](null, 'This is stdout', 'This is stderr');
|
cpExecCbs[0](null, 'This is stdout', 'This is stderr');
|
||||||
|
|
||||||
await expectAsync(extractPromise).toBeResolved();
|
|
||||||
expect(consoleWarnSpy).toHaveBeenCalledWith('This is stderr');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should make the build directory non-writable', async () => {
|
it('should make the build directory non-writable', done => {
|
||||||
const extractPromise = (bc as any).extractArchive('foo', 'bar');
|
(bc as any).extractArchive('foo', 'bar').
|
||||||
cpExecCbs[0]();
|
then(() => expect(shellChmodSpy).toHaveBeenCalledWith('-R', 'a-w', 'bar')).
|
||||||
|
then(done);
|
||||||
|
|
||||||
await expectAsync(extractPromise).toBeResolved();
|
cpExecCbs[0]();
|
||||||
expect(shellChmodSpy).toHaveBeenCalledWith('-R', 'a-w', 'bar');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should delete the build artifact file on success', async () => {
|
it('should delete the build artifact file on success', done => {
|
||||||
const extractPromise = (bc as any).extractArchive('input/file', 'output/dir');
|
(bc as any).extractArchive('input/file', 'output/dir').
|
||||||
cpExecCbs[0]();
|
then(() => expect(shellRmSpy).toHaveBeenCalledWith('-f', 'input/file')).
|
||||||
|
then(done);
|
||||||
|
|
||||||
await expectAsync(extractPromise).toBeResolved();
|
cpExecCbs[0]();
|
||||||
expect(shellRmSpy).toHaveBeenCalledWith('-f', 'input/file');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
describe('on error', () => {
|
describe('on error', () => {
|
||||||
|
|
||||||
it('should abort and skip further operations if it fails to extract the archive', async () => {
|
it('should abort and skip further operations if it fails to extract the archive', done => {
|
||||||
const extractPromise = (bc as any).extractArchive('foo', 'bar');
|
(bc as any).extractArchive('foo', 'bar').catch((err: any) => {
|
||||||
|
expect(shellChmodSpy).not.toHaveBeenCalled();
|
||||||
|
expect(shellRmSpy).not.toHaveBeenCalled();
|
||||||
|
expect(err).toBe('Test');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
cpExecCbs[0]('Test');
|
cpExecCbs[0]('Test');
|
||||||
|
|
||||||
await expectAsync(extractPromise).toBeRejectedWith('Test');
|
|
||||||
expect(shellChmodSpy).not.toHaveBeenCalled();
|
|
||||||
expect(shellRmSpy).not.toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should abort and skip further operations if it fails to make non-writable', async () => {
|
it('should abort and skip further operations if it fails to make non-writable', done => {
|
||||||
// tslint:disable-next-line: no-string-throw
|
(bc as any).extractArchive('foo', 'bar').catch((err: any) => {
|
||||||
shellChmodSpy.and.callFake(() => { throw 'Test'; });
|
expect(shellChmodSpy).toHaveBeenCalled();
|
||||||
|
expect(shellRmSpy).not.toHaveBeenCalled();
|
||||||
|
expect(err).toBe('Test');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
shellChmodSpy.and.callFake(() => {
|
||||||
|
// tslint:disable-next-line: no-string-throw
|
||||||
|
throw 'Test';
|
||||||
|
});
|
||||||
|
|
||||||
const extractPromise = (bc as any).extractArchive('foo', 'bar');
|
|
||||||
cpExecCbs[0]();
|
cpExecCbs[0]();
|
||||||
|
|
||||||
await expectAsync(extractPromise).toBeRejectedWith('Test');
|
|
||||||
expect(shellChmodSpy).toHaveBeenCalled();
|
|
||||||
expect(shellRmSpy).not.toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should abort and reject if it fails to remove the build artifact file', async () => {
|
it('should abort and reject if it fails to remove the build artifact file', done => {
|
||||||
// tslint:disable-next-line: no-string-throw
|
(bc as any).extractArchive('foo', 'bar').catch((err: any) => {
|
||||||
shellRmSpy.and.callFake(() => { throw 'Test'; });
|
expect(shellChmodSpy).toHaveBeenCalled();
|
||||||
|
expect(shellRmSpy).toHaveBeenCalled();
|
||||||
|
expect(err).toBe('Test');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
shellRmSpy.and.callFake(() => {
|
||||||
|
// tslint:disable-next-line: no-string-throw
|
||||||
|
throw 'Test';
|
||||||
|
});
|
||||||
|
|
||||||
const extractPromise = (bc as any).extractArchive('foo', 'bar');
|
|
||||||
cpExecCbs[0]();
|
cpExecCbs[0]();
|
||||||
|
|
||||||
await expectAsync(extractPromise).toBeRejectedWith('Test');
|
|
||||||
expect(shellChmodSpy).toHaveBeenCalled();
|
|
||||||
expect(shellRmSpy).toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -558,54 +600,62 @@ describe('BuildCreator', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
shellLsSpy = spyOn(shell, 'ls').and.returnValue([] as unknown as shell.ShellArray);
|
shellLsSpy = spyOn(shell, 'ls').and.returnValue([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should return a promise', async () => {
|
it('should return a promise', done => {
|
||||||
const promise = (bc as any).listShasByDate('input/dir');
|
const promise = (bc as any).listShasByDate('input/dir');
|
||||||
expect(promise).toBeInstanceOf(Promise);
|
promise.then(done); // Do not complete the test (and release the spies) synchronously
|
||||||
|
// to avoid running the actual `ls()`.
|
||||||
|
|
||||||
// Do not complete the test (and release the spies) synchronously to avoid running the actual `ls()`.
|
expect(promise).toEqual(jasmine.any(Promise));
|
||||||
await promise;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should `ls()` files with their metadata', async () => {
|
it('should `ls()` files with their metadata', done => {
|
||||||
await (bc as any).listShasByDate('input/dir');
|
(bc as any).listShasByDate('input/dir').
|
||||||
expect(shellLsSpy).toHaveBeenCalledWith('-l', 'input/dir');
|
then(() => expect(shellLsSpy).toHaveBeenCalledWith('-l', 'input/dir')).
|
||||||
|
then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should reject if listing files fails', async () => {
|
it('should reject if listing files fails', done => {
|
||||||
shellLsSpy.and.rejectWith('Test');
|
shellLsSpy.and.callFake(() => Promise.reject('Test'));
|
||||||
await expectAsync((bc as any).listShasByDate('input/dir')).toBeRejectedWith('Test');
|
(bc as any).listShasByDate('input/dir').catch((err: string) => {
|
||||||
|
expect(err).toBe('Test');
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should return the filenames', async () => {
|
it('should return the filenames', done => {
|
||||||
shellLsSpy.and.resolveTo([
|
shellLsSpy.and.callFake(() => Promise.resolve([
|
||||||
lsResult('foo', 100),
|
lsResult('foo', 100),
|
||||||
lsResult('bar', 200),
|
lsResult('bar', 200),
|
||||||
lsResult('baz', 300),
|
lsResult('baz', 300),
|
||||||
]);
|
]));
|
||||||
|
|
||||||
await expectAsync((bc as any).listShasByDate('input/dir')).toBeResolvedTo(['foo', 'bar', 'baz']);
|
(bc as any).listShasByDate('input/dir').
|
||||||
|
then((shas: string[]) => expect(shas).toEqual(['foo', 'bar', 'baz'])).
|
||||||
|
then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should sort by date', async () => {
|
it('should sort by date', done => {
|
||||||
shellLsSpy.and.resolveTo([
|
shellLsSpy.and.callFake(() => Promise.resolve([
|
||||||
lsResult('foo', 300),
|
lsResult('foo', 300),
|
||||||
lsResult('bar', 100),
|
lsResult('bar', 100),
|
||||||
lsResult('baz', 200),
|
lsResult('baz', 200),
|
||||||
]);
|
]));
|
||||||
|
|
||||||
await expectAsync((bc as any).listShasByDate('input/dir')).toBeResolvedTo(['bar', 'baz', 'foo']);
|
(bc as any).listShasByDate('input/dir').
|
||||||
|
then((shas: string[]) => expect(shas).toEqual(['bar', 'baz', 'foo'])).
|
||||||
|
then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should not break with ShellJS\' custom `sort()` method', async () => {
|
it('should not break with ShellJS\' custom `sort()` method', done => {
|
||||||
const mockArray = [
|
const mockArray = [
|
||||||
lsResult('foo', 300),
|
lsResult('foo', 300),
|
||||||
lsResult('bar', 100),
|
lsResult('bar', 100),
|
||||||
@ -613,21 +663,26 @@ describe('BuildCreator', () => {
|
|||||||
];
|
];
|
||||||
mockArray.sort = jasmine.createSpy('sort');
|
mockArray.sort = jasmine.createSpy('sort');
|
||||||
|
|
||||||
shellLsSpy.and.resolveTo(mockArray);
|
shellLsSpy.and.callFake(() => Promise.resolve(mockArray));
|
||||||
|
(bc as any).listShasByDate('input/dir').
|
||||||
await expectAsync((bc as any).listShasByDate('input/dir')).toBeResolvedTo(['bar', 'baz', 'foo']);
|
then((shas: string[]) => {
|
||||||
expect(mockArray.sort).not.toHaveBeenCalled();
|
expect(shas).toEqual(['bar', 'baz', 'foo']);
|
||||||
|
expect(mockArray.sort).not.toHaveBeenCalled();
|
||||||
|
}).
|
||||||
|
then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should only include directories', async () => {
|
it('should only include directories', done => {
|
||||||
shellLsSpy.and.resolveTo([
|
shellLsSpy.and.callFake(() => Promise.resolve([
|
||||||
lsResult('foo', 100),
|
lsResult('foo', 100),
|
||||||
lsResult('bar', 200, false),
|
lsResult('bar', 200, false),
|
||||||
lsResult('baz', 300),
|
lsResult('baz', 300),
|
||||||
]);
|
]));
|
||||||
|
|
||||||
await expectAsync((bc as any).listShasByDate('input/dir')).toBeResolvedTo(['foo', 'baz']);
|
(bc as any).listShasByDate('input/dir').
|
||||||
|
then((shas: string[]) => expect(shas).toEqual(['foo', 'baz'])).
|
||||||
|
then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -32,18 +32,18 @@ describe('BuildRetriever', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
api = new CircleCiApi('ORG', 'REPO', 'TOKEN');
|
api = new CircleCiApi('ORG', 'REPO', 'TOKEN');
|
||||||
spyOn(api, 'getBuildInfo').and.resolveTo(BUILD_INFO);
|
spyOn(api, 'getBuildInfo').and.callFake(() => Promise.resolve(BUILD_INFO));
|
||||||
getBuildArtifactUrlSpy = spyOn(api, 'getBuildArtifactUrl').and.resolveTo(BASE_URL + ARTIFACT_PATH);
|
getBuildArtifactUrlSpy = spyOn(api, 'getBuildArtifactUrl')
|
||||||
|
.and.callFake(() => Promise.resolve(BASE_URL + ARTIFACT_PATH));
|
||||||
|
|
||||||
WRITEFILE_RESULT = undefined;
|
WRITEFILE_RESULT = undefined;
|
||||||
writeFileSpy = spyOn(fs, 'writeFile').and.callFake(
|
writeFileSpy = spyOn(fs, 'writeFile').and.callFake(
|
||||||
((_path: string, _buffer: Buffer, callback: fs.NoParamCallback) =>
|
(_path: string, _buffer: Buffer, callback: (err?: any) => {}) => callback(WRITEFILE_RESULT),
|
||||||
callback(WRITEFILE_RESULT)) as typeof fs.writeFile,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
EXISTS_RESULT = false;
|
EXISTS_RESULT = false;
|
||||||
existsSpy = spyOn(fs, 'exists').and.callFake(
|
existsSpy = spyOn(fs, 'exists').and.callFake(
|
||||||
((_path, callback) => callback(EXISTS_RESULT)) as typeof fs.exists,
|
(_path: string, callback: (exists: boolean) => {}) => callback(EXISTS_RESULT),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -56,7 +56,6 @@ describe('BuildRetriever', () => {
|
|||||||
expect(() => new BuildRetriever(api, -1, DOWNLOAD_DIR))
|
expect(() => new BuildRetriever(api, -1, DOWNLOAD_DIR))
|
||||||
.toThrowError(`Invalid parameter "downloadSizeLimit" should be a number greater than 0.`);
|
.toThrowError(`Invalid parameter "downloadSizeLimit" should be a number greater than 0.`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fail if the "downloadDir" is missing', () => {
|
it('should fail if the "downloadDir" is missing', () => {
|
||||||
expect(() => new BuildRetriever(api, MAX_DOWNLOAD_SIZE, ''))
|
expect(() => new BuildRetriever(api, MAX_DOWNLOAD_SIZE, ''))
|
||||||
.toThrowError(`Missing or empty required parameter 'downloadDir'!`);
|
.toThrowError(`Missing or empty required parameter 'downloadDir'!`);
|
||||||
@ -73,10 +72,14 @@ describe('BuildRetriever', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should error if it is not possible to extract the PR number from the branch', async () => {
|
it('should error if it is not possible to extract the PR number from the branch', async () => {
|
||||||
BUILD_INFO.branch = 'master';
|
|
||||||
const retriever = new BuildRetriever(api, MAX_DOWNLOAD_SIZE, DOWNLOAD_DIR);
|
const retriever = new BuildRetriever(api, MAX_DOWNLOAD_SIZE, DOWNLOAD_DIR);
|
||||||
|
try {
|
||||||
await expectAsync(retriever.getGithubInfo(12345)).toBeRejectedWithError('No PR found in branch field: master');
|
BUILD_INFO.branch = 'master';
|
||||||
|
await retriever.getGithubInfo(12345);
|
||||||
|
throw new Error('Exception Expected');
|
||||||
|
} catch (error) {
|
||||||
|
expect(error.message).toEqual('No PR found in branch field: master');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -107,10 +110,12 @@ describe('BuildRetriever', () => {
|
|||||||
it('should fail if the artifact is too large', async () => {
|
it('should fail if the artifact is too large', async () => {
|
||||||
const artifactRequest = nock(BASE_URL).get(ARTIFACT_PATH).reply(200, ARTIFACT_CONTENTS);
|
const artifactRequest = nock(BASE_URL).get(ARTIFACT_PATH).reply(200, ARTIFACT_CONTENTS);
|
||||||
retriever = new BuildRetriever(api, 10, DOWNLOAD_DIR);
|
retriever = new BuildRetriever(api, 10, DOWNLOAD_DIR);
|
||||||
|
try {
|
||||||
await expectAsync(retriever.downloadBuildArtifact(12345, 777, 'COMMIT', ARTIFACT_PATH)).
|
await retriever.downloadBuildArtifact(12345, 777, 'COMMIT', ARTIFACT_PATH);
|
||||||
toBeRejectedWith(jasmine.objectContaining({status: 413}));
|
throw new Error('Exception Expected');
|
||||||
|
} catch (error) {
|
||||||
|
expect(error.status).toEqual(413);
|
||||||
|
}
|
||||||
artifactRequest.done();
|
artifactRequest.done();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -138,40 +143,50 @@ describe('BuildRetriever', () => {
|
|||||||
artifactRequest.done();
|
artifactRequest.done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fail if the CircleCI API fails', async () => {
|
it('should fail if the CircleCI API fails', async () => {
|
||||||
getBuildArtifactUrlSpy.and.rejectWith('getBuildArtifactUrl failed');
|
try {
|
||||||
await expectAsync(retriever.downloadBuildArtifact(12345, 777, 'COMMIT', ARTIFACT_PATH)).
|
getBuildArtifactUrlSpy.and.callFake(() => Promise.reject('getBuildArtifactUrl failed'));
|
||||||
toBeRejectedWithError('CircleCI artifact download failed (getBuildArtifactUrl failed)');
|
await retriever.downloadBuildArtifact(12345, 777, 'COMMIT', ARTIFACT_PATH);
|
||||||
|
throw new Error('Exception Expected');
|
||||||
|
} catch (error) {
|
||||||
|
expect(error.message).toEqual('CircleCI artifact download failed (getBuildArtifactUrl failed)');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fail if the URL fetch errors', async () => {
|
it('should fail if the URL fetch errors', async () => {
|
||||||
// create a new handler that errors
|
// create a new handler that errors
|
||||||
const artifactRequest = nock(BASE_URL).get(ARTIFACT_PATH).replyWithError('Artifact Request Failed');
|
const artifactRequest = nock(BASE_URL).get(ARTIFACT_PATH).replyWithError('Artifact Request Failed');
|
||||||
|
try {
|
||||||
await expectAsync(retriever.downloadBuildArtifact(12345, 777, 'COMMIT', ARTIFACT_PATH)).toBeRejectedWithError(
|
await retriever.downloadBuildArtifact(12345, 777, 'COMMIT', ARTIFACT_PATH);
|
||||||
'CircleCI artifact download failed ' +
|
throw new Error('Exception Expected');
|
||||||
|
} catch (error) {
|
||||||
|
expect(error.message).toEqual('CircleCI artifact download failed ' +
|
||||||
'(request to http://test.com/some/path/build.zip failed, reason: Artifact Request Failed)');
|
'(request to http://test.com/some/path/build.zip failed, reason: Artifact Request Failed)');
|
||||||
|
}
|
||||||
artifactRequest.done();
|
artifactRequest.done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fail if the URL fetch 404s', async () => {
|
it('should fail if the URL fetch 404s', async () => {
|
||||||
// create a new handler that errors
|
// create a new handler that errors
|
||||||
const artifactRequest = nock(BASE_URL).get(ARTIFACT_PATH).reply(404, 'No such artifact');
|
const artifactRequest = nock(BASE_URL).get(ARTIFACT_PATH).reply(404, 'No such artifact');
|
||||||
|
try {
|
||||||
await expectAsync(retriever.downloadBuildArtifact(12345, 777, 'COMMIT', ARTIFACT_PATH)).
|
await retriever.downloadBuildArtifact(12345, 777, 'COMMIT', ARTIFACT_PATH);
|
||||||
toBeRejectedWithError('CircleCI artifact download failed (Error 404 - Not Found)');
|
throw new Error('Exception Expected');
|
||||||
|
} catch (error) {
|
||||||
|
expect(error.message).toEqual('CircleCI artifact download failed (Error 404 - Not Found)');
|
||||||
|
}
|
||||||
artifactRequest.done();
|
artifactRequest.done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fail if file write fails', async () => {
|
it('should fail if file write fails', async () => {
|
||||||
const artifactRequest = nock(BASE_URL).get(ARTIFACT_PATH).reply(200, ARTIFACT_CONTENTS);
|
const artifactRequest = nock(BASE_URL).get(ARTIFACT_PATH).reply(200, ARTIFACT_CONTENTS);
|
||||||
WRITEFILE_RESULT = 'Test Error';
|
try {
|
||||||
|
WRITEFILE_RESULT = 'Test Error';
|
||||||
await expectAsync(retriever.downloadBuildArtifact(12345, 777, 'COMMIT', ARTIFACT_PATH)).
|
await retriever.downloadBuildArtifact(12345, 777, 'COMMIT', ARTIFACT_PATH);
|
||||||
toBeRejectedWithError('CircleCI artifact download failed (Test Error)');
|
throw new Error('Exception Expected');
|
||||||
|
} catch (error) {
|
||||||
|
expect(error.message).toEqual('CircleCI artifact download failed (Test Error)');
|
||||||
|
}
|
||||||
artifactRequest.done();
|
artifactRequest.done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -51,10 +51,7 @@ describe('BuildVerifier', () => {
|
|||||||
describe('getSignificantFilesChanged', () => {
|
describe('getSignificantFilesChanged', () => {
|
||||||
it('should return false if none of the fetched files match the given pattern', async () => {
|
it('should return false if none of the fetched files match the given pattern', async () => {
|
||||||
const fetchFilesSpy = spyOn(prs, 'fetchFiles');
|
const fetchFilesSpy = spyOn(prs, 'fetchFiles');
|
||||||
fetchFilesSpy.and.resolveTo([
|
fetchFilesSpy.and.callFake(() => Promise.resolve([{filename: 'a/b/c'}, {filename: 'd/e/f'}]));
|
||||||
{filename: 'a/b/c', sha: 'a1'},
|
|
||||||
{filename: 'd/e/f', sha: 'b2'},
|
|
||||||
]);
|
|
||||||
expect(await bv.getSignificantFilesChanged(777, /^x/)).toEqual(false);
|
expect(await bv.getSignificantFilesChanged(777, /^x/)).toEqual(false);
|
||||||
expect(fetchFilesSpy).toHaveBeenCalledWith(777);
|
expect(fetchFilesSpy).toHaveBeenCalledWith(777);
|
||||||
|
|
||||||
@ -81,30 +78,37 @@ describe('BuildVerifier', () => {
|
|||||||
user: {login: 'username'},
|
user: {login: 'username'},
|
||||||
};
|
};
|
||||||
|
|
||||||
prsFetchSpy = spyOn(GithubPullRequests.prototype, 'fetch').and.resolveTo(mockPrInfo);
|
prsFetchSpy = spyOn(GithubPullRequests.prototype, 'fetch').
|
||||||
teamsIsMemberBySlugSpy = spyOn(GithubTeams.prototype, 'isMemberBySlug').and.resolveTo(true);
|
and.callFake(() => Promise.resolve(mockPrInfo));
|
||||||
|
|
||||||
|
teamsIsMemberBySlugSpy = spyOn(GithubTeams.prototype, 'isMemberBySlug').
|
||||||
|
and.callFake(() => Promise.resolve(true));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should return a promise', async () => {
|
it('should return a promise', done => {
|
||||||
const promise = bv.getPrIsTrusted(pr);
|
const promise = bv.getPrIsTrusted(pr);
|
||||||
expect(promise).toBeInstanceOf(Promise);
|
promise.then(done); // Do not complete the test (and release the spies) synchronously
|
||||||
|
// to avoid running the actual `GithubTeams#isMemberBySlug()`.
|
||||||
|
|
||||||
// Do not complete the test (and release the spies) synchronously to avoid running the actual
|
expect(promise).toEqual(jasmine.any(Promise));
|
||||||
// `GithubTeams#isMemberBySlug()`.
|
|
||||||
await promise;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should fetch the corresponding PR', async () => {
|
it('should fetch the corresponding PR', done => {
|
||||||
await bv.getPrIsTrusted(pr);
|
bv.getPrIsTrusted(pr).then(() => {
|
||||||
expect(prsFetchSpy).toHaveBeenCalledWith(pr);
|
expect(prsFetchSpy).toHaveBeenCalledWith(pr);
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should fail if fetching the PR errors', async () => {
|
it('should fail if fetching the PR errors', done => {
|
||||||
prsFetchSpy.and.rejectWith('Test');
|
prsFetchSpy.and.callFake(() => Promise.reject('Test'));
|
||||||
await expectAsync(bv.getPrIsTrusted(pr)).toBeRejectedWith('Test');
|
bv.getPrIsTrusted(pr).catch(err => {
|
||||||
|
expect(err).toBe('Test');
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -113,14 +117,19 @@ describe('BuildVerifier', () => {
|
|||||||
beforeEach(() => mockPrInfo.labels.push({name: 'trusted: pr-label'}));
|
beforeEach(() => mockPrInfo.labels.push({name: 'trusted: pr-label'}));
|
||||||
|
|
||||||
|
|
||||||
it('should resolve to true', async () => {
|
it('should resolve to true', done => {
|
||||||
await expectAsync(bv.getPrIsTrusted(pr)).toBeResolvedTo(true);
|
bv.getPrIsTrusted(pr).then(isTrusted => {
|
||||||
|
expect(isTrusted).toBe(true);
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should not try to verify the author\'s membership status', async () => {
|
it('should not try to verify the author\'s membership status', done => {
|
||||||
await expectAsync(bv.getPrIsTrusted(pr));
|
bv.getPrIsTrusted(pr).then(() => {
|
||||||
expect(teamsIsMemberBySlugSpy).not.toHaveBeenCalled();
|
expect(teamsIsMemberBySlugSpy).not.toHaveBeenCalled();
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -128,27 +137,40 @@ describe('BuildVerifier', () => {
|
|||||||
|
|
||||||
describe('when the PR does not have the "trusted PR" label', () => {
|
describe('when the PR does not have the "trusted PR" label', () => {
|
||||||
|
|
||||||
it('should verify the PR author\'s membership in the specified teams', async () => {
|
it('should verify the PR author\'s membership in the specified teams', done => {
|
||||||
await bv.getPrIsTrusted(pr);
|
bv.getPrIsTrusted(pr).then(() => {
|
||||||
expect(teamsIsMemberBySlugSpy).toHaveBeenCalledWith('username', ['team1', 'team2']);
|
expect(teamsIsMemberBySlugSpy).toHaveBeenCalledWith('username', ['team1', 'team2']);
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should fail if verifying membership errors', async () => {
|
it('should fail if verifying membership errors', done => {
|
||||||
teamsIsMemberBySlugSpy.and.rejectWith('Test');
|
teamsIsMemberBySlugSpy.and.callFake(() => Promise.reject('Test'));
|
||||||
await expectAsync(bv.getPrIsTrusted(pr)).toBeRejectedWith('Test');
|
bv.getPrIsTrusted(pr).catch(err => {
|
||||||
|
expect(err).toBe('Test');
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should resolve to true if the PR\'s author is a member', async () => {
|
it('should resolve to true if the PR\'s author is a member', done => {
|
||||||
teamsIsMemberBySlugSpy.and.resolveTo(true);
|
teamsIsMemberBySlugSpy.and.callFake(() => Promise.resolve(true));
|
||||||
await expectAsync(bv.getPrIsTrusted(pr)).toBeResolvedTo(true);
|
|
||||||
|
bv.getPrIsTrusted(pr).then(isTrusted => {
|
||||||
|
expect(isTrusted).toBe(true);
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should resolve to false if the PR\'s author is not a member', async () => {
|
it('should resolve to false if the PR\'s author is not a member', done => {
|
||||||
teamsIsMemberBySlugSpy.and.resolveTo(false);
|
teamsIsMemberBySlugSpy.and.callFake(() => Promise.resolve(false));
|
||||||
await expectAsync(bv.getPrIsTrusted(pr)).toBeResolvedTo(false);
|
|
||||||
|
bv.getPrIsTrusted(pr).then(isTrusted => {
|
||||||
|
expect(isTrusted).toBe(false);
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
import {PreviewServerError} from '../../lib/preview-server/preview-error';
|
||||||
|
|
||||||
|
export const expectToBePreviewServerError = (actual: PreviewServerError, status?: number, message?: string) => {
|
||||||
|
expect(actual).toEqual(jasmine.any(PreviewServerError));
|
||||||
|
if (status != null) {
|
||||||
|
expect(actual.status).toBe(status);
|
||||||
|
}
|
||||||
|
if (message != null) {
|
||||||
|
expect(actual.message).toBe(message);
|
||||||
|
}
|
||||||
|
};
|
@ -1,5 +0,0 @@
|
|||||||
declare module jasmine {
|
|
||||||
interface AsyncMatchers {
|
|
||||||
toBeRejectedWithPreviewServerError(status: number, message?: string | RegExp): Promise<void>;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,59 +0,0 @@
|
|||||||
import {PreviewServerError} from '../../lib/preview-server/preview-error';
|
|
||||||
|
|
||||||
|
|
||||||
// Matchers
|
|
||||||
const toBeRejectedWithPreviewServerError: jasmine.CustomAsyncMatcherFactory = () => {
|
|
||||||
return {
|
|
||||||
async compare(actualPromise: Promise<never>, expectedStatus: number, expectedMessage?: string | RegExp) {
|
|
||||||
if (!(actualPromise instanceof Promise)) {
|
|
||||||
throw new Error(`Expected '${toBeRejectedWithPreviewServerError.name}()' to be called on a promise.`);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
await actualPromise;
|
|
||||||
|
|
||||||
return {
|
|
||||||
pass: false,
|
|
||||||
message: `Expected a promise to be rejected with a '${PreviewServerError.name}', but it was resolved.`,
|
|
||||||
};
|
|
||||||
} catch (actualError) {
|
|
||||||
const actualPrintValue = stringify(actualError);
|
|
||||||
const expectedPrintValue =
|
|
||||||
stringify(new PreviewServerError(expectedStatus, expectedMessage && `${expectedMessage}`));
|
|
||||||
|
|
||||||
const pass = errorMatches(actualError, expectedStatus, expectedMessage);
|
|
||||||
const message =
|
|
||||||
`Expected a promise ${pass ? 'not ' : ''}to be rejected with ${expectedPrintValue}, but is was` +
|
|
||||||
`${pass ? '' : ` rejected with ${actualPrintValue}`}.`;
|
|
||||||
|
|
||||||
return {pass, message};
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
// Helpers
|
|
||||||
function errorMatches(actualErr: unknown, expectedStatus: number, expectedMsg?: string | RegExp): boolean {
|
|
||||||
if (!(actualErr instanceof PreviewServerError)) return false;
|
|
||||||
if (actualErr.status !== expectedStatus) return false;
|
|
||||||
return messageMatches(actualErr.message, expectedMsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
function messageMatches(actualMsg: string, expectedMsg?: string | RegExp): boolean {
|
|
||||||
if (typeof expectedMsg === 'undefined') return true;
|
|
||||||
if (typeof expectedMsg === 'string') return actualMsg === expectedMsg;
|
|
||||||
return expectedMsg.test(actualMsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
function stringify(value: unknown): string {
|
|
||||||
if (value instanceof PreviewServerError) {
|
|
||||||
return `${PreviewServerError.name}(${value.status}${value.message ? `, ${value.message}` : ''})`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return jasmine.pp(value);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Exports
|
|
||||||
export const customAsyncMatchers: jasmine.CustomAsyncMatcherFactories = {
|
|
||||||
toBeRejectedWithPreviewServerError,
|
|
||||||
};
|
|
@ -9,8 +9,8 @@ describe('PreviewServerError', () => {
|
|||||||
|
|
||||||
|
|
||||||
it('should extend Error', () => {
|
it('should extend Error', () => {
|
||||||
expect(err).toBeInstanceOf(PreviewServerError);
|
expect(err).toEqual(jasmine.any(PreviewServerError));
|
||||||
expect(err).toBeInstanceOf(Error);
|
expect(err).toEqual(jasmine.any(Error));
|
||||||
|
|
||||||
expect(Object.getPrototypeOf(err)).toBe(PreviewServerError.prototype);
|
expect(Object.getPrototypeOf(err)).toBe(PreviewServerError.prototype);
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
// Imports
|
// Imports
|
||||||
|
import * as express from 'express';
|
||||||
import * as http from 'http';
|
import * as http from 'http';
|
||||||
import * as supertest from 'supertest';
|
import * as supertest from 'supertest';
|
||||||
import {CircleCiApi} from '../../lib/common/circle-ci-api';
|
import {CircleCiApi} from '../../lib/common/circle-ci-api';
|
||||||
@ -133,7 +134,7 @@ describe('PreviewServerFactory', () => {
|
|||||||
const buildCreator = jasmine.any(BuildCreator);
|
const buildCreator = jasmine.any(BuildCreator);
|
||||||
expect(usfCreateMiddlewareSpy).toHaveBeenCalledWith(buildRetriever, buildVerifier, buildCreator, defaultConfig);
|
expect(usfCreateMiddlewareSpy).toHaveBeenCalledWith(buildRetriever, buildVerifier, buildCreator, defaultConfig);
|
||||||
|
|
||||||
const middleware = usfCreateMiddlewareSpy.calls.mostRecent().returnValue;
|
const middleware: express.Express = usfCreateMiddlewareSpy.calls.mostRecent().returnValue;
|
||||||
expect(httpCreateServerSpy).toHaveBeenCalledWith(middleware);
|
expect(httpCreateServerSpy).toHaveBeenCalledWith(middleware);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -229,7 +230,7 @@ describe('PreviewServerFactory', () => {
|
|||||||
|
|
||||||
expect(prsAddCommentSpy).toHaveBeenCalledTimes(2);
|
expect(prsAddCommentSpy).toHaveBeenCalledTimes(2);
|
||||||
expect(prs).toBe(allCalls[1].object);
|
expect(prs).toBe(allCalls[1].object);
|
||||||
expect(prs).toBeInstanceOf(GithubPullRequests);
|
expect(prs).toEqual(jasmine.any(GithubPullRequests));
|
||||||
expect(prs.repoSlug).toBe('organisation/repo');
|
expect(prs.repoSlug).toBe('organisation/repo');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -301,8 +302,9 @@ describe('PreviewServerFactory', () => {
|
|||||||
let bvGetSignificantFilesChangedSpy: jasmine.Spy;
|
let bvGetSignificantFilesChangedSpy: jasmine.Spy;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
bvGetPrIsTrustedSpy = spyOn(buildVerifier, 'getPrIsTrusted').and.resolveTo(true);
|
bvGetPrIsTrustedSpy = spyOn(buildVerifier, 'getPrIsTrusted').and.returnValue(Promise.resolve(true));
|
||||||
bvGetSignificantFilesChangedSpy = spyOn(buildVerifier, 'getSignificantFilesChanged').and.resolveTo(true);
|
bvGetSignificantFilesChangedSpy = spyOn(buildVerifier, 'getSignificantFilesChanged').
|
||||||
|
and.returnValue(Promise.resolve(true));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -329,7 +331,7 @@ describe('PreviewServerFactory', () => {
|
|||||||
|
|
||||||
|
|
||||||
it('should respond appropriately if the PR did not touch any significant files', async () => {
|
it('should respond appropriately if the PR did not touch any significant files', async () => {
|
||||||
bvGetSignificantFilesChangedSpy.and.resolveTo(false);
|
bvGetSignificantFilesChangedSpy.and.returnValue(Promise.resolve(false));
|
||||||
|
|
||||||
const expectedResponse = {canHavePublicPreview: false, reason: 'No significant files touched.'};
|
const expectedResponse = {canHavePublicPreview: false, reason: 'No significant files touched.'};
|
||||||
const expectedLog = `PR:${pr} - Cannot have a public preview, because it did not touch any significant files.`;
|
const expectedLog = `PR:${pr} - Cannot have a public preview, because it did not touch any significant files.`;
|
||||||
@ -343,7 +345,7 @@ describe('PreviewServerFactory', () => {
|
|||||||
|
|
||||||
|
|
||||||
it('should respond appropriately if the PR is not automatically verifiable as "trusted"', async () => {
|
it('should respond appropriately if the PR is not automatically verifiable as "trusted"', async () => {
|
||||||
bvGetPrIsTrustedSpy.and.resolveTo(false);
|
bvGetPrIsTrustedSpy.and.returnValue(Promise.resolve(false));
|
||||||
|
|
||||||
const expectedResponse = {canHavePublicPreview: false, reason: 'Not automatically verifiable as "trusted".'};
|
const expectedResponse = {canHavePublicPreview: false, reason: 'Not automatically verifiable as "trusted".'};
|
||||||
const expectedLog =
|
const expectedLog =
|
||||||
@ -370,7 +372,7 @@ describe('PreviewServerFactory', () => {
|
|||||||
|
|
||||||
|
|
||||||
it('should respond with error if `getSignificantFilesChanged()` fails', async () => {
|
it('should respond with error if `getSignificantFilesChanged()` fails', async () => {
|
||||||
bvGetSignificantFilesChangedSpy.and.rejectWith('getSignificantFilesChanged error');
|
bvGetSignificantFilesChangedSpy.and.callFake(() => Promise.reject('getSignificantFilesChanged error'));
|
||||||
|
|
||||||
await agent.get(url).expect(500, 'getSignificantFilesChanged error');
|
await agent.get(url).expect(500, 'getSignificantFilesChanged error');
|
||||||
expect(loggerErrorSpy).toHaveBeenCalledWith('Previewability check error', 'getSignificantFilesChanged error');
|
expect(loggerErrorSpy).toHaveBeenCalledWith('Previewability check error', 'getSignificantFilesChanged error');
|
||||||
@ -378,10 +380,11 @@ describe('PreviewServerFactory', () => {
|
|||||||
|
|
||||||
|
|
||||||
it('should respond with error if `getPrIsTrusted()` fails', async () => {
|
it('should respond with error if `getPrIsTrusted()` fails', async () => {
|
||||||
bvGetPrIsTrustedSpy.and.throwError('getPrIsTrusted error');
|
const error = new Error('getPrIsTrusted error');
|
||||||
|
bvGetPrIsTrustedSpy.and.callFake(() => { throw error; });
|
||||||
|
|
||||||
await agent.get(url).expect(500, 'getPrIsTrusted error');
|
await agent.get(url).expect(500, 'getPrIsTrusted error');
|
||||||
expect(loggerErrorSpy).toHaveBeenCalledWith('Previewability check error', new Error('getPrIsTrusted error'));
|
expect(loggerErrorSpy).toHaveBeenCalledWith('Previewability check error', error);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -494,7 +497,7 @@ describe('PreviewServerFactory', () => {
|
|||||||
// Note it is important to put the `reject` into `and.callFake`;
|
// Note it is important to put the `reject` into `and.callFake`;
|
||||||
// If you just `and.returnValue` the rejected promise
|
// If you just `and.returnValue` the rejected promise
|
||||||
// then you get an "unhandled rejection" message in the console.
|
// then you get an "unhandled rejection" message in the console.
|
||||||
getGithubInfoSpy.and.rejectWith('Test Error');
|
getGithubInfoSpy.and.callFake(() => Promise.reject('Test Error'));
|
||||||
await agent.post(URL).send(BASIC_PAYLOAD).expect(500, 'Test Error');
|
await agent.post(URL).send(BASIC_PAYLOAD).expect(500, 'Test Error');
|
||||||
expect(getGithubInfoSpy).toHaveBeenCalledWith(BUILD_NUM);
|
expect(getGithubInfoSpy).toHaveBeenCalledWith(BUILD_NUM);
|
||||||
expect(downloadBuildArtifactSpy).not.toHaveBeenCalled();
|
expect(downloadBuildArtifactSpy).not.toHaveBeenCalled();
|
||||||
@ -515,7 +518,7 @@ describe('PreviewServerFactory', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should fail if the artifact fetch request fails', async () => {
|
it('should fail if the artifact fetch request fails', async () => {
|
||||||
downloadBuildArtifactSpy.and.rejectWith('Test Error');
|
downloadBuildArtifactSpy.and.callFake(() => Promise.reject('Test Error'));
|
||||||
await agent.post(URL).send(BASIC_PAYLOAD).expect(500, 'Test Error');
|
await agent.post(URL).send(BASIC_PAYLOAD).expect(500, 'Test Error');
|
||||||
expect(getGithubInfoSpy).toHaveBeenCalledWith(BUILD_NUM);
|
expect(getGithubInfoSpy).toHaveBeenCalledWith(BUILD_NUM);
|
||||||
expect(downloadBuildArtifactSpy).toHaveBeenCalled();
|
expect(downloadBuildArtifactSpy).toHaveBeenCalled();
|
||||||
@ -524,7 +527,7 @@ describe('PreviewServerFactory', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should fail if verifying the PR fails', async () => {
|
it('should fail if verifying the PR fails', async () => {
|
||||||
getPrIsTrustedSpy.and.rejectWith('Test Error');
|
getPrIsTrustedSpy.and.callFake(() => Promise.reject('Test Error'));
|
||||||
await agent.post(URL).send(BASIC_PAYLOAD).expect(500, 'Test Error');
|
await agent.post(URL).send(BASIC_PAYLOAD).expect(500, 'Test Error');
|
||||||
expect(getGithubInfoSpy).toHaveBeenCalledWith(BUILD_NUM);
|
expect(getGithubInfoSpy).toHaveBeenCalledWith(BUILD_NUM);
|
||||||
expect(downloadBuildArtifactSpy).toHaveBeenCalled();
|
expect(downloadBuildArtifactSpy).toHaveBeenCalled();
|
||||||
@ -533,7 +536,7 @@ describe('PreviewServerFactory', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should fail if creating the preview build fails', async () => {
|
it('should fail if creating the preview build fails', async () => {
|
||||||
createBuildSpy.and.rejectWith('Test Error');
|
createBuildSpy.and.callFake(() => Promise.reject('Test Error'));
|
||||||
await agent.post(URL).send(BASIC_PAYLOAD).expect(500, 'Test Error');
|
await agent.post(URL).send(BASIC_PAYLOAD).expect(500, 'Test Error');
|
||||||
expect(getGithubInfoSpy).toHaveBeenCalledWith(BUILD_NUM);
|
expect(getGithubInfoSpy).toHaveBeenCalledWith(BUILD_NUM);
|
||||||
expect(downloadBuildArtifactSpy).toHaveBeenCalled();
|
expect(downloadBuildArtifactSpy).toHaveBeenCalled();
|
||||||
@ -602,7 +605,7 @@ describe('PreviewServerFactory', () => {
|
|||||||
|
|
||||||
|
|
||||||
it('should propagate errors from BuildVerifier', async () => {
|
it('should propagate errors from BuildVerifier', async () => {
|
||||||
bvGetPrIsTrustedSpy.and.rejectWith('Test');
|
bvGetPrIsTrustedSpy.and.callFake(() => Promise.reject('Test'));
|
||||||
|
|
||||||
await createRequest(+pr).expect(500, 'Test');
|
await createRequest(+pr).expect(500, 'Test');
|
||||||
|
|
||||||
@ -612,9 +615,7 @@ describe('PreviewServerFactory', () => {
|
|||||||
|
|
||||||
|
|
||||||
it('should call \'BuildCreator#updatePrVisibility()\' with the correct arguments', async () => {
|
it('should call \'BuildCreator#updatePrVisibility()\' with the correct arguments', async () => {
|
||||||
bvGetPrIsTrustedSpy.
|
bvGetPrIsTrustedSpy.and.callFake((pr2: number) => Promise.resolve(pr2 === 42));
|
||||||
withArgs(24).and.resolveTo(false).
|
|
||||||
withArgs(42).and.resolveTo(true);
|
|
||||||
|
|
||||||
await createRequest(24);
|
await createRequest(24);
|
||||||
expect(bcUpdatePrVisibilitySpy).toHaveBeenCalledWith(24, false);
|
expect(bcUpdatePrVisibilitySpy).toHaveBeenCalledWith(24, false);
|
||||||
@ -625,7 +626,7 @@ describe('PreviewServerFactory', () => {
|
|||||||
|
|
||||||
|
|
||||||
it('should propagate errors from BuildCreator', async () => {
|
it('should propagate errors from BuildCreator', async () => {
|
||||||
bcUpdatePrVisibilitySpy.and.rejectWith('Test');
|
bcUpdatePrVisibilitySpy.and.callFake(() => Promise.reject('Test'));
|
||||||
await createRequest(+pr).expect(500, 'Test');
|
await createRequest(+pr).expect(500, 'Test');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -633,9 +634,7 @@ describe('PreviewServerFactory', () => {
|
|||||||
describe('on success', () => {
|
describe('on success', () => {
|
||||||
|
|
||||||
it('should respond with 200 (action: undefined)', async () => {
|
it('should respond with 200 (action: undefined)', async () => {
|
||||||
bvGetPrIsTrustedSpy.
|
bvGetPrIsTrustedSpy.and.returnValues(Promise.resolve(true), Promise.resolve(false));
|
||||||
withArgs(2).and.resolveTo(false).
|
|
||||||
withArgs(4).and.resolveTo(true);
|
|
||||||
|
|
||||||
const reqs = [4, 2].map(num => createRequest(num).expect(200, http.STATUS_CODES[200]));
|
const reqs = [4, 2].map(num => createRequest(num).expect(200, http.STATUS_CODES[200]));
|
||||||
await Promise.all(reqs);
|
await Promise.all(reqs);
|
||||||
@ -643,9 +642,7 @@ describe('PreviewServerFactory', () => {
|
|||||||
|
|
||||||
|
|
||||||
it('should respond with 200 (action: labeled)', async () => {
|
it('should respond with 200 (action: labeled)', async () => {
|
||||||
bvGetPrIsTrustedSpy.
|
bvGetPrIsTrustedSpy.and.returnValues(Promise.resolve(true), Promise.resolve(false));
|
||||||
withArgs(2).and.resolveTo(false).
|
|
||||||
withArgs(4).and.resolveTo(true);
|
|
||||||
|
|
||||||
const reqs = [4, 2].map(num => createRequest(num, 'labeled').expect(200, http.STATUS_CODES[200]));
|
const reqs = [4, 2].map(num => createRequest(num, 'labeled').expect(200, http.STATUS_CODES[200]));
|
||||||
await Promise.all(reqs);
|
await Promise.all(reqs);
|
||||||
@ -653,9 +650,7 @@ describe('PreviewServerFactory', () => {
|
|||||||
|
|
||||||
|
|
||||||
it('should respond with 200 (action: unlabeled)', async () => {
|
it('should respond with 200 (action: unlabeled)', async () => {
|
||||||
bvGetPrIsTrustedSpy.
|
bvGetPrIsTrustedSpy.and.returnValues(Promise.resolve(true), Promise.resolve(false));
|
||||||
withArgs(2).and.resolveTo(false).
|
|
||||||
withArgs(4).and.resolveTo(true);
|
|
||||||
|
|
||||||
const reqs = [4, 2].map(num => createRequest(num, 'unlabeled').expect(200, http.STATUS_CODES[200]));
|
const reqs = [4, 2].map(num => createRequest(num, 'unlabeled').expect(200, http.STATUS_CODES[200]));
|
||||||
await Promise.all(reqs);
|
await Promise.all(reqs);
|
||||||
|
@ -39,7 +39,7 @@ describe('preview-server/utils', () => {
|
|||||||
throwRequestError(505, 'ERROR MESSAGE', request);
|
throwRequestError(505, 'ERROR MESSAGE', request);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
caught = true;
|
caught = true;
|
||||||
expect(error).toBeInstanceOf(PreviewServerError);
|
expect(error).toEqual(jasmine.any(PreviewServerError));
|
||||||
expect(error.status).toEqual(505);
|
expect(error.status).toEqual(505);
|
||||||
expect(error.message).toEqual(`ERROR MESSAGE in request: POST some.domain.com/path "The request body"`);
|
expect(error.message).toEqual(`ERROR MESSAGE in request: POST some.domain.com/path "The request body"`);
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -8,32 +8,10 @@ exitCode=0
|
|||||||
|
|
||||||
|
|
||||||
# Helpers
|
# Helpers
|
||||||
function checkCert {
|
|
||||||
local certPath=$1
|
|
||||||
|
|
||||||
if [[ ! -f "$certPath" ]]; then
|
|
||||||
echo "Certificate '$certPath' does not exist. Skipping expiration check..."
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
openssl x509 -checkend 0 -in "$certPath" -noout > /dev/null
|
|
||||||
reportStatus "Certificate '$certPath'"
|
|
||||||
|
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
echo " [WARN]"
|
|
||||||
echo " If you did not provide the certificate explicitly, try running the"
|
|
||||||
echo " 'docker build' command again with the '--no-cache' option to generate"
|
|
||||||
echo " a new self-signed certificate."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function reportStatus {
|
function reportStatus {
|
||||||
local lastExitCode=$?
|
local lastExitCode=$?
|
||||||
|
|
||||||
echo "$1: $([[ $lastExitCode -eq 0 ]] && echo OK || echo NOT OK)"
|
echo "$1: $([[ $lastExitCode -eq 0 ]] && echo OK || echo NOT OK)"
|
||||||
[[ $lastExitCode -eq 0 ]] || exitCode=1
|
[[ $lastExitCode -eq 0 ]] || exitCode=1
|
||||||
|
|
||||||
return $lastExitCode
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -50,16 +28,6 @@ for s in ${services[@]}; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
# Check SSL/TLS certificates expiration
|
|
||||||
certs=(
|
|
||||||
"$AIO_LOCALCERTS_DIR/$AIO_DOMAIN_NAME.crt"
|
|
||||||
"$TEST_AIO_LOCALCERTS_DIR/$TEST_AIO_DOMAIN_NAME.crt"
|
|
||||||
)
|
|
||||||
for c in ${certs[@]}; do
|
|
||||||
checkCert $c
|
|
||||||
done
|
|
||||||
|
|
||||||
|
|
||||||
# Check servers
|
# Check servers
|
||||||
origins=(
|
origins=(
|
||||||
http://$AIO_PREVIEW_SERVER_HOSTNAME:$AIO_PREVIEW_SERVER_PORT
|
http://$AIO_PREVIEW_SERVER_HOSTNAME:$AIO_PREVIEW_SERVER_PORT
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
## Create `aio-builds` persistent disk (if not already exists)
|
## Create `aio-builds` persistent disk (if not already exists)
|
||||||
- Follow instructions [here](https://cloud.google.com/compute/docs/disks/add-persistent-disk#create_disk).
|
- Follow instructions [here](https://cloud.google.com/compute/docs/disks/add-persistent-disk#create_disk).
|
||||||
- `sudo mkfs.ext4 -m 0 -E lazy_itable_init=0,lazy_journal_init=0,discard /dev/disk/by-id/google-aio-builds`
|
- `sudo mkfs.ext4 -F -E lazy_itable_init=0,lazy_journal_init=0,discard /dev/disk/by-id/google-aio-builds`
|
||||||
|
|
||||||
|
|
||||||
## Mount disk
|
## Mount disk
|
||||||
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
## Mount disk on boot
|
## Mount disk on boot
|
||||||
- Run:
|
- Run:
|
||||||
```sh
|
```
|
||||||
echo UUID=`sudo blkid -s UUID -o value /dev/disk/by-id/google-aio-builds` \
|
echo UUID=`sudo blkid -s UUID -o value /dev/disk/by-id/google-aio-builds` \
|
||||||
/mnt/disks/aio-builds ext4 defaults,discard,nofail 0 2 | sudo tee -a /etc/fstab
|
/mnt/disks/aio-builds ext4 discard,defaults,nofail 0 2 | sudo tee -a /etc/fstab
|
||||||
```
|
```
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
# VM setup - Create docker image
|
# VM setup - Create docker image
|
||||||
|
|
||||||
|
|
||||||
## Install git, Node.js and yarn
|
## Install node and yarn
|
||||||
- `sudo apt-get update`
|
- Install [nvm](https://github.com/creationix/nvm#installation).
|
||||||
- `sudo apt-get install -y git`
|
- Install node.js: `nvm install 8`
|
||||||
- Install the latest stable version of [Node.js](https://nodejs.org/en/download).
|
- Install yarn: `npm -g install yarn`
|
||||||
- Install the latest stable version of [yarn](https://classic.yarnpkg.com/en/docs/install).
|
|
||||||
|
|
||||||
|
|
||||||
## Checkout repository
|
## Checkout repository
|
||||||
@ -17,11 +16,7 @@
|
|||||||
- You can overwrite the default environment variables inside the image, by passing new values using
|
- You can overwrite the default environment variables inside the image, by passing new values using
|
||||||
`--build-arg`.
|
`--build-arg`.
|
||||||
|
|
||||||
**Note 1:** The script has to execute docker commands with `sudo`.
|
**Note:** The script has to execute docker commands with `sudo`.
|
||||||
|
|
||||||
**Note 2:**
|
|
||||||
The script has to execute `yarn` commands, so make sure `yarn` is on the `PATH` when invoking the
|
|
||||||
script.
|
|
||||||
|
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
@ -31,7 +26,7 @@ The following commands would create a docker image from GitHub repo `foo/bar` to
|
|||||||
|
|
||||||
- `git clone https://github.com/foo/bar.git foobar`
|
- `git clone https://github.com/foo/bar.git foobar`
|
||||||
- Run:
|
- Run:
|
||||||
```sh
|
```
|
||||||
./foobar/aio-builds-setup/scripts/create-image.sh foobar-builds \
|
./foobar/aio-builds-setup/scripts/create-image.sh foobar-builds \
|
||||||
--build-arg AIO_REPO_SLUG=foo/bar \
|
--build-arg AIO_REPO_SLUG=foo/bar \
|
||||||
--build-arg AIO_DOMAIN_NAME=foobar-builds.io \
|
--build-arg AIO_DOMAIN_NAME=foobar-builds.io \
|
||||||
|
@ -3,17 +3,24 @@
|
|||||||
|
|
||||||
## Install docker
|
## Install docker
|
||||||
|
|
||||||
Official installation instructions: https://docs.docker.com/engine/install
|
_Debian (jessie):_
|
||||||
Example:
|
- `sudo apt-get update`
|
||||||
|
- `sudo apt-get install -y apt-transport-https ca-certificates curl git software-properties-common`
|
||||||
|
- `curl -fsSL https://apt.dockerproject.org/gpg | sudo apt-key add -`
|
||||||
|
- `apt-key fingerprint 58118E89F3A912897C070ADBF76221572C52609D`
|
||||||
|
- `sudo add-apt-repository "deb https://apt.dockerproject.org/repo/ debian-$(lsb_release -cs) main"`
|
||||||
|
- `sudo apt-get update`
|
||||||
|
- `sudo apt-get -y install docker-engine`
|
||||||
|
|
||||||
_Debian (buster):_
|
_Ubuntu (16.04):_
|
||||||
- `sudo apt-get update`
|
- `sudo apt-get update`
|
||||||
- `sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common`
|
- `sudo apt-get install -y curl git linux-image-extra-$(uname -r) linux-image-extra-virtual`
|
||||||
- `curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -`
|
- `sudo apt-get install -y apt-transport-https ca-certificates`
|
||||||
- `sudo apt-key fingerprint 0EBFCD88`
|
- `curl -fsSL https://yum.dockerproject.org/gpg | sudo apt-key add -`
|
||||||
- `sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"`
|
- `apt-key fingerprint 58118E89F3A912897C070ADBF76221572C52609D`
|
||||||
|
- `sudo add-apt-repository "deb https://apt.dockerproject.org/repo/ ubuntu-$(lsb_release -cs) main"`
|
||||||
- `sudo apt-get update`
|
- `sudo apt-get update`
|
||||||
- `sudo apt-get -y install docker-ce docker-ce-cli containerd.io`
|
- `sudo apt-get -y install docker-engine`
|
||||||
|
|
||||||
|
|
||||||
## Start the docker
|
## Start the docker
|
||||||
|
@ -8,16 +8,16 @@ VM host to update the preview server based on changes in the source code.
|
|||||||
|
|
||||||
The script will pull the latest changes from the origin's master branch and examine if there have
|
The script will pull the latest changes from the origin's master branch and examine if there have
|
||||||
been any changes in files inside the preview server source code directory (see below). If there are,
|
been any changes in files inside the preview server source code directory (see below). If there are,
|
||||||
it will create a new image and verify that it works as expected. Finally, it will stop and remove
|
it will create a new image and verify that is works as expected. Finally, it will stop and remove
|
||||||
the old docker container and image, create a new container based on the new image and start it.
|
the old docker container and image, create a new container based on the new image and start it.
|
||||||
|
|
||||||
The script assumes that the preview server source code is in the repository's
|
The script assumes that the preview server source code is in the repository's
|
||||||
`aio/aio-builds-setup/` directory and expects the following inputs:
|
`aio/aio-builds-setup/` directory and expects the following inputs:
|
||||||
|
|
||||||
- **$1**: `HOST_REPO_DIR`
|
- **$1**: `HOST_REPO_DIR`
|
||||||
- **$2**: `HOST_SECRETS_DIR`
|
- **$2**: `HOST_LOCALCERTS_DIR`
|
||||||
- **$3**: `HOST_BUILDS_DIR`
|
- **$3**: `HOST_SECRETS_DIR`
|
||||||
- **$4**: `HOST_LOCALCERTS_DIR`
|
- **$4**: `HOST_BUILDS_DIR`
|
||||||
- **$5**: `HOST_LOGS_DIR`
|
- **$5**: `HOST_LOGS_DIR`
|
||||||
|
|
||||||
See [here](vm-setup--create-host-dirs-and-files.md) for more info on what each input directory is
|
See [here](vm-setup--create-host-dirs-and-files.md) for more info on what each input directory is
|
||||||
@ -25,38 +25,28 @@ used for.
|
|||||||
|
|
||||||
**Note 1:** The script has to execute docker commands with `sudo`.
|
**Note 1:** The script has to execute docker commands with `sudo`.
|
||||||
|
|
||||||
**Note 2:**
|
**Note 2:** Make sure the user that executes the script has access to update the repository
|
||||||
The script has to execute `yarn` commands, so make sure `yarn` is on the `PATH` when invoking the
|
|
||||||
script.
|
|
||||||
|
|
||||||
**Note 3:** Make sure the user that executes the script has access to update the repository.
|
|
||||||
|
|
||||||
|
|
||||||
## Run the script manually
|
## Run the script manually
|
||||||
You may choose to manually run the script, when necessary. Example:
|
You may choose to manually run the script, when necessary. Example:
|
||||||
|
|
||||||
```sh
|
```
|
||||||
update-preview-server.sh \
|
update-preview-server.sh \
|
||||||
/path/to/repo \
|
/path/to/repo \
|
||||||
|
/path/to/localcerts \
|
||||||
/path/to/secrets \
|
/path/to/secrets \
|
||||||
/path/to/builds \
|
/path/to/builds \
|
||||||
/path/to/localcerts \
|
|
||||||
/path/to/logs
|
/path/to/logs
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Run the script automatically
|
## Run the script automatically
|
||||||
You may choose to automatically trigger the script, e.g. using a cronjob. For example, the following
|
You may choose to automatically trigger the script, e.g. using a cronjob. For example, the following
|
||||||
cronjob entry would run the script every 30 minutes, update the preview server (if necessary) and
|
cronjob entry would run the script every hour and update the preview server (assuming the user has
|
||||||
log its output to `update-preview-server.log` (assuming the user has the necessary permissions):
|
the necessary permissions):
|
||||||
|
|
||||||
```
|
```
|
||||||
# Periodically check for changes and update the preview server (if necessary)
|
# Periodically check for changes and update the preview server (if necessary)
|
||||||
*/30 * * * * /path/to/update-preview-server.sh /path/to/repo /path/to/secrets /path/to/builds /path/to/localcerts /path/to/logs >> /path/to/update-preview-server.log 2>&1
|
*/30 * * * * /path/to/update-preview-server.sh /path/to/repo /path/to/localcerts /path/to/secrets /path/to/builds /path/to/logs
|
||||||
```
|
```
|
||||||
|
|
||||||
**Note:**
|
|
||||||
Keep in mind that cron jobs run in non-interactive, non-login shells. This means that the execution
|
|
||||||
context might be different compared to when running the same commands from an interactive, login
|
|
||||||
shell. For example, `.bashrc` files are normally _not_ sourced automatically in cron jobs. See
|
|
||||||
[here](http://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html) for more info.
|
|
||||||
|
@ -7,14 +7,13 @@ echo -e "\n\n[`date`] - Updating the preview server..."
|
|||||||
|
|
||||||
# Input
|
# Input
|
||||||
readonly HOST_REPO_DIR=$1
|
readonly HOST_REPO_DIR=$1
|
||||||
readonly HOST_SECRETS_DIR=$2
|
readonly HOST_LOCALCERTS_DIR=$2
|
||||||
readonly HOST_BUILDS_DIR=$3
|
readonly HOST_SECRETS_DIR=$3
|
||||||
readonly HOST_LOCALCERTS_DIR=$4
|
readonly HOST_BUILDS_DIR=$4
|
||||||
readonly HOST_LOGS_DIR=$5
|
readonly HOST_LOGS_DIR=$5
|
||||||
|
|
||||||
# Constants
|
# Constants
|
||||||
readonly PROVISIONAL_TAG=provisional
|
readonly PROVISIONAL_IMAGE_NAME=aio-builds:provisional
|
||||||
readonly PROVISIONAL_IMAGE_NAME=aio-builds:$PROVISIONAL_TAG
|
|
||||||
readonly LATEST_IMAGE_NAME=aio-builds:latest
|
readonly LATEST_IMAGE_NAME=aio-builds:latest
|
||||||
readonly CONTAINER_NAME=aio
|
readonly CONTAINER_NAME=aio
|
||||||
|
|
||||||
@ -31,7 +30,7 @@ readonly CONTAINER_NAME=aio
|
|||||||
# Do not update the server unless files inside `aio-builds-setup/` have changed
|
# Do not update the server unless files inside `aio-builds-setup/` have changed
|
||||||
# or the last attempt failed (identified by the provisional image still being around).
|
# or the last attempt failed (identified by the provisional image still being around).
|
||||||
readonly relevantChangedFilesCount=$(git diff --name-only $lastDeployedCommit...HEAD | grep -P "^aio/aio-builds-setup/" | wc -l)
|
readonly relevantChangedFilesCount=$(git diff --name-only $lastDeployedCommit...HEAD | grep -P "^aio/aio-builds-setup/" | wc -l)
|
||||||
readonly lastAttemptFailed=$(sudo docker image ls | grep "$PROVISIONAL_TAG" >> /dev/fd/3 && echo "true" || echo "false")
|
readonly lastAttemptFailed=$(sudo docker rmi "$PROVISIONAL_IMAGE_NAME" >> /dev/fd/3 && echo "true" || echo "false")
|
||||||
if [[ $relevantChangedFilesCount -eq 0 ]] && [[ "$lastAttemptFailed" != "true" ]]; then
|
if [[ $relevantChangedFilesCount -eq 0 ]] && [[ "$lastAttemptFailed" != "true" ]]; then
|
||||||
echo "Skipping update because no relevant files have been touched."
|
echo "Skipping update because no relevant files have been touched."
|
||||||
exit 0
|
exit 0
|
||||||
@ -61,9 +60,9 @@ readonly CONTAINER_NAME=aio
|
|||||||
--publish 80:80 \
|
--publish 80:80 \
|
||||||
--publish 443:443 \
|
--publish 443:443 \
|
||||||
--restart unless-stopped \
|
--restart unless-stopped \
|
||||||
|
--volume $HOST_LOCALCERTS_DIR:/etc/ssl/localcerts:ro \
|
||||||
--volume $HOST_SECRETS_DIR:/aio-secrets:ro \
|
--volume $HOST_SECRETS_DIR:/aio-secrets:ro \
|
||||||
--volume $HOST_BUILDS_DIR:/var/www/aio-builds \
|
--volume $HOST_BUILDS_DIR:/var/www/aio-builds \
|
||||||
--volume $HOST_LOCALCERTS_DIR:/etc/ssl/localcerts:ro \
|
|
||||||
--volume $HOST_LOGS_DIR:/var/log/aio \
|
--volume $HOST_LOGS_DIR:/var/log/aio \
|
||||||
"$LATEST_IMAGE_NAME"
|
"$LATEST_IMAGE_NAME"
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"styles": [
|
"styles": [
|
||||||
"src/styles/main.scss"
|
"src/styles.scss"
|
||||||
],
|
],
|
||||||
"scripts": [],
|
"scripts": [],
|
||||||
"budgets": [
|
"budgets": [
|
||||||
@ -158,7 +158,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"styles": [
|
"styles": [
|
||||||
"src/styles/main.scss"
|
"src/styles.scss"
|
||||||
],
|
],
|
||||||
"scripts": []
|
"scripts": []
|
||||||
}
|
}
|
||||||
@ -193,4 +193,4 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"defaultProject": "site"
|
"defaultProject": "site"
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
# CLI Overview and Command Reference
|
# CLI Overview and Command Reference
|
||||||
|
|
||||||
The Angular CLI is a command-line interface tool that you use to initialize, develop, scaffold, and maintain Angular applications directly from a command shell.
|
The Angular CLI is a command-line interface tool that you use to initialize, develop, scaffold, and maintain Angular applications. You can use the tool directly in a command shell, or indirectly through an interactive UI such as [Angular Console](https://angularconsole.com).
|
||||||
|
|
||||||
## Installing Angular CLI
|
## Installing Angular CLI
|
||||||
|
|
||||||
@ -109,3 +109,9 @@ Options that specify files can be given as absolute paths, or as paths relative
|
|||||||
The [ng generate](cli/generate) and [ng add](cli/add) commands take as an argument the artifact or library to be generated or added to the current project.
|
The [ng generate](cli/generate) and [ng add](cli/add) commands take as an argument the artifact or library to be generated or added to the current project.
|
||||||
In addition to any general options, each artifact or library defines its own options in a *schematic*.
|
In addition to any general options, each artifact or library defines its own options in a *schematic*.
|
||||||
Schematic options are supplied to the command in the same format as immediate command options.
|
Schematic options are supplied to the command in the same format as immediate command options.
|
||||||
|
|
||||||
|
|
||||||
|
### Building with Bazel
|
||||||
|
|
||||||
|
Optionally, you can configure the Angular CLI to use [Bazel](https://docs.bazel.build) as the build tool. For more information, see [Building with Bazel](guide/bazel).
|
||||||
|
|
||||||
|
@ -32,15 +32,15 @@ export const slideInAnimation =
|
|||||||
// #enddocregion style-view
|
// #enddocregion style-view
|
||||||
// #docregion query
|
// #docregion query
|
||||||
query(':enter', [
|
query(':enter', [
|
||||||
style({ left: '-100%' })
|
style({ left: '-100%'})
|
||||||
]),
|
]),
|
||||||
query(':leave', animateChild()),
|
query(':leave', animateChild()),
|
||||||
group([
|
group([
|
||||||
query(':leave', [
|
query(':leave', [
|
||||||
animate('300ms ease-out', style({ left: '100%' }))
|
animate('300ms ease-out', style({ left: '100%'}))
|
||||||
]),
|
]),
|
||||||
query(':enter', [
|
query(':enter', [
|
||||||
animate('300ms ease-out', style({ left: '0%' }))
|
animate('300ms ease-out', style({ left: '0%'}))
|
||||||
])
|
])
|
||||||
]),
|
]),
|
||||||
query(':enter', animateChild()),
|
query(':enter', animateChild()),
|
||||||
@ -56,15 +56,15 @@ export const slideInAnimation =
|
|||||||
})
|
})
|
||||||
]),
|
]),
|
||||||
query(':enter', [
|
query(':enter', [
|
||||||
style({ left: '-100%' })
|
style({ left: '-100%'})
|
||||||
]),
|
]),
|
||||||
query(':leave', animateChild()),
|
query(':leave', animateChild()),
|
||||||
group([
|
group([
|
||||||
query(':leave', [
|
query(':leave', [
|
||||||
animate('200ms ease-out', style({ left: '100%' }))
|
animate('200ms ease-out', style({ left: '100%'}))
|
||||||
]),
|
]),
|
||||||
query(':enter', [
|
query(':enter', [
|
||||||
animate('300ms ease-out', style({ left: '0%' }))
|
animate('300ms ease-out', style({ left: '0%'}))
|
||||||
])
|
])
|
||||||
]),
|
]),
|
||||||
query(':enter', animateChild()),
|
query(':enter', animateChild()),
|
||||||
|
@ -17,7 +17,7 @@ Toggle All Animations <input type="checkbox" [checked]="!animationsDisabled" (cl
|
|||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<!-- #docregion route-animations-outlet -->
|
<!-- #docregion route-animations-outlet -->
|
||||||
<div [@routeAnimations]="prepareRoute(outlet)">
|
<div [@routeAnimations]="prepareRoute(outlet)" >
|
||||||
<router-outlet #outlet="outlet"></router-outlet>
|
<router-outlet #outlet="outlet"></router-outlet>
|
||||||
</div>
|
</div>
|
||||||
<!-- #enddocregion route-animations-outlet -->
|
<!-- #enddocregion route-animations-outlet -->
|
||||||
|
@ -3,7 +3,7 @@ import { NgModule } from '@angular/core';
|
|||||||
import { BrowserModule } from '@angular/platform-browser';
|
import { BrowserModule } from '@angular/platform-browser';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
|
|
||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
import { HeroFormComponent } from './hero-form/hero-form.component';
|
import { HeroFormComponent } from './hero-form/hero-form.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
@ -200,4 +200,13 @@
|
|||||||
(ngModelChange)="model.name = $event">
|
(ngModelChange)="model.name = $event">
|
||||||
TODO: remove this: {{model.name}}
|
TODO: remove this: {{model.name}}
|
||||||
<!-- #enddocregion ngModel-3-->
|
<!-- #enddocregion ngModel-3-->
|
||||||
|
<hr>
|
||||||
|
<!-- #docregion ngModelName-2 -->
|
||||||
|
<input type="text" class="form-control" id="name"
|
||||||
|
required
|
||||||
|
[(ngModel)]="model.name" name="name"
|
||||||
|
#spy>
|
||||||
|
<br>TODO: remove this: {{spy.className}}
|
||||||
|
<!-- #enddocregion ngModelName-2 -->
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// #docregion , v1, final
|
// #docregion , v1, final
|
||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
|
|
||||||
import { Hero } from '../hero';
|
import { Hero } from '../hero';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-hero-form',
|
selector: 'app-hero-form',
|
||||||
|
@ -76,15 +76,15 @@ export class ConfigService {
|
|||||||
console.error('An error occurred:', error.error.message);
|
console.error('An error occurred:', error.error.message);
|
||||||
} else {
|
} else {
|
||||||
// The backend returned an unsuccessful response code.
|
// The backend returned an unsuccessful response code.
|
||||||
// The response body may contain clues as to what went wrong.
|
// The response body may contain clues as to what went wrong,
|
||||||
console.error(
|
console.error(
|
||||||
`Backend returned code ${error.status}, ` +
|
`Backend returned code ${error.status}, ` +
|
||||||
`body was: ${error.error}`);
|
`body was: ${error.error}`);
|
||||||
}
|
}
|
||||||
// Return an observable with a user-facing error message.
|
// return an observable with a user-facing error message
|
||||||
return throwError(
|
return throwError(
|
||||||
'Something bad happened; please try again later.');
|
'Something bad happened; please try again later.');
|
||||||
}
|
};
|
||||||
// #enddocregion handleError
|
// #enddocregion handleError
|
||||||
|
|
||||||
makeIntentionalError() {
|
makeIntentionalError() {
|
||||||
|
@ -13,13 +13,13 @@ import { searchUrl } from '../package-search/package-search.service';
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If request is cacheable (e.g., package search) and
|
* If request is cachable (e.g., package search) and
|
||||||
* response is in cache return the cached response as observable.
|
* response is in cache return the cached response as observable.
|
||||||
* If has 'x-refresh' header that is true,
|
* If has 'x-refresh' header that is true,
|
||||||
* then also re-run the package search, using response from next(),
|
* then also re-run the package search, using response from next(),
|
||||||
* returning an observable that emits the cached response first.
|
* returning an observable that emits the cached response first.
|
||||||
*
|
*
|
||||||
* If not in cache or not cacheable,
|
* If not in cache or not cachable,
|
||||||
* pass request through to next()
|
* pass request through to next()
|
||||||
*/
|
*/
|
||||||
// #docregion v1
|
// #docregion v1
|
||||||
@ -28,8 +28,8 @@ export class CachingInterceptor implements HttpInterceptor {
|
|||||||
constructor(private cache: RequestCache) {}
|
constructor(private cache: RequestCache) {}
|
||||||
|
|
||||||
intercept(req: HttpRequest<any>, next: HttpHandler) {
|
intercept(req: HttpRequest<any>, next: HttpHandler) {
|
||||||
// continue if not cacheable.
|
// continue if not cachable.
|
||||||
if (!isCacheable(req)) { return next.handle(req); }
|
if (!isCachable(req)) { return next.handle(req); }
|
||||||
|
|
||||||
const cachedResponse = this.cache.get(req);
|
const cachedResponse = this.cache.get(req);
|
||||||
// #enddocregion v1
|
// #enddocregion v1
|
||||||
@ -51,11 +51,11 @@ export class CachingInterceptor implements HttpInterceptor {
|
|||||||
// #enddocregion v1
|
// #enddocregion v1
|
||||||
|
|
||||||
|
|
||||||
/** Is this request cacheable? */
|
/** Is this request cachable? */
|
||||||
function isCacheable(req: HttpRequest<any>) {
|
function isCachable(req: HttpRequest<any>) {
|
||||||
// Only GET requests are cacheable
|
// Only GET requests are cachable
|
||||||
return req.method === 'GET' &&
|
return req.method === 'GET' &&
|
||||||
// Only npm package search is cacheable in this app
|
// Only npm package search is cachable in this app
|
||||||
-1 < req.url.indexOf(searchUrl);
|
-1 < req.url.indexOf(searchUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"description": "i18n",
|
|
||||||
"files":[
|
|
||||||
"!**/*.d.ts",
|
|
||||||
"!**/*.js",
|
|
||||||
"!**/*.[0-9].*",
|
|
||||||
"!doc-files/**/*",
|
|
||||||
"**/*.xlf"
|
|
||||||
],
|
|
||||||
"file": "src/app/app.component.ts",
|
|
||||||
"tags": ["Angular", "i18n", "internationalization"]
|
|
||||||
}
|
|
9
aio/content/examples/i18n/zipper.json
Normal file
9
aio/content/examples/i18n/zipper.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"files": [
|
||||||
|
"!dist/",
|
||||||
|
"!**/*.d.ts",
|
||||||
|
"!src/**/*.js",
|
||||||
|
"!doc-files/**/*",
|
||||||
|
"**/*.xlf"
|
||||||
|
]
|
||||||
|
}
|
@ -3,7 +3,6 @@ import {
|
|||||||
AfterContentInit,
|
AfterContentInit,
|
||||||
AfterViewChecked,
|
AfterViewChecked,
|
||||||
AfterViewInit,
|
AfterViewInit,
|
||||||
Directive,
|
|
||||||
DoCheck,
|
DoCheck,
|
||||||
OnChanges,
|
OnChanges,
|
||||||
OnDestroy,
|
OnDestroy,
|
||||||
@ -16,8 +15,7 @@ import { LoggerService } from './logger.service';
|
|||||||
let nextId = 1;
|
let nextId = 1;
|
||||||
|
|
||||||
// #docregion ngOnInit
|
// #docregion ngOnInit
|
||||||
@Directive()
|
export class PeekABoo implements OnInit {
|
||||||
export class PeekABooDirective implements OnInit {
|
|
||||||
constructor(private logger: LoggerService) { }
|
constructor(private logger: LoggerService) { }
|
||||||
|
|
||||||
// implement OnInit's `ngOnInit` method
|
// implement OnInit's `ngOnInit` method
|
||||||
@ -36,7 +34,7 @@ export class PeekABooDirective implements OnInit {
|
|||||||
})
|
})
|
||||||
// Don't HAVE to mention the Lifecycle Hook interfaces
|
// Don't HAVE to mention the Lifecycle Hook interfaces
|
||||||
// unless we want typing and tool support.
|
// unless we want typing and tool support.
|
||||||
export class PeekABooComponent extends PeekABooDirective implements
|
export class PeekABooComponent extends PeekABoo implements
|
||||||
OnChanges, OnInit, DoCheck,
|
OnChanges, OnInit, DoCheck,
|
||||||
AfterContentInit, AfterContentChecked,
|
AfterContentInit, AfterContentChecked,
|
||||||
AfterViewInit, AfterViewChecked,
|
AfterViewInit, AfterViewChecked,
|
||||||
|
@ -23,7 +23,7 @@ export class GreetingModule {
|
|||||||
// #enddocregion ctor
|
// #enddocregion ctor
|
||||||
|
|
||||||
// #docregion for-root
|
// #docregion for-root
|
||||||
static forRoot(config: UserServiceConfig): ModuleWithProviders<GreetingModule> {
|
static forRoot(config: UserServiceConfig): ModuleWithProviders {
|
||||||
return {
|
return {
|
||||||
ngModule: GreetingModule,
|
ngModule: GreetingModule,
|
||||||
providers: [
|
providers: [
|
||||||
|
@ -6,5 +6,5 @@ import { Component } from '@angular/core';
|
|||||||
templateUrl: './app.component.html'
|
templateUrl: './app.component.html'
|
||||||
})
|
})
|
||||||
export class AppComponent {
|
export class AppComponent {
|
||||||
birthday = new Date(1988, 3, 15); // April 15, 1988 -- since month parameter is zero-based
|
birthday = new Date(1988, 3, 15); // April 15, 1988
|
||||||
}
|
}
|
||||||
|
@ -8,5 +8,5 @@ import { Component } from '@angular/core';
|
|||||||
// #enddocregion hero-birthday-template
|
// #enddocregion hero-birthday-template
|
||||||
})
|
})
|
||||||
export class HeroBirthdayComponent {
|
export class HeroBirthdayComponent {
|
||||||
birthday = new Date(1988, 3, 15); // April 15, 1988 -- since month parameter is zero-based
|
birthday = new Date(1988, 3, 15); // April 15, 1988
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import { Component } from '@angular/core';
|
|||||||
})
|
})
|
||||||
// #docregion class
|
// #docregion class
|
||||||
export class HeroBirthday2Component {
|
export class HeroBirthday2Component {
|
||||||
birthday = new Date(1988, 3, 15); // April 15, 1988 -- since month parameter is zero-based
|
birthday = new Date(1988, 3, 15); // April 15, 1988
|
||||||
toggle = true; // start with true == shortDate
|
toggle = true; // start with true == shortDate
|
||||||
|
|
||||||
get format() { return this.toggle ? 'shortDate' : 'fullDate'; }
|
get format() { return this.toggle ? 'shortDate' : 'fullDate'; }
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
import { Injectable } from '@angular/core';
|
|
||||||
|
|
||||||
@Injectable({
|
|
||||||
providedIn: 'any',
|
|
||||||
})
|
|
||||||
export class UserService {
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
import { browser, element, by } from 'protractor';
|
|
||||||
|
|
||||||
describe('Router basic tutorial e2e tests', () => {
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
browser.get('');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should display Angular Router Sample', () => {
|
|
||||||
expect(element(by.css('h1')).getText()).toBe('Angular Router Sample');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should display Crisis Center button', () => {
|
|
||||||
expect(element.all(by.css('a')).get(0).getText()).toBe('Crisis Center');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should display Heroes button', () => {
|
|
||||||
expect(element.all(by.css('a')).get(1).getText()).toBe('Heroes');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should display HEROES', () => {
|
|
||||||
expect(element(by.css('h3')).getText()).toBe('HEROES');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should change to display crisis list component', async () => {
|
|
||||||
const crisisButton = element.all(by.css('a')).get(0);
|
|
||||||
await crisisButton.click();
|
|
||||||
expect(element(by.css('h3')).getText()).toBe('CRISIS CENTER');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should change to display heroes component', async () => {
|
|
||||||
const heroesButton = element.all(by.css('a')).get(1);
|
|
||||||
await heroesButton.click();
|
|
||||||
expect(element(by.css('h3')).getText()).toBe('HEROES');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should use wildcard route', async () => {
|
|
||||||
browser.get('/fake-page');
|
|
||||||
expect(browser.getCurrentUrl()).toContain('fake-page');
|
|
||||||
expect(element(by.css('h2')).getText()).toBe('Page Not Found');
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,34 +0,0 @@
|
|||||||
.button {
|
|
||||||
box-shadow: inset 0px 1px 0px 0px #ffffff;
|
|
||||||
background: linear-gradient(to bottom, #ffffff 5%, #f6f6f6 100%);
|
|
||||||
background-color: #ffffff;
|
|
||||||
border-radius: 6px;
|
|
||||||
border: 1px solid #dcdcdc;
|
|
||||||
display: inline-block;
|
|
||||||
cursor: pointer;
|
|
||||||
color: #666666;
|
|
||||||
font-family: Arial;
|
|
||||||
font-size: 15px;
|
|
||||||
font-weight: bold;
|
|
||||||
padding: 6px 24px;
|
|
||||||
text-decoration: none;
|
|
||||||
text-shadow: 0px 1px 0px #ffffff;
|
|
||||||
outline: 0;
|
|
||||||
}
|
|
||||||
.activebutton {
|
|
||||||
box-shadow: inset 0px 1px 0px 0px #dcecfb;
|
|
||||||
background: linear-gradient(to bottom, #bddbfa 5%, #80b5ea 100%);
|
|
||||||
background-color: #bddbfa;
|
|
||||||
border-radius: 6px;
|
|
||||||
border: 1px solid #84bbf3;
|
|
||||||
display: inline-block;
|
|
||||||
cursor: pointer;
|
|
||||||
color: #ffffff;
|
|
||||||
font-family: Arial;
|
|
||||||
font-size: 15px;
|
|
||||||
font-weight: bold;
|
|
||||||
padding: 6px 24px;
|
|
||||||
text-decoration: none;
|
|
||||||
text-shadow: 0px 1px 0px #528ecc;
|
|
||||||
outline: 0;
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
<!-- #docplaster -->
|
|
||||||
<!-- #docregion setup -->
|
|
||||||
<h1>Angular Router Sample</h1>
|
|
||||||
<!-- #enddocregion setup-->
|
|
||||||
<!-- #docregion routeractivelink -->
|
|
||||||
<nav>
|
|
||||||
<a class="button" routerLink="/crisis-list" routerLinkActive="activebutton">Crisis Center</a> |
|
|
||||||
<a class="button" routerLink="/heroes-list" routerLinkActive="activebutton">Heroes</a>
|
|
||||||
</nav>
|
|
||||||
<!-- #enddocregion routeractivelink-->
|
|
||||||
<!-- #docregion router-outlet -->
|
|
||||||
<router-outlet></router-outlet>
|
|
||||||
<!-- #enddocregion router-outlet -->
|
|
||||||
|
|
||||||
<div style="display: none;">
|
|
||||||
<!-- This HTML represents the initial state for the tutorial. It is not intended to appear in the app. -->
|
|
||||||
<!-- #docregion setup, components -->
|
|
||||||
<app-crisis-list></app-crisis-list>
|
|
||||||
<app-heroes-list></app-heroes-list>
|
|
||||||
<!-- #enddocregion setup, components -->
|
|
||||||
|
|
||||||
<!-- This HTML snippet is for when the user first adds the routerlink navigation. -->
|
|
||||||
<!-- #docregion nav -->
|
|
||||||
<nav>
|
|
||||||
<a class="button" routerLink="/crisis-list">Crisis Center</a> |
|
|
||||||
<a class="button" routerLink="/heroes-list">Heroes</a>
|
|
||||||
</nav>
|
|
||||||
<!-- #enddocregion nav-->
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
@ -1,10 +0,0 @@
|
|||||||
import { Component } from '@angular/core';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-root',
|
|
||||||
templateUrl: './app.component.html',
|
|
||||||
styleUrls: ['./app.component.css']
|
|
||||||
})
|
|
||||||
export class AppComponent {
|
|
||||||
title = 'angular-router-sample';
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
// #docplaster
|
|
||||||
import { BrowserModule } from '@angular/platform-browser';
|
|
||||||
import { NgModule } from '@angular/core';
|
|
||||||
// #docregion router-import
|
|
||||||
import { RouterModule } from '@angular/router';
|
|
||||||
// #enddocregion router-import
|
|
||||||
import { AppComponent } from './app.component';
|
|
||||||
import { CrisisListComponent } from './crisis-list/crisis-list.component';
|
|
||||||
import { HeroesListComponent } from './heroes-list/heroes-list.component';
|
|
||||||
import { PageNotFoundComponent } from './page-not-found/page-not-found.component';
|
|
||||||
|
|
||||||
@NgModule({
|
|
||||||
declarations: [
|
|
||||||
AppComponent,
|
|
||||||
CrisisListComponent,
|
|
||||||
HeroesListComponent,
|
|
||||||
PageNotFoundComponent
|
|
||||||
],
|
|
||||||
// #docplaster
|
|
||||||
// #docregion import-basic, import-redirect, import-wildcard
|
|
||||||
imports: [
|
|
||||||
BrowserModule,
|
|
||||||
RouterModule.forRoot([
|
|
||||||
{path: 'crisis-list', component: CrisisListComponent},
|
|
||||||
{path: 'heroes-list', component: HeroesListComponent},
|
|
||||||
// #enddocregion import-basic
|
|
||||||
{path: '', redirectTo: '/heroes-list', pathMatch: 'full'},
|
|
||||||
// #enddocregion import-redirect
|
|
||||||
{path: '**', component: PageNotFoundComponent}
|
|
||||||
// #enddocregion import-wildcard
|
|
||||||
// #docregion import-basic, import-redirect, import-wildcard
|
|
||||||
]),
|
|
||||||
],
|
|
||||||
// #enddocregion import-basic, import-redirect, import-wildcard
|
|
||||||
providers: [],
|
|
||||||
bootstrap: [AppComponent]
|
|
||||||
})
|
|
||||||
export class AppModule { }
|
|
@ -1,2 +0,0 @@
|
|||||||
<h3>CRISIS CENTER</h3>
|
|
||||||
<p>Get your crisis here</p>
|
|
@ -1,10 +0,0 @@
|
|||||||
import { Component } from '@angular/core';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-crisis-list',
|
|
||||||
templateUrl: './crisis-list.component.html',
|
|
||||||
styleUrls: ['./crisis-list.component.css']
|
|
||||||
})
|
|
||||||
export class CrisisListComponent {
|
|
||||||
|
|
||||||
}
|
|
@ -1,2 +0,0 @@
|
|||||||
<h3>HEROES</h3>
|
|
||||||
<p>Get your heroes here</p>
|
|
@ -1,10 +0,0 @@
|
|||||||
import { Component } from '@angular/core';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-heroes-list',
|
|
||||||
templateUrl: './heroes-list.component.html',
|
|
||||||
styleUrls: ['./heroes-list.component.css']
|
|
||||||
})
|
|
||||||
export class HeroesListComponent {
|
|
||||||
|
|
||||||
}
|
|
@ -1,2 +0,0 @@
|
|||||||
<h2>Page Not Found</h2>
|
|
||||||
<p>We couldn't find that page! Not even with x-ray vision.</p>
|
|
@ -1,10 +0,0 @@
|
|||||||
import { Component } from '@angular/core';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-page-not-found',
|
|
||||||
templateUrl: './page-not-found.component.html',
|
|
||||||
styleUrls: ['./page-not-found.component.css']
|
|
||||||
})
|
|
||||||
export class PageNotFoundComponent {
|
|
||||||
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>Angular Router Sample</title>
|
|
||||||
<base href="/">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<app-root></app-root>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,12 +0,0 @@
|
|||||||
import { enableProdMode } from '@angular/core';
|
|
||||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
|
||||||
|
|
||||||
import { AppModule } from './app/app.module';
|
|
||||||
import { environment } from './environments/environment';
|
|
||||||
|
|
||||||
if (environment.production) {
|
|
||||||
enableProdMode();
|
|
||||||
}
|
|
||||||
|
|
||||||
platformBrowserDynamic().bootstrapModule(AppModule)
|
|
||||||
.catch(err => console.error(err));
|
|
@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"description": "Router",
|
|
||||||
"files":[
|
|
||||||
"!**/*.d.ts",
|
|
||||||
"!**/*.js",
|
|
||||||
"!**/*.[0-9].*"
|
|
||||||
],
|
|
||||||
"tags": ["router-tutorial"]
|
|
||||||
}
|
|
@ -6,11 +6,13 @@ import { Routes, RouterModule } from '@angular/router'; // CLI imports router
|
|||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{ path: 'first-component', component: FirstComponent },
|
{ path: 'first-component', component: FirstComponent },
|
||||||
{ path: 'second-component', component: SecondComponent },
|
{ path: 'second-component', component: SecondComponent },
|
||||||
// #enddocregion routes, routes-with-wildcard
|
// #enddocregion routes
|
||||||
{ path: '', redirectTo: '/first-component', pathMatch: 'full' }, // redirect to `first-component`
|
{ path: '', redirectTo: '/first-component', pathMatch: 'full' }, // redirect to `first-component`
|
||||||
// #docregion routes-with-wildcard
|
{ path: '**', component: FirstComponent },
|
||||||
|
// #enddocregion redirect
|
||||||
{ path: '**', component: PageNotFoundComponent }, // Wildcard route for a 404 page
|
{ path: '**', component: PageNotFoundComponent }, // Wildcard route for a 404 page
|
||||||
// #docregion routes
|
// #docregion routes
|
||||||
|
// #docregion redirect
|
||||||
];
|
];
|
||||||
// #enddocregion routes, routes-with-wildcard, redirect
|
// #enddocregion routes, routes-with-wildcard, redirect
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// #docregion
|
// #docregion
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Router, UrlTree } from '@angular/router';
|
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Router } from '@angular/router';
|
||||||
|
|
||||||
import { AuthService } from './auth.service';
|
import { AuthService } from './auth.service';
|
||||||
|
|
||||||
@ -12,20 +12,21 @@ export class AuthGuard implements CanActivate {
|
|||||||
|
|
||||||
canActivate(
|
canActivate(
|
||||||
next: ActivatedRouteSnapshot,
|
next: ActivatedRouteSnapshot,
|
||||||
state: RouterStateSnapshot): true|UrlTree {
|
state: RouterStateSnapshot): boolean {
|
||||||
let url: string = state.url;
|
let url: string = state.url;
|
||||||
|
|
||||||
return this.checkLogin(url);
|
return this.checkLogin(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
checkLogin(url: string): true|UrlTree {
|
checkLogin(url: string): boolean {
|
||||||
if (this.authService.isLoggedIn) { return true; }
|
if (this.authService.isLoggedIn) { return true; }
|
||||||
|
|
||||||
// Store the attempted URL for redirecting
|
// Store the attempted URL for redirecting
|
||||||
this.authService.redirectUrl = url;
|
this.authService.redirectUrl = url;
|
||||||
|
|
||||||
// Redirect to the login page
|
// Navigate to the login page with extras
|
||||||
return this.router.parseUrl('/login');
|
this.router.navigate(['/login']);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// #enddocregion
|
// #enddocregion
|
||||||
|
@ -4,8 +4,7 @@ import {
|
|||||||
CanActivate, Router,
|
CanActivate, Router,
|
||||||
ActivatedRouteSnapshot,
|
ActivatedRouteSnapshot,
|
||||||
RouterStateSnapshot,
|
RouterStateSnapshot,
|
||||||
CanActivateChild,
|
CanActivateChild
|
||||||
UrlTree
|
|
||||||
} from '@angular/router';
|
} from '@angular/router';
|
||||||
import { AuthService } from './auth.service';
|
import { AuthService } from './auth.service';
|
||||||
|
|
||||||
@ -17,7 +16,7 @@ export class AuthGuard implements CanActivate, CanActivateChild {
|
|||||||
|
|
||||||
canActivate(
|
canActivate(
|
||||||
route: ActivatedRouteSnapshot,
|
route: ActivatedRouteSnapshot,
|
||||||
state: RouterStateSnapshot): true|UrlTree {
|
state: RouterStateSnapshot): boolean {
|
||||||
let url: string = state.url;
|
let url: string = state.url;
|
||||||
|
|
||||||
return this.checkLogin(url);
|
return this.checkLogin(url);
|
||||||
@ -25,19 +24,20 @@ export class AuthGuard implements CanActivate, CanActivateChild {
|
|||||||
|
|
||||||
canActivateChild(
|
canActivateChild(
|
||||||
route: ActivatedRouteSnapshot,
|
route: ActivatedRouteSnapshot,
|
||||||
state: RouterStateSnapshot): true|UrlTree {
|
state: RouterStateSnapshot): boolean {
|
||||||
return this.canActivate(route, state);
|
return this.canActivate(route, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #enddocregion can-activate-child
|
// #enddocregion can-activate-child
|
||||||
checkLogin(url: string): true|UrlTree {
|
checkLogin(url: string): boolean {
|
||||||
if (this.authService.isLoggedIn) { return true; }
|
if (this.authService.isLoggedIn) { return true; }
|
||||||
|
|
||||||
// Store the attempted URL for redirecting
|
// Store the attempted URL for redirecting
|
||||||
this.authService.redirectUrl = url;
|
this.authService.redirectUrl = url;
|
||||||
|
|
||||||
// Redirect to the login page
|
// Navigate to the login page
|
||||||
return this.router.parseUrl('/login');
|
this.router.navigate(['/login']);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
// #docregion can-activate-child
|
// #docregion can-activate-child
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user