Skip to content

Commit 04ca3bc

Browse files
IgorMinarkara
authored andcommitted
ci: move local and saucelabs unit tests to circle (angular#27937)
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
1 parent c1dacdd commit 04ca3bc

17 files changed

Lines changed: 207 additions & 348 deletions

.circleci/config.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,54 @@ jobs:
399399
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'
400400
when: on_fail
401401

402+
legacy-unit-tests-local:
403+
<<: *job_defaults
404+
docker:
405+
- image: *browsers_docker_image
406+
steps:
407+
- checkout:
408+
<<: *post_checkout
409+
- restore_cache:
410+
key: *cache_key
411+
- *define_env_vars
412+
- *yarn_install
413+
- run: yarn tsc -p packages
414+
- run: yarn tsc -p packages/examples
415+
- run: yarn tsc -p modules
416+
- run: yarn karma start ./karma-js.conf.js --single-run --browsers=ChromeNoSandbox
417+
418+
legacy-unit-tests-saucelabs:
419+
<<: *job_defaults
420+
# In order to avoid the bottleneck of having a slow host machine, we acquire a better
421+
# container for this job. This is necessary because we launch a lot of browsers concurrently
422+
# and therefore the tunnel and Karma need to process a lot of file requests and tests.
423+
resource_class: xlarge
424+
steps:
425+
- checkout:
426+
<<: *post_checkout
427+
- restore_cache:
428+
key: *cache_key
429+
- *define_env_vars
430+
- *yarn_install
431+
- run:
432+
name: Preparing environment for running tests on Saucelabs.
433+
command: |
434+
setPublicVar KARMA_JS_BROWSERS $(node -e 'console.log(require("./browser-providers.conf").sauceAliases.CI_REQUIRED.join(","))')
435+
setSecretVar SAUCE_ACCESS_KEY $(echo $SAUCE_ACCESS_KEY | rev)
436+
- run:
437+
name: Starting Saucelabs tunnel
438+
command: ./scripts/saucelabs/start-tunnel.sh
439+
background: true
440+
- run: yarn tsc -p packages
441+
- run: yarn tsc -p packages/examples
442+
- run: yarn tsc -p modules
443+
# Waits for the Saucelabs tunnel to be ready. This ensures that we don't run tests
444+
# too early without Saucelabs not being ready.
445+
- run: ./scripts/saucelabs/wait-for-tunnel.sh
446+
- run: yarn karma start ./karma-js.conf.js --single-run --browsers=${KARMA_JS_BROWSERS}
447+
- run: ./scripts/saucelabs/stop-tunnel.sh
448+
449+
402450
workflows:
403451
version: 2
404452
default_workflow:
@@ -408,6 +456,8 @@ workflows:
408456
- test_ivy_aot
409457
- build-packages-dist
410458
- test_aio
459+
- legacy-unit-tests-local
460+
- legacy-unit-tests-saucelabs
411461
- deploy_aio:
412462
requires:
413463
- test_aio
@@ -451,6 +501,9 @@ workflows:
451501
# Get the artifacts to publish from the build-packages-dist job
452502
# since the publishing script expects the legacy outputs layout.
453503
- build-packages-dist
504+
- legacy-unit-tests-local
505+
- legacy-unit-tests-saucelabs
506+
454507

455508
aio_monitoring:
456509
jobs:
@@ -462,3 +515,9 @@ workflows:
462515
branches:
463516
only:
464517
- master
518+
519+
# TODO:
520+
# - don't build the g3 branch
521+
# - verify that we are bootstrapping with the right yarn version coming from the docker image
522+
# - check local chrome version pulled from docker image
523+
# - remove /tools/ngcontainer

.circleci/env.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ echo "source $envHelpersPath;" >> $BASH_ENV;
99
####################################################################################################
1010
# Define PUBLIC environment variables for CircleCI.
1111
####################################################################################################
12+
# See https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables for more info.
13+
####################################################################################################
1214
setPublicVar PROJECT_ROOT "$(pwd)";
1315
setPublicVar CI_AIO_MIN_PWA_SCORE "95";
1416
# This is the branch being built; e.g. `pull/12345` for PR builds.
@@ -31,5 +33,26 @@ setSecretVar CI_SECRET_PAYLOAD_FIREBASE_TOKEN "$ANGULAR_PAYLOAD_TOKEN";
3133
setSecretVar CI_SECRET_SLACK_CARETAKER_WEBHOOK_URL "$SLACK_CARETAKER_WEBHOOK_URL";
3234

3335

36+
####################################################################################################
37+
# Define SauceLabs environment variables for CircleCI.
38+
####################################################################################################
39+
# In order to have a meaningful SauceLabs badge on the repo page,
40+
# the angular2-ci account is used only when pushing commits to master;
41+
# in all other cases, the regular angular-ci account is used.
42+
if [ "${CI_PULL_REQUEST}" = "false" ] && [ "${CI_REPO_OWNER}" = "angular" ] && [ "${CI_BRANCH}" = "master" ]; then
43+
setPublicVar SAUCE_USERNAME "angular2-ci";
44+
setSecretVar SAUCE_ACCESS_KEY "693ebc16208a-0b5b-1614-8d66-a2662f4e";
45+
else
46+
setPublicVar SAUCE_USERNAME "angular-ci";
47+
setSecretVar SAUCE_ACCESS_KEY "9b988f434ff8-fbca-8aa4-4ae3-35442987";
48+
fi
49+
setPublicVar SAUCE_READY_FILE /tmp/angular/sauce-connect-ready-file.lock
50+
setPublicVar SAUCE_PID_FILE /tmp/angular/sauce-connect-pid-file.lock
51+
setPublicVar SAUCE_TUNNEL_IDENTIFIER "angular-${CIRCLE_BUILD_NUM}-${CIRCLE_NODE_INDEX}"
52+
# Amount of seconds we wait for sauceconnect to establish a tunnel instance. In order to not
53+
# acquire CircleCI instances for too long if sauceconnect failed, we need a connect timeout.
54+
setPublicVar SAUCE_READY_FILE_TIMEOUT 120
55+
56+
3457
# Source `$BASH_ENV` to make the variables available immediately.
3558
source $BASH_ENV;

.travis.yml

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,11 @@
1-
language: node_js
2-
sudo: false
3-
dist: trusty
4-
node_js:
5-
- '10.9.0'
6-
7-
addons:
8-
# firefox: "38.0"
9-
apt:
10-
sources:
11-
# needed to install g++ that is used by npms's native modules
12-
- ubuntu-toolchain-r-test
13-
packages:
14-
# needed to install g++ that is used by npms's native modules
15-
- g++-4.8
16-
17-
branches:
18-
except:
19-
- g3
20-
21-
cache:
22-
yarn: true
23-
directories:
24-
- ./node_modules
25-
- ./.chrome/chromium
26-
- ./aio/node_modules
271

282
env:
29-
global:
30-
# GITHUB_TOKEN_ANGULAR=<github token, a personal access token of the angular-builds account, account access in valentine>
31-
# This is needed for the e2e Travis matrix task to publish packages to github for continuous packages delivery.
32-
- secure: "aCdHveZuY8AT4Jr1JoJB4LxZsnGWRe/KseZh1YXYe5UtufFCtTVHvUcLn0j2aLBF0KpdyS+hWf0i4np9jthKu2xPKriefoPgCMpisYeC0MFkwbmv+XlgkUbgkgVZMGiVyX7DCYXVahxIoOUjVMEDCbNiHTIrfEuyq24U3ok2tHc="
333
matrix:
34-
# Order: a slower build first, so that we don't occupy an idle travis worker waiting for others to complete.
354
- CI_MODE=e2e
365
- CI_MODE=js
376
- CI_MODE=saucelabs_required
38-
# deactivated, see #19768
39-
# - CI_MODE=browserstack_required
40-
41-
# We disable these optional jobs because those acquire tunnel and browser instances which
42-
# could lead to rate limit excess while those are failing most of the time and nobody pays
43-
# attention anyway.
44-
# - CI_MODE=saucelabs_optional
45-
# - CI_MODE=browserstack_optional
467

47-
matrix:
48-
fast_finish: true
49-
allow_failures:
50-
- env: "CI_MODE=saucelabs_optional"
51-
- env: "CI_MODE=browserstack_optional"
528

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

5710
install:
5811
- ./scripts/ci/install.sh

karma-js.conf.js

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -144,20 +144,19 @@ module.exports = function(config) {
144144
browserNoActivityTimeout: 300000,
145145
});
146146

