Skip to content

Commit

Permalink
ci: move local and saucelabs unit tests to circle (angular#27937)
Browse files Browse the repository at this point in the history
Moving the tests over to CircleCI in pretty much "as-is" state just so that we can drop the dependency on Travis.

In the followup changes we plan to migrate these tests to run on sauce under bazel. @gregmagolan is working on that.

I've previously verified that all the tests executed in legacy-unit-tests-local already under bazel.
Therefore the legacy-unit-tests-local job is strictly not necessary any more, but given how flaky legacy-unit-tests-saucelabs is,
it is good to have the -local job just so that we can quickly determine if any failure is a flake or legit issue
(the bazel version of these tests could theoretically run in a slightly different way and fail or not fail in a different way, so having -lcoal job is just an extra safety check).

This change was coauthored with @devversion

PR Close angular#27937
  • Loading branch information
IgorMinar authored and ngfelixl committed Jan 27, 2019
1 parent fba0abe commit 670749b
Show file tree
Hide file tree
Showing 17 changed files with 207 additions and 348 deletions.
59 changes: 59 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,54 @@ jobs:
command: 'curl --request POST --header "Content-Type: application/json" --data "{\"text\":\":x: \`$CIRCLE_JOB\` job failed on build $CIRCLE_BUILD_NUM: $CIRCLE_BUILD_URL :scream:\"}" $CI_SECRET_SLACK_CARETAKER_WEBHOOK_URL'
when: on_fail

legacy-unit-tests-local:
<<: *job_defaults
docker:
- image: *browsers_docker_image
steps:
- checkout:
<<: *post_checkout
- restore_cache:
key: *cache_key
- *define_env_vars
- *yarn_install
- run: yarn tsc -p packages
- run: yarn tsc -p packages/examples
- run: yarn tsc -p modules
- run: yarn karma start ./karma-js.conf.js --single-run --browsers=ChromeNoSandbox

legacy-unit-tests-saucelabs:
<<: *job_defaults
# In order to avoid the bottleneck of having a slow host machine, we acquire a better
# container for this job. This is necessary because we launch a lot of browsers concurrently
# and therefore the tunnel and Karma need to process a lot of file requests and tests.
resource_class: xlarge
steps:
- checkout:
<<: *post_checkout
- restore_cache:
key: *cache_key
- *define_env_vars
- *yarn_install
- run:
name: Preparing environment for running tests on Saucelabs.
command: |
setPublicVar KARMA_JS_BROWSERS $(node -e 'console.log(require("./browser-providers.conf").sauceAliases.CI_REQUIRED.join(","))')
setSecretVar SAUCE_ACCESS_KEY $(echo $SAUCE_ACCESS_KEY | rev)
- run:
name: Starting Saucelabs tunnel
command: ./scripts/saucelabs/start-tunnel.sh
background: true
- run: yarn tsc -p packages
- run: yarn tsc -p packages/examples
- run: yarn tsc -p modules
# Waits for the Saucelabs tunnel to be ready. This ensures that we don't run tests
# too early without Saucelabs not being ready.
- run: ./scripts/saucelabs/wait-for-tunnel.sh
- run: yarn karma start ./karma-js.conf.js --single-run --browsers=${KARMA_JS_BROWSERS}
- run: ./scripts/saucelabs/stop-tunnel.sh


workflows:
version: 2
default_workflow:
Expand All @@ -408,6 +456,8 @@ workflows:
- test_ivy_aot
- build-packages-dist
- test_aio
- legacy-unit-tests-local
- legacy-unit-tests-saucelabs
- deploy_aio:
requires:
- test_aio
Expand Down Expand Up @@ -451,6 +501,9 @@ workflows:
# Get the artifacts to publish from the build-packages-dist job
# since the publishing script expects the legacy outputs layout.
- build-packages-dist
- legacy-unit-tests-local
- legacy-unit-tests-saucelabs


aio_monitoring:
jobs:
Expand All @@ -462,3 +515,9 @@ workflows:
branches:
only:
- master

# TODO:
# - don't build the g3 branch
# - verify that we are bootstrapping with the right yarn version coming from the docker image
# - check local chrome version pulled from docker image
# - remove /tools/ngcontainer
23 changes: 23 additions & 0 deletions .circleci/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ echo "source $envHelpersPath;" >> $BASH_ENV;
####################################################################################################
# Define PUBLIC environment variables for CircleCI.
####################################################################################################
# See https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables for more info.
####################################################################################################
setPublicVar PROJECT_ROOT "$(pwd)";
setPublicVar CI_AIO_MIN_PWA_SCORE "95";
# This is the branch being built; e.g. `pull/12345` for PR builds.
Expand All @@ -31,5 +33,26 @@ setSecretVar CI_SECRET_PAYLOAD_FIREBASE_TOKEN "$ANGULAR_PAYLOAD_TOKEN";
setSecretVar CI_SECRET_SLACK_CARETAKER_WEBHOOK_URL "$SLACK_CARETAKER_WEBHOOK_URL";


####################################################################################################
# Define SauceLabs environment variables for CircleCI.
####################################################################################################
# In order to have a meaningful SauceLabs badge on the repo page,
# the angular2-ci account is used only when pushing commits to master;
# in all other cases, the regular angular-ci account is used.
if [ "${CI_PULL_REQUEST}" = "false" ] && [ "${CI_REPO_OWNER}" = "angular" ] && [ "${CI_BRANCH}" = "master" ]; then
setPublicVar SAUCE_USERNAME "angular2-ci";
setSecretVar SAUCE_ACCESS_KEY "693ebc16208a-0b5b-1614-8d66-a2662f4e";
else
setPublicVar SAUCE_USERNAME "angular-ci";
setSecretVar SAUCE_ACCESS_KEY "9b988f434ff8-fbca-8aa4-4ae3-35442987";
fi
setPublicVar SAUCE_READY_FILE /tmp/angular/sauce-connect-ready-file.lock
setPublicVar SAUCE_PID_FILE /tmp/angular/sauce-connect-pid-file.lock
setPublicVar SAUCE_TUNNEL_IDENTIFIER "angular-${CIRCLE_BUILD_NUM}-${CIRCLE_NODE_INDEX}"
# 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.
setPublicVar SAUCE_READY_FILE_TIMEOUT 120


# Source `$BASH_ENV` to make the variables available immediately.
source $BASH_ENV;
47 changes: 0 additions & 47 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,58 +1,11 @@
language: node_js
sudo: false
dist: trusty
node_js:
- '10.9.0'

addons:
# firefox: "38.0"
apt:
sources:
# needed to install g++ that is used by npms's native modules
- ubuntu-toolchain-r-test
packages:
# needed to install g++ that is used by npms's native modules
- g++-4.8

branches:
except:
- g3

cache:
yarn: true
directories:
- ./node_modules
- ./.chrome/chromium
- ./aio/node_modules

env:
global:
# GITHUB_TOKEN_ANGULAR=<github token, a personal access token of the angular-builds account, account access in valentine>
# This is needed for the e2e Travis matrix task to publish packages to github for continuous packages delivery.
- secure: "aCdHveZuY8AT4Jr1JoJB4LxZsnGWRe/KseZh1YXYe5UtufFCtTVHvUcLn0j2aLBF0KpdyS+hWf0i4np9jthKu2xPKriefoPgCMpisYeC0MFkwbmv+XlgkUbgkgVZMGiVyX7DCYXVahxIoOUjVMEDCbNiHTIrfEuyq24U3ok2tHc="
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=js
- CI_MODE=saucelabs_required
# deactivated, see #19768
# - CI_MODE=browserstack_required

# We disable these optional jobs because those acquire tunnel and browser instances which
# could lead to rate limit excess while those are failing most of the time and nobody pays
# attention anyway.
# - CI_MODE=saucelabs_optional
# - CI_MODE=browserstack_optional

matrix:
fast_finish: true
allow_failures:
- env: "CI_MODE=saucelabs_optional"
- env: "CI_MODE=browserstack_optional"

before_install:
# source the env.sh script so that the exported variables are available to other scripts later on
- source ./scripts/ci/env.sh print

install:
- ./scripts/ci/install.sh
Expand Down
29 changes: 14 additions & 15 deletions karma-js.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,19 @@ module.exports = function(config) {
browserNoActivityTimeout: 300000,
});

