diff --git a/.circleci/config.yml b/.circleci/config.yml index 8b64c1c775..81b8527ca0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,29 +3,96 @@ # Check https://circleci.com/docs/2.0/language-javascript/ for more details # version: 2 + +defaults: &defaults + working_directory: ~/repo + docker: + - image: circleci/node:8.12.0-stretch-browsers + jobs: build: - docker: - - image: circleci/node:8.12.0-stretch-browsers - working_directory: ~/repo + <<: *defaults steps: - checkout - restore_cache: keys: - - yarn-dependencies-v7-{{ .Branch }}-{{ checksum "yarn.lock" }} - - yarn-dependencies-v7-{{ .Branch }}- + - yarn-dependencies-v9-{{ .Branch }}-{{ checksum "yarn.lock" }} + - yarn-dependencies-v9-{{ .Branch }}- # fallback to using the latest cache if no exact match is found - - yarn-dependencies-v7- + - yarn-dependencies-v9- - run: yarn install --frozen-lockfile --non-interactive - - run: npx cypress verify - - run: yarn start prepare.e2e.and.check-formatting + - run: yarn start format.and.lint.check - save_cache: - key: yarn-dependencies-v7-{{ .Branch }}-{{ checksum "yarn.lock" }} + key: yarn-dependencies-v9-{{ .Branch }}-{{ checksum "yarn.lock" }} paths: - ~/.cache + - run: yarn start dev.gen-graphql - run: yarn start test.affected.origin-master + - run: rm -rf node-modules/ + - persist_to_workspace: + root: ~/ + paths: + - repo + + cypress-1: + <<: *defaults + steps: + - attach_workspace: + at: ~/ + - restore_cache: + keys: + - yarn-dependencies-v9-{{ .Branch }}-{{ checksum "yarn.lock" }} + - run: yarn install --frozen-lockfile --non-interactive + - run: yarn start prepare.e2e + - run: + command: yarn start e2e.ci1 + no_output_timeout: 5m + environment: + CYPRESS_RECORD_KEY: b8ec9ad7-505f-48bb-9990-e8d5627bac26 + + cypress-2: + <<: *defaults + steps: + - attach_workspace: + at: ~/ + - restore_cache: + keys: + - yarn-dependencies-v9-{{ .Branch }}-{{ checksum "yarn.lock" }} + - run: yarn install --frozen-lockfile --non-interactive + - run: yarn start prepare.e2e + - run: + command: yarn start e2e.ci2 + no_output_timeout: 5m + environment: + CYPRESS_RECORD_KEY: b8ec9ad7-505f-48bb-9990-e8d5627bac26 + + cypress-3: + <<: *defaults + steps: + - attach_workspace: + at: ~/ + - restore_cache: + keys: + - yarn-dependencies-v9-{{ .Branch }}-{{ checksum "yarn.lock" }} + - run: yarn install --frozen-lockfile --non-interactive + - run: yarn start prepare.e2e - run: - command: yarn start e2e.ci + command: yarn start e2e.ci3 no_output_timeout: 5m environment: CYPRESS_RECORD_KEY: b8ec9ad7-505f-48bb-9990-e8d5627bac26 + +workflows: + version: 2 + build_and_test: + jobs: + - build + - cypress-1: + requires: + - build + - cypress-2: + requires: + - build + - cypress-3: + requires: + - build diff --git a/angular.json b/angular.json index 661f2dc085..4501e5f1cf 100644 --- a/angular.json +++ b/angular.json @@ -129,6 +129,20 @@ "options": { "cypressConfig": "apps/angular-console-e2e/cypress.json", "tsConfig": "apps/angular-console-e2e/tsconfig.e2e.json" + }, + "configurations": { + "ci1": { + "cypressConfig": "apps/angular-console-e2e/cypress.json", + "tsConfig": "apps/angular-console-e2e/tsconfig.ci-1.json" + }, + "ci2": { + "cypressConfig": "apps/angular-console-e2e/cypress.json", + "tsConfig": "apps/angular-console-e2e/tsconfig.ci-2.json" + }, + "ci3": { + "cypressConfig": "apps/angular-console-e2e/cypress.json", + "tsConfig": "apps/angular-console-e2e/tsconfig.ci-3.json" + } } }, "lint": { diff --git a/apps/angular-console-e2e/src/integration/extensions.spec.ts b/apps/angular-console-e2e/src/integration/extensions.spec.ts index e468f5726f..9a8da57a55 100644 --- a/apps/angular-console-e2e/src/integration/extensions.spec.ts +++ b/apps/angular-console-e2e/src/integration/extensions.spec.ts @@ -11,8 +11,8 @@ import { waitForActionToComplete, whitelistGraphql, elementContainsText -} from './utils'; -import { clearAllRecentTasks } from './tasks.utils'; +} from '../support/utils'; +import { clearAllRecentTasks } from '../support/tasks.utils'; describe('Extensions', () => { beforeEach(() => { diff --git a/apps/angular-console-e2e/src/integration/forms.spec.ts b/apps/angular-console-e2e/src/integration/forms.spec.ts index e4d51a731f..ce4e4e62c6 100644 --- a/apps/angular-console-e2e/src/integration/forms.spec.ts +++ b/apps/angular-console-e2e/src/integration/forms.spec.ts @@ -10,7 +10,7 @@ import { uniqName, whitelistGraphql, elementContainsText -} from './utils'; +} from '../support/utils'; describe('Forms', () => { beforeEach(() => { diff --git a/apps/angular-console-e2e/src/integration/generate-workspace-schematics.spec.ts b/apps/angular-console-e2e/src/integration/generate-workspace-schematics.spec.ts index af0620f4b7..858558a1c3 100644 --- a/apps/angular-console-e2e/src/integration/generate-workspace-schematics.spec.ts +++ b/apps/angular-console-e2e/src/integration/generate-workspace-schematics.spec.ts @@ -10,8 +10,8 @@ import { uniqName, whitelistGraphql, elementContainsText -} from './utils'; -import { clearRecentTask } from './tasks.utils'; +} from '../support/utils'; +import { clearRecentTask } from '../support/tasks.utils'; describe('Generate Workspace Schematics', () => { beforeEach(() => { diff --git a/apps/angular-console-e2e/src/integration/generate.spec.ts b/apps/angular-console-e2e/src/integration/generate.spec.ts index c2f6ba1783..8335d724fc 100644 --- a/apps/angular-console-e2e/src/integration/generate.spec.ts +++ b/apps/angular-console-e2e/src/integration/generate.spec.ts @@ -11,8 +11,8 @@ import { uniqName, whitelistGraphql, elementContainsText -} from './utils'; -import { clearRecentTask } from './tasks.utils'; +} from '../support/utils'; +import { clearRecentTask } from '../support/tasks.utils'; describe('Generate', () => { beforeEach(() => { diff --git a/apps/angular-console-e2e/src/integration/no_node_modules.spec.ts b/apps/angular-console-e2e/src/integration/no_node_modules.spec.ts index dc1a8992a0..ddfab8153a 100644 --- a/apps/angular-console-e2e/src/integration/no_node_modules.spec.ts +++ b/apps/angular-console-e2e/src/integration/no_node_modules.spec.ts @@ -9,7 +9,7 @@ import { taskListHeaders, texts, whitelistGraphql -} from './utils'; +} from '../support/utils'; describe('Project without node modules', () => { beforeEach(() => { diff --git a/apps/angular-console-e2e/src/integration/projects.spec.ts b/apps/angular-console-e2e/src/integration/projects.spec.ts index 49951a1b90..43f529869b 100644 --- a/apps/angular-console-e2e/src/integration/projects.spec.ts +++ b/apps/angular-console-e2e/src/integration/projects.spec.ts @@ -5,7 +5,7 @@ import { texts, whitelistGraphql, elementContainsText -} from './utils'; +} from '../support/utils'; describe('Projects', () => { beforeEach(() => { diff --git a/apps/angular-console-e2e/src/integration/tasks.spec.ts b/apps/angular-console-e2e/src/integration/tasks.spec.ts index 92597dd5d6..2331a141b6 100644 --- a/apps/angular-console-e2e/src/integration/tasks.spec.ts +++ b/apps/angular-console-e2e/src/integration/tasks.spec.ts @@ -11,7 +11,7 @@ import { texts, whitelistGraphql, elementContainsText -} from './utils'; +} from '../support/utils'; import { checkMultipleRecentTasks, checkSingleRecentTask, @@ -19,7 +19,7 @@ import { toggleRecentTasksExpansion, checkActionBarHidden, clearAllRecentTasks -} from './tasks.utils'; +} from '../support/tasks.utils'; const PASSING_TESTS = ` import { TestBed, async } from '@angular/core/testing'; diff --git a/apps/angular-console-e2e/src/integration/workspaces.spec.ts b/apps/angular-console-e2e/src/integration/workspaces.spec.ts index 888bbdd10f..7f63c7daed 100644 --- a/apps/angular-console-e2e/src/integration/workspaces.spec.ts +++ b/apps/angular-console-e2e/src/integration/workspaces.spec.ts @@ -3,7 +3,7 @@ import { checkButtonIsDisabled, selectFolder, uniqName -} from './utils'; +} from '../support/utils'; describe('Workspaces', () => { const name = uniqName('workspace'); diff --git a/apps/angular-console-e2e/src/integration/tasks.utils.ts b/apps/angular-console-e2e/src/support/tasks.utils.ts similarity index 97% rename from apps/angular-console-e2e/src/integration/tasks.utils.ts rename to apps/angular-console-e2e/src/support/tasks.utils.ts index 36a3908f12..063607b98e 100644 --- a/apps/angular-console-e2e/src/integration/tasks.utils.ts +++ b/apps/angular-console-e2e/src/support/tasks.utils.ts @@ -1,4 +1,4 @@ -import { elementContainsText } from './utils'; +import { elementContainsText } from '../support/utils'; interface Task { command: string; diff --git a/apps/angular-console-e2e/src/integration/utils.ts b/apps/angular-console-e2e/src/support/utils.ts similarity index 100% rename from apps/angular-console-e2e/src/integration/utils.ts rename to apps/angular-console-e2e/src/support/utils.ts diff --git a/apps/angular-console-e2e/tsconfig.ci-1.json b/apps/angular-console-e2e/tsconfig.ci-1.json new file mode 100644 index 0000000000..374a09c3dc --- /dev/null +++ b/apps/angular-console-e2e/tsconfig.ci-1.json @@ -0,0 +1,15 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "sourceMap": false, + "outDir": "../../dist/out-tsc/apps/angular-console-e2e/src", + "lib": ["es2015", "dom"], + "types": ["cypress", "node"] + }, + "exclude": ["src/integration/*.spec.ts"], + "files": [ + "src/integration/extensions.spec.ts", + "src/integration/generate-workspace-schematics.spec.ts", + "src/integration/generate.spec.ts" + ] +} diff --git a/apps/angular-console-e2e/tsconfig.ci-2.json b/apps/angular-console-e2e/tsconfig.ci-2.json new file mode 100644 index 0000000000..3c722cc042 --- /dev/null +++ b/apps/angular-console-e2e/tsconfig.ci-2.json @@ -0,0 +1,15 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "sourceMap": false, + "outDir": "../../dist/out-tsc/apps/angular-console-e2e/src", + "lib": ["es2015", "dom"], + "types": ["cypress", "node"] + }, + "exclude": ["src/integration/*.spec.ts"], + "files": [ + "src/integration/no_node_modules.spec.ts", + "src/integration/projects.spec.ts", + "src/integration/workspaces.spec.ts" + ] +} diff --git a/apps/angular-console-e2e/tsconfig.ci-3.json b/apps/angular-console-e2e/tsconfig.ci-3.json new file mode 100644 index 0000000000..3efe098dab --- /dev/null +++ b/apps/angular-console-e2e/tsconfig.ci-3.json @@ -0,0 +1,11 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "sourceMap": false, + "outDir": "../../dist/out-tsc/apps/angular-console-e2e/src", + "lib": ["es2015", "dom"], + "types": ["cypress", "node"] + }, + "exclude": ["src/integration/*.spec.ts"], + "files": ["src/integration/forms.spec.ts", "src/integration/tasks.spec.ts"] +} diff --git a/package-scripts.js b/package-scripts.js index a05c3128a8..ba073a6e9a 100644 --- a/package-scripts.js +++ b/package-scripts.js @@ -189,7 +189,11 @@ module.exports = { default: 'node ./tools/scripts/e2e.js --headless', 'new-fixtures': nps.series.nps('prepare.e2e', 'e2e.headless') }, - ci: 'node ./tools/scripts/e2e.js --headless --record' + ci1: + 'node ./tools/scripts/e2e.js --headless --record --configuration=ci1', + ci2: + 'node ./tools/scripts/e2e.js --headless --record --configuration=ci2', + ci3: 'node ./tools/scripts/e2e.js --headless --record --configuration=ci3' }, format: { default: 'nx format:write', diff --git a/tools/scripts/set-up-e2e-fixtures.js b/tools/scripts/set-up-e2e-fixtures.js index a4c6ab0a77..d77c87168a 100644 --- a/tools/scripts/set-up-e2e-fixtures.js +++ b/tools/scripts/set-up-e2e-fixtures.js @@ -6,6 +6,11 @@ const fs = require('fs'); console.log(`setting up fixtures`); +let flags = process.argv.slice(2); + +if (flags.includes('--ci-1')) { +} + shell.rm('-rf', 'tmp'); shell.mkdir('tmp'); @@ -19,49 +24,37 @@ cp.execSync('yarn add @angular/cli@7.3.1', { cwd: path.join(tmp, 'ng') }); cp.execSync('yarn add @nrwl/schematics@7.5.2', { cwd: path.join(tmp, 'ng') }); cp.execSync('ng config -g cli.packageManager yarn'); -cp.exec( +cp.execSync( `${path.join( tmp, 'ng' )}/node_modules/.bin/ng new proj --collection=@schematics/angular --directory=proj --skip-git --no-interactive`, - { cwd: tmp, stdio: [0, 1, 2] }, - () => { - const angularJson = JSON.parse( - fs.readFileSync(path.join(tmp, 'proj', 'angular.json')).toString() - ); - angularJson.schematics = { - '@schematics/angular:service': { - flat: false - } - }; - fs.writeFileSync( - path.join(tmp, 'proj', 'angular.json'), - JSON.stringify(angularJson, null, 2) - ); - - const karma = fs - .readFileSync(path.join(tmp, 'proj', 'src', 'karma.conf.js')) - .toString(); - fs.writeFileSync( - path.join(tmp, 'proj', 'src', 'karma.conf.js'), - karma.replace('Chrome', 'ChromeHeadless') - ); + { cwd: tmp, stdio: [0, 1, 2] } +); - shell.mv(path.join(tmp, 'proj'), './tmp/proj'); +const angularJson = JSON.parse( + fs.readFileSync(path.join(tmp, 'proj', 'angular.json')).toString() +); +angularJson.schematics = { + '@schematics/angular:service': { + flat: false } +}; +fs.writeFileSync( + path.join(tmp, 'proj', 'angular.json'), + JSON.stringify(angularJson, null, 2) ); -cp.exec( - `${path.join( - tmp, - 'ng' - )}/node_modules/.bin/ng new proj-extensions --collection=@schematics/angular --directory=proj-extensions --skip-git --no-interactive`, - { cwd: tmp, stdio: [0, 1, 2] }, - () => { - shell.mv(path.join(tmp, 'proj-extensions'), './tmp/proj-extensions'); - } +const karma = fs + .readFileSync(path.join(tmp, 'proj', 'src', 'karma.conf.js')) + .toString(); +fs.writeFileSync( + path.join(tmp, 'proj', 'src', 'karma.conf.js'), + karma.replace('Chrome', 'ChromeHeadless') ); +shell.mv(path.join(tmp, 'proj'), './tmp/proj'); + cp.exec( `${path.join( tmp, @@ -76,13 +69,21 @@ cp.exec( } ); -cp.exec( +cp.execSync( `${path.join( tmp, 'ng' - )}/node_modules/.bin/ng new proj-nx --collection=@nrwl/schematics --directory=proj-nx --skip-git --no-interactive`, - { cwd: tmp, stdio: [0, 1, 2] }, - () => { - shell.mv(path.join(tmp, 'proj-nx'), './tmp/proj-nx'); - } + )}/node_modules/.bin/ng new proj-extensions --collection=@schematics/angular --directory=proj-extensions --skip-git --no-interactive`, + { cwd: tmp, stdio: [0, 1, 2] } ); +shell.mv(path.join(tmp, 'proj-extensions'), './tmp/proj-extensions'); + +cp.execSync( + `${path.join( + tmp, + 'ng' + )}/node_modules/.bin/ng new proj-nx --minimal --collection=@nrwl/schematics --directory=proj-nx --skip-git --no-interactive`, + { cwd: tmp, stdio: [0, 1, 2] } +); + +shell.mv(path.join(tmp, 'proj-nx'), './tmp/proj-nx');