147-
if (process.env.TRAVIS) {
148-
var buildId =
149-
'TRAVIS #' + process.env.TRAVIS_BUILD_NUMBER + ' (' + process.env.TRAVIS_BUILD_ID + ')';
150-
if (process.env.CI_MODE.startsWith('saucelabs')) {
151-
config.sauceLabs.build = buildId;
152-
config.sauceLabs.tunnelIdentifier = process.env.TRAVIS_JOB_NUMBER;
153-
154-
// Try "websocket" for a faster transmission first. Fallback to "polling" if necessary.
155-
config.transports = ['websocket', 'polling'];
156-
}
157-
158-
if (process.env.CI_MODE.startsWith('browserstack')) {
159-
config.browserStack.build = buildId;
160-
config.browserStack.tunnelIdentifier = process.env.TRAVIS_JOB_NUMBER;
161-
}
147+
if (process.env.CIRCLECI) {
148+
const tunnelIdentifier = process.env['SAUCE_TUNNEL_IDENTIFIER'];
149+
150+
// Setup the Saucelabs plugin so that it can launch browsers using the proper tunnel.
151+
config.sauceLabs.build = tunnelIdentifier;
152+
config.sauceLabs.tunnelIdentifier = tunnelIdentifier;
153+
154+
// Setup the Browserstack plugin so that it can launch browsers using the proper tunnel.
155+
// TODO: This is currently not used because BS doesn't run on the CI. Consider removing.
156+
config.browserStack.build = tunnelIdentifier;
157+
config.browserStack.tunnelIdentifier = tunnelIdentifier;
158+
159+
// Try "websocket" for a faster transmission first. Fallback to "polling" if necessary.
160+
config.transports = ['websocket', 'polling'];
162161
}
163162
};

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@
133133
"rollup-plugin-node-resolve": "3.0.0",
134134
"rollup-plugin-sourcemaps": "0.4.2",
135135
"rxjs": "^6.3.0",
136+
"sauce-connect": "https://saucelabs.com/downloads/sc-4.5.2-linux.tar.gz",
136137
"semver": "5.4.1",
137138
"systemjs": "0.18.10",
138139
"tslint": "5.7.0",

