Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: integration tests now against bazel built packages #22810

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion .circleci/config.yml
Expand Up @@ -15,8 +15,12 @@
var_1: &docker_image angular/ngcontainer:0.2.0
var_2: &cache_key v2-angular-{{ .Branch }}-{{ checksum "yarn.lock" }}-0.2.0

# Define common ENV vars
var_3: &define_env_vars
run: echo "export PROJECT_ROOT=$(pwd)" >> $BASH_ENV

# See remote cache documentation in /docs/BAZEL.md
var_3: &setup-bazel-remote-cache
var_4: &setup-bazel-remote-cache
run:
name: Start up bazel remote cache proxy
command: ~/bazel-remote-proxy -backend circleci://
Expand Down Expand Up @@ -63,6 +67,7 @@ jobs:
<<: *job_defaults
resource_class: xlarge
steps:
- *define_env_vars
- checkout:
<<: *post_checkout
# See remote cache documentation in /docs/BAZEL.md
Expand All @@ -82,6 +87,10 @@ jobs:
# NOTE: Angular developers should typically just bazel build //packages/... or bazel test //packages/...
- run: bazel query --output=label //... | xargs bazel test

# We run the integration tests outside of Bazel for now.
# See comments inside this script.
- run: xvfb-run --auto-servernum ./integration/run_tests.sh

# CircleCI will allow us to go back and view/download these artifacts from past builds.
# Also we can use a service like https://buildsize.org/ to automatically track binary size of these artifacts.
- store_artifacts:
Expand Down
1 change: 0 additions & 1 deletion .travis.yml
Expand Up @@ -45,7 +45,6 @@ env:
matrix:
# Order: a slower build first, so that we don't occupy an idle travis worker waiting for others to complete.
- CI_MODE=e2e
- CI_MODE=e2e_2
- CI_MODE=js
- CI_MODE=saucelabs_required
# deactivated, see #19768
Expand Down
15 changes: 3 additions & 12 deletions integration/README.md
Expand Up @@ -51,18 +51,9 @@ you can install the package directly from `file:../../node_modules`.

## Running integration tests

First you must run `build.sh` to create the current distribution.

You can iterate on the tests by keeping the dist folder up-to-date.
See the `package.json` of the test(s) you're debugging, to see which dist/ folders they install from.
Then run the right `tsc --watch` command to keep those dist folders up-to-date, for example:

```
$ ./node_modules/.bin/tsc -p packages/core/tsconfig-build.json --watch
```

Now you can run the integration test, it will re-install from the dist/ folder on each run.

```
$ ./integration/run_tests.sh
```

The test runner will first re-build any stale npm packages, then `cd` into each
subdirectory to execute the test.
2 changes: 1 addition & 1 deletion integration/bazel/angular.tsconfig.json
Expand Up @@ -17,6 +17,6 @@
"node_modules/@angular/bazel/**",
"node_modules/@angular/compiler-cli/**",
"node_modules/@angular/common/locales/**",
"node_modules/@angular/tsc-wrapped/**"
"node_modules/@angular/*/testing/**"
]
}
Expand Up @@ -8,27 +8,27 @@
"url": "https://github.com/angular/angular.git"
},
"dependencies": {
"@angular/animations": "file:../../../dist/packages-dist/animations",
"@angular/common": "file:../../../dist/packages-dist/common",
"@angular/compiler": "file:../../../dist/packages-dist/compiler",
"@angular/compiler-cli": "file:../../../dist/packages-dist/compiler-cli",
"@angular/core": "file:../../../dist/packages-dist/core",
"@angular/http": "file:../../../dist/packages-dist/http",
"@angular/platform-browser": "file:../../../dist/packages-dist/platform-browser",
"@angular/platform-browser-dynamic": "file:../../../dist/packages-dist/platform-browser-dynamic",
"@angular/platform-server": "file:../../../dist/packages-dist/platform-server",
"@angular/animations": "file:../../dist/packages-dist/animations",
"@angular/common": "file:../../dist/packages-dist/common",
"@angular/compiler": "file:../../dist/packages-dist/compiler",
"@angular/compiler-cli": "file:../../dist/packages-dist/compiler-cli",
"@angular/core": "file:../../dist/packages-dist/core",
"@angular/http": "file:../../dist/packages-dist/http",
"@angular/platform-browser": "file:../../dist/packages-dist/platform-browser",
"@angular/platform-browser-dynamic": "file:../../dist/packages-dist/platform-browser-dynamic",
"@angular/platform-server": "file:../../dist/packages-dist/platform-server",
"express": "^4.14.1",
"rxjs": "file:../../../node_modules/rxjs",
"typescript": "file:../../../node_modules/typescript",
"zone.js": "file:../../../node_modules/zone.js"
"rxjs": "file:../../node_modules/rxjs",
"typescript": "file:../../node_modules/typescript",
"zone.js": "file:../../node_modules/zone.js"
},
"devDependencies": {
"@types/jasmine": "2.5.41",
"babel-core": "^6.23.1",
"babel-loader": "^6.4.0",
"babel-preset-es2015": "^6.22.0",
"concurrently": "3.1.0",
"protractor": "file:../../../node_modules/protractor",
"protractor": "file:../../node_modules/protractor",
"raw-loader": "^0.5.1",
"webpack": "^2.2.1"
},
Expand Down
59 changes: 43 additions & 16 deletions integration/run_tests.sh
Expand Up @@ -2,19 +2,47 @@