if (process.env.TRAVIS) {
var buildId =
'TRAVIS #' + process.env.TRAVIS_BUILD_NUMBER + ' (' + process.env.TRAVIS_BUILD_ID + ')';
if (process.env.CI_MODE.startsWith('saucelabs')) {
config.sauceLabs.build = buildId;
config.sauceLabs.tunnelIdentifier = process.env.TRAVIS_JOB_NUMBER;

// Try "websocket" for a faster transmission first. Fallback to "polling" if necessary.
config.transports = ['websocket', 'polling'];
}

if (process.env.CI_MODE.startsWith('browserstack')) {
config.browserStack.build = buildId;
config.browserStack.tunnelIdentifier = process.env.TRAVIS_JOB_NUMBER;
}
if (process.env.CIRCLECI) {
const tunnelIdentifier = process.env['SAUCE_TUNNEL_IDENTIFIER'];

// Setup the Saucelabs plugin so that it can launch browsers using the proper tunnel.
config.sauceLabs.build = tunnelIdentifier;
config.sauceLabs.tunnelIdentifier = tunnelIdentifier;

// Setup the Browserstack plugin so that it can launch browsers using the proper tunnel.
// TODO: This is currently not used because BS doesn't run on the CI. Consider removing.
config.browserStack.build = tunnelIdentifier;
config.browserStack.tunnelIdentifier = tunnelIdentifier;

// Try "websocket" for a faster transmission first. Fallback to "polling" if necessary.
config.transports = ['websocket', 'polling'];
}
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
"rollup-plugin-node-resolve": "3.0.0",
"rollup-plugin-sourcemaps": "0.4.2",
"rxjs": "^6.3.0",
"sauce-connect": "https://saucelabs.com/downloads/sc-4.5.2-linux.tar.gz",
"semver": "5.4.1",
"systemjs": "0.18.10",
"tslint": "5.7.0",
Expand Down
26 changes: 26 additions & 0 deletions packages/compiler-cli/DEVELOPER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

# Legacy docs for @angular/compiler-cli Developers

*Note from Igor: This doc is likely outdated now but I'm keeping it around because offline_compiler_test.sh need to be converted to bazel/circleci (or deleted) and these docs seem relevant to anyone who needs to understand those tests. Once that's done this file can be deleted.*


```
# Build Angular and the compiler
./build.sh
# Run the test once
# (First edit the LINKABLE_PKGS to use npm link instead of npm install)
$ ./scripts/ci/offline_compiler_test.sh
# Keep a package fresh in watch mode
./node_modules/.bin/tsc -p packages/compiler/tsconfig-build.json -w
# Recompile @angular/core module (needs to use tsc-ext to keep the metadata)
$ export NODE_PATH=${NODE_PATH}:$(pwd)/dist/all:$(pwd)/dist/tools
$ node dist/tools/@angular/compiler-cli/src/main -p packages/core/tsconfig-build.json
# Iterate on the test
$ cd /tmp/wherever/e2e_test.1464388257/
$ ./node_modules/.bin/ngc
$ ./node_modules/.bin/jasmine test/*_spec.js
```
139 changes: 0 additions & 139 deletions packages/compiler-cli/README.md

This file was deleted.

2 changes: 2 additions & 0 deletions scripts/ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ if [[ ${CI_MODE:-} == "bazel" ]]; then
fi

travisFoldStart "tsc tools"
# TODO: I think these three can be deleted... but I'm not sure
# let's delete them one at a time and test on CI
$(npm bin)/tsc -p tools
$(npm bin)/tsc -p packages/compiler/tsconfig-tools.json
$(npm bin)/tsc -p packages/compiler-cli/tsconfig-tools.json
Expand Down

0 comments on commit 670749b

Please sign in to comment.