packages/compiler-cli/DEVELOPER.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
# Legacy docs for @angular/compiler-cli Developers
3+
4+
*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.*
5+
6+
7+
```
8+
# Build Angular and the compiler
9+
./build.sh
10+
11+
# Run the test once
12+
# (First edit the LINKABLE_PKGS to use npm link instead of npm install)
13+
$ ./scripts/ci/offline_compiler_test.sh
14+
15+
# Keep a package fresh in watch mode
16+
./node_modules/.bin/tsc -p packages/compiler/tsconfig-build.json -w
17+
18+
# Recompile @angular/core module (needs to use tsc-ext to keep the metadata)
19+
$ export NODE_PATH=${NODE_PATH}:$(pwd)/dist/all:$(pwd)/dist/tools
20+
$ node dist/tools/@angular/compiler-cli/src/main -p packages/core/tsconfig-build.json
21+
22+
# Iterate on the test
23+
$ cd /tmp/wherever/e2e_test.1464388257/
24+
$ ./node_modules/.bin/ngc
25+
$ ./node_modules/.bin/jasmine test/*_spec.js
26+
```

packages/compiler-cli/README.md

Lines changed: 0 additions & 139 deletions
This file was deleted.

scripts/ci/build.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ if [[ ${CI_MODE:-} == "bazel" ]]; then
2020
fi
2121

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

0 commit comments

Comments
 (0)