set -e -o pipefail

currentDir=$(cd $(dirname $0); pwd)
cd ${currentDir}
# see https://circleci.com/docs/2.0/env-vars/#circleci-built-in-environment-variables
CI=${CI:-false}

cd "$(dirname "$0")"

readonly thisDir=$(cd $(dirname $0); pwd)
# basedir is the workspace root
readonly basedir=$(pwd)/..
readonly bin=$(bazel info bazel-bin)

echo "#################################"
echo "Building @angular/* npm packages "
echo "#################################"

# Ideally these integration tests should run under bazel, and just list the npm
# packages in their deps[].
# Until then, we have to manually run bazel first to create the npm packages we
# want to test.
bazel query --output=label 'kind(.*_package, //packages/...)' \
| xargs bazel build

# Allow this test to run even if dist/ doesn't exist yet.
# Under Bazel we don't need to create the dist folder to run the integration tests
[ -d "${basedir}/dist/packages-dist" ] || mkdir -p $basedir/dist/packages-dist
# Each package is a subdirectory of bazel-bin/packages/
for pkg in $(ls ${bin}/packages); do
# Skip any that don't have an "npm_package" target
if [ -d "${bin}/packages/${pkg}/npm_package" ]; then
echo "# Copy artifacts to dist/packages-dist/${pkg}"
rm -rf ${basedir}/dist/packages-dist/${pkg}
cp -R ${bin}/packages/${pkg}/npm_package ${basedir}/dist/packages-dist/${pkg}
fi
done

# Track payload size functions
# TODO(alexeagle): finish migrating these to buildsize.org
if [[ -v TRAVIS ]]; then
if $CI; then
# We don't install this by default because it contains some broken Bazel setup
# and also it's a very big dependency that we never use except on Travis.
# and also it's a very big dependency that we never use except when publishing
# payload sizes on CI.
yarn add -D firebase-tools@3.12.0
source ../scripts/ci/payload-size.sh
source ${basedir}/scripts/ci/payload-size.sh
fi

# Workaround https://github.com/yarnpkg/yarn/issues/2165
Expand All @@ -35,24 +63,23 @@ for testDir in $(ls | grep -v node_modules) ; do
(
cd $testDir
rm -rf dist
pwd
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

echo ""
echo ""
echo " ======= running integration tests: `pwd`"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was right above in the bigger ### fences

yarn install --cache-folder ../$cache
yarn test || exit 1
# Track payload size for cli-hello-world and hello_world__closure and the render3 tests
if [[ $testDir == cli-hello-world ]] || [[ $testDir == hello_world__closure ]] || [[ $testDir == hello_world__render3__closure ]] || [[ $testDir == hello_world__render3__rollup ]] || [[ $testDir == hello_world__render3__cli ]]; then
if [[ $testDir == cli-hello-world ]] || [[ $testDir == hello_world__render3__cli ]]; then
yarn build
fi
if [[ -v TRAVIS ]]; then
trackPayloadSize "$testDir" "dist/*.js" true false "${thisDir}/_payload-limits.json"
fi
fi
if [[ -v TRAVIS ]]; then
# remove the temporary node modules directory to save space.
rm -rf node_modules
#if $CI; then
# trackPayloadSize "$testDir" "dist/*.js" true false "${basedir}/integration/_payload-limits.json"
#fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so we are disabling the size tracking for cli hello world?
is this because we don't have credentials setup yet?
can you add a todo and explanation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filed #23376

fi
# remove the temporary node modules directory to keep the source folder clean.
rm -rf node_modules
)
done

