diff --git a/.circleci/config.yml b/.circleci/config.yml index 768e6693b8..e752093c4f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,20 +1,137 @@ version: 2 + +# Settings common to each job. +anchor_1: &defaults + working_directory: ~/angular-cli + docker: + - image: angular/ngcontainer + +# Restore cache based on package-lock.json checksum for branch. +anchor_2: &restore_cache_defaults + key: angular-cli-{{ checksum "package-lock.json" }} + +# Attach workspace that contains: +# - dist/ : built cli +# - angular-cli-e2e-default/ : initialized e2e test project +anchor_3: &attach_workspace_defaults + at: /workspace + jobs: build: - working_directory: ~/angular-cli - docker: - - image: angular/ngcontainer - - image: node:8.4 + <<: *defaults steps: - checkout - restore_cache: - key: angular-cli-{{ .Branch }}-{{ checksum "package-lock.json" }} - - run: | - node --version - npm --version - npm install --quiet + <<: *restore_cache_defaults + - run: node --version + - run: npm --version + - run: npm install --quiet + - run: npm run build - save_cache: - key: angular-cli-{{ .Branch }}-{{ checksum "package-lock.json" }} + key: angular-cli-{{ checksum "package-lock.json" }} paths: - "node_modules" - - run: xvfb-run -a node tests/run_e2e.js --glob=tests/build/** + + lint: + <<: *defaults + steps: + - checkout + - restore_cache: + <<: *restore_cache_defaults + - run: npm run lint + + test: + <<: *defaults + steps: + - checkout + - restore_cache: + <<: *restore_cache_defaults + - run: npm run test + + e2e-setup: + <<: *defaults + steps: + - checkout + - restore_cache: + <<: *restore_cache_defaults + - run: mkdir /workspace + - run: mkdir /workspace/angular-cli-e2e-default + # Ignore all tests, we just want the setup step to persist it to the workspace. + - run: node tests/run_e2e.js --tmpdir=/workspace/angular-cli-e2e-default --ignore=**/* + - run: mv dist /workspace/ + - persist_to_workspace: + root: /workspace + paths: + - dist/ + - angular-cli-e2e-default/ + + e2e-0: + <<: *defaults + steps: + - checkout + - restore_cache: + <<: *restore_cache_defaults + - attach_workspace: + <<: *attach_workspace_defaults + - run: cp -r /workspace/dist/ ./ + - run: xvfb-run -a node tests/run_e2e.js --nobuild --reuse=/workspace/angular-cli-e2e-default/test-project --nb-shards=4 --shard=0 --nosilent + + e2e-1: + <<: *defaults + steps: + - checkout + - restore_cache: + <<: *restore_cache_defaults + - attach_workspace: + <<: *attach_workspace_defaults + - run: cp -r /workspace/dist/ ./ + - run: xvfb-run -a node tests/run_e2e.js --nobuild --reuse=/workspace/angular-cli-e2e-default/test-project --nb-shards=4 --shard=1 --nosilent + + e2e-2: + <<: *defaults + steps: + - checkout + - restore_cache: + <<: *restore_cache_defaults + - attach_workspace: + <<: *attach_workspace_defaults + - run: cp -r /workspace/dist/ ./ + - run: xvfb-run -a node tests/run_e2e.js --nobuild --reuse=/workspace/angular-cli-e2e-default/test-project --nb-shards=4 --shard=2 --nosilent + + e2e-3: + <<: *defaults + steps: + - checkout + - restore_cache: + <<: *restore_cache_defaults + - attach_workspace: + <<: *attach_workspace_defaults + - run: cp -r /workspace/dist/ ./ + - run: xvfb-run -a node tests/run_e2e.js --nobuild --reuse=/workspace/angular-cli-e2e-default/test-project --nb-shards=4 --shard=3 --nosilent + +workflows: + version: 2 + build_and_test: + jobs: + - build + - lint: + requires: + - build + - test: + requires: + - build + - e2e-setup: + requires: + - build + - e2e-0: + requires: + - e2e-setup + - e2e-1: + requires: + - e2e-setup + - e2e-2: + requires: + - e2e-setup + - e2e-3: + requires: + - e2e-setup diff --git a/scripts/test-commit-messages.js b/scripts/test-commit-messages.js index 07b684c0f3..223fd425e8 100644 --- a/scripts/test-commit-messages.js +++ b/scripts/test-commit-messages.js @@ -34,7 +34,7 @@ logger // Note: This is based on the gulp task found in the angular/angular repository execSync('git fetch origin'); // Travis doesn't have master when running jobs on other branches (minor/patch/etc). -execSync('git fetch origin master:master'); +execSync('git fetch origin master:master --force'); // Get PR target branch, default to master for running locally. const currentBranch = process.env.TRAVIS_BRANCH diff --git a/tests/e2e/setup/200-create-tmp-dir.ts b/tests/e2e/setup/200-create-tmp-dir.ts index e63d150721..71f1f84a2d 100644 --- a/tests/e2e/setup/200-create-tmp-dir.ts +++ b/tests/e2e/setup/200-create-tmp-dir.ts @@ -1,3 +1,4 @@ +import {dirname} from 'path'; import {setGlobalVariable, getGlobalVariable} from '../utils/env'; @@ -7,7 +8,10 @@ export default function() { const argv = getGlobalVariable('argv'); // Get to a temporary directory. - let tempRoot = argv.reuse || temp.mkdirSync('angular-cli-e2e-'); + let tempRoot = argv.tmpdir || temp.mkdirSync('angular-cli-e2e-');; + if (argv.reuse) { + tempRoot = dirname(argv.reuse); + } console.log(` Using "${tempRoot}" as temporary directory for a new project.`); setGlobalVariable('tmp-root', tempRoot); process.chdir(tempRoot); diff --git a/tests/e2e/tests/misc/typescript-warning.ts b/tests/e2e/tests/misc/typescript-warning.ts index 3c535a7e86..6b8735a3de 100644 --- a/tests/e2e/tests/misc/typescript-warning.ts +++ b/tests/e2e/tests/misc/typescript-warning.ts @@ -15,13 +15,6 @@ export default function () { } return Promise.resolve() - .then(() => silentNpm('uninstall', 'typescript', '--no-save')) - .then(() => ng('build')) - .catch((err) => { - if (!err.message.match('Versions of @angular/compiler-cli and typescript could not')) { - throw new Error('Expected to have missing dependency error in output.'); - } - }) // Warning should show. .then(() => silentNpm('install', `typescript@${unsupportedTsVersion}`, '--no-save')) .then(() => ng('build')) diff --git a/tests/e2e_runner.ts b/tests/e2e_runner.ts index 8a7d9d4964..13778f8214 100644 --- a/tests/e2e_runner.ts +++ b/tests/e2e_runner.ts @@ -41,6 +41,7 @@ Error.stackTraceLimit = Infinity; * passed in. * --shard Index of this processes' shard. * --devkit=path Path to the devkit to use. The devkit will be built prior to running. + * --tmpdir=path Override temporary directory to use for new projects. * If unnamed flags are passed in, the list of tests will be filtered to include only those passed. */ const argv = minimist(process.argv.slice(2), { @@ -54,7 +55,7 @@ const argv = minimist(process.argv.slice(2), { 'noproject', 'verbose', ], - 'string': ['devkit', 'glob', 'ignore', 'reuse', 'ng-sha', ], + 'string': ['devkit', 'glob', 'ignore', 'reuse', 'ng-sha', 'tmpdir'], 'number': ['nb-shards', 'shard'] });