if [[ -v TRAVIS ]]; then
trackPayloadSize "umd" "../dist/packages-dist/*/bundles/*.umd.min.js" false false
fi
#if $CI; then
# trackPayloadSize "umd" "../dist/packages-dist/*/bundles/*.umd.min.js" false false
#fi
3 changes: 2 additions & 1 deletion packages/bazel/test/ng_package/example/package.json
@@ -1,3 +1,4 @@
{
"name": "example"
"name": "example",
"version": "0.0.0-PLACEHOLDER"
}
6 changes: 0 additions & 6 deletions packages/platform-server/integrationtest/.gitignore

This file was deleted.

13 changes: 0 additions & 13 deletions packages/platform-server/integrationtest/run_tests.sh

This file was deleted.

1 change: 0 additions & 1 deletion scripts/ci/env.sh
Expand Up @@ -40,7 +40,6 @@ setEnvVar YARN_VERSION 1.3.2
# Revision 494239 (which was part of Chrome 62.0.3186.0) is the last version that does not cause flakes. (Latest revision checked: 508578)
setEnvVar CHROMIUM_VERSION 494239 # Chrome 62 linux stable, see https://www.chromium.org/developers/calendar
setEnvVar CHROMEDRIVER_VERSION_ARG "--versions.chrome 2.33"
setEnvVar BAZEL_VERSION 0.11.1
setEnvVar SAUCE_CONNECT_VERSION 4.4.9
setEnvVar ANGULAR_CLI_VERSION 1.6.3
setEnvVar PROJECT_ROOT $(cd ${thisDir}/../..; pwd)
Expand Down
16 changes: 0 additions & 16 deletions scripts/ci/install.sh
Expand Up @@ -64,22 +64,6 @@ if [[ ${TRAVIS} &&
travisFoldEnd "yarn-install.aio"
fi

# Install bazel
if [[ ${TRAVIS} && ${CI_MODE} == "e2e_2" ]]; then
travisFoldStart "bazel-install"
(
mkdir tmp
cd tmp
curl --location --compressed https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-installer-linux-x86_64.sh > bazel-${BAZEL_VERSION}-installer-linux-x86_64.sh
chmod +x bazel-${BAZEL_VERSION}-installer-linux-x86_64.sh
./bazel-${BAZEL_VERSION}-installer-linux-x86_64.sh --user
cd ..
rm -rf tmp
)
travisFoldEnd "bazel-install"
fi


# Install Chromium
if [[ ${TRAVIS} &&
${CI_MODE} == "js" ||
Expand Down
36 changes: 0 additions & 36 deletions scripts/ci/test-e2e-2.sh

This file was deleted.

15 changes: 12 additions & 3 deletions scripts/ci/test-e2e.sh
@@ -1,7 +1,5 @@
#!/usr/bin/env bash

# First shard for the e2e tests. Balance it with runtime of test-e2e-2.sh

set -u -e -o pipefail

# Setup environment
Expand All @@ -17,7 +15,6 @@ travisFoldStart "test.e2e.check-cycle"
$(npm bin)/gulp check-cycle
travisFoldEnd "test.e2e.check-cycle"


# Serve files for e2e tests
(
$(npm bin)/gulp serve &
Expand All @@ -33,3 +30,15 @@ travisFoldEnd "test.e2e.protractor-examples-e2e"
travisFoldStart "test.e2e.protractor-perf"
NODE_PATH=$NODE_PATH:./dist/all $(npm bin)/protractor ./protractor-perf.conf.js --bundles=true --dryrun
travisFoldEnd "test.e2e.protractor-perf"

# TODO(i): temporarily disable this test because we don't have rxjs backwards compatibility package
# and cdk+material are not yet compatible with rxjs v6
# uncomment when we have cdk and material releases compatible with rxjs v6
#travisFoldStart "test.e2e.offlineCompiler"
# #TODO(alexeagle): move offline_compiler_test to integration/
# ${thisDir}/offline_compiler_test.sh
#travisFoldEnd "test.e2e.offlineCompiler"

travisFoldStart "test.e2e.source-maps"
./node_modules/.bin/gulp source-map-test
travisFoldEnd "test.e2e.source-maps"
3 changes: 0 additions & 3 deletions scripts/ci/test.sh
Expand Up @@ -22,9 +22,6 @@ case ${CI_MODE} in
e2e)
${thisDir}/test-e2e.sh
;;
e2e_2)
${thisDir}/test-e2e-2.sh
;;
saucelabs_required)
${thisDir}/test-saucelabs.sh
;;
Expand Down
1 change: 1 addition & 0 deletions tools/bazel.rc
Expand Up @@ -28,6 +28,7 @@ build --watchfs
# Release support #
###############################

# Releases should always be stamped with version control info
build --workspace_status_command=./tools/bazel_stamp_vars.sh

###############################
Expand Down