Skip to content

Commit

Permalink
ci: add ivy track for all prs
Browse files Browse the repository at this point in the history
  • Loading branch information
filipesilva authored and mgechev committed Mar 29, 2019
1 parent 8d82e98 commit 27a84a8
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 25 deletions.
21 changes: 7 additions & 14 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,24 +106,17 @@ jobs:
path: /tmp/dist
destination: cli/new-production

e2e-cli-ng-snapshots:
e2e-cli-ivy:
<<: *defaults
environment:
BASH_ENV: ~/.profile
resource_class: xlarge
parallelism: 4
steps:
- run:
name: Don't run expensive e2e tests for forks other than renovate-bot and angular
command: >
if [[ "$CIRCLE_PR_USERNAME" != "renovate-bot" ]] &&
[[ "$CIRCLE_PROJECT_USERNAME" != "angular" || $CIRCLE_BRANCH != "master" ]]; then
circleci step halt
fi
- attach_workspace: *attach_options
- run: xvfb-run -a node ./tests/legacy-cli/run_e2e --nb-shards=${CIRCLE_NODE_TOTAL} --shard=${CIRCLE_NODE_INDEX} --ng-snapshots
- run: xvfb-run -a node ./tests/legacy-cli/run_e2e --nb-shards=${CIRCLE_NODE_TOTAL} --shard=${CIRCLE_NODE_INDEX} --ivy

e2e-cli-ivy-snapshots:
e2e-cli-ng-snapshots:
<<: *defaults
environment:
BASH_ENV: ~/.profile
Expand All @@ -138,7 +131,7 @@ jobs:
circleci step halt
fi
- attach_workspace: *attach_options
- run: xvfb-run -a node ./tests/legacy-cli/run_e2e --nb-shards=${CIRCLE_NODE_TOTAL} --shard=${CIRCLE_NODE_INDEX} --ng-snapshots --ivy
- run: xvfb-run -a node ./tests/legacy-cli/run_e2e --nb-shards=${CIRCLE_NODE_TOTAL} --shard=${CIRCLE_NODE_INDEX} --ng-snapshots

build:
<<: *defaults
Expand Down Expand Up @@ -210,6 +203,9 @@ workflows:
- e2e-cli:
requires:
- build
- e2e-cli-ivy:
requires:
- build
- snapshot_publish_docs:
requires:
- install
Expand All @@ -220,9 +216,6 @@ workflows:
- e2e-cli-ng-snapshots:
requires:
- build
- e2e-cli-ivy-snapshots:
requires:
- build
- snapshot_publish:
requires:
- test
Expand Down
10 changes: 7 additions & 3 deletions tests/legacy-cli/e2e/tests/basic/rebuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
import {writeFile, writeMultipleFiles} from '../../utils/fs';
import {wait} from '../../utils/utils';
import {request} from '../../utils/http';
import {getGlobalVariable} from '../../utils/env';

const validBundleRegEx = /: Compiled successfully./;

Expand All @@ -15,7 +16,10 @@ export default function() {
return Promise.resolve();
}

const lazyChunkRegExp = /lazy-module\.js/g;
const argv = getGlobalVariable('argv');
const ivyProject = argv['ivy'];
const lazyImport = ivyProject ? `() => import('./lazy/lazy.module').then(m => m.LazyModule)`
: `'./lazy/lazy.module#LazyModule'`;

return execAndWaitForOutputToMatch('ng', ['serve'], validBundleRegEx)
// Add a lazy module.
Expand Down Expand Up @@ -43,7 +47,7 @@ export default function() {
FormsModule,
HttpClientModule,
RouterModule.forRoot([
{ path: 'lazy', loadChildren: './lazy/lazy.module#LazyModule' }
{ path: 'lazy', loadChildren: ${lazyImport} }
])
],
providers: [],
Expand All @@ -55,7 +59,7 @@ export default function() {
// Count the bundles.
.then((results) => {
const stdout = results[0].stdout;
if (!lazyChunkRegExp.test(stdout)) {
if (!/(lazy-module|0)\.js/g.test(stdout)) {
throw new Error('Expected webpack to create a new chunk, but did not.');
}
})
Expand Down
29 changes: 21 additions & 8 deletions tests/legacy-cli/e2e/tests/misc/lazy-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,19 @@ import {readdirSync} from 'fs';

import {ng, silentNpm} from '../../utils/process';
import {appendToFile, writeFile, prependToFile, replaceInFile} from '../../utils/fs';
import {getGlobalVariable} from '../../utils/env';


export default function() {
const argv = getGlobalVariable('argv');
const ivyProject = argv['ivy'];
const lazyImport = ivyProject ? `() => import('src/app/lazy/lazy.module').then(m => m.LazyModule)`
: `'src/app/lazy/lazy.module#LazyModule'`;
const lazyImport1 = ivyProject ? `() => import('./lazy/lazy.module').then(m => m.LazyModule)`
: `'./lazy/lazy.module#LazyModule'`;
const lazyImport2 = ivyProject ? `() => import('./too/lazy/lazy.module').then(m => m.LazyModule)`
: `'./too/lazy/lazy.module#LazyModule'`;

let oldNumberOfFiles = 0;
return Promise.resolve()
.then(() => ng('build'))
Expand All @@ -15,9 +25,9 @@ export default function() {
import { RouterModule } from '@angular/router';
`))
.then(() => replaceInFile('src/app/app.module.ts', 'imports: [', `imports: [
RouterModule.forRoot([{ path: "lazy", loadChildren: "src/app/lazy/lazy.module#LazyModule" }]),
RouterModule.forRoot([{ path: "lazy1", loadChildren: "./lazy/lazy.module#LazyModule" }]),
RouterModule.forRoot([{ path: "lazy2", loadChildren: "./too/lazy/lazy.module#LazyModule" }]),
RouterModule.forRoot([{ path: "lazy", loadChildren: ${lazyImport} }]),
RouterModule.forRoot([{ path: "lazy1", loadChildren: ${lazyImport1} }]),
RouterModule.forRoot([{ path: "lazy2", loadChildren: ${lazyImport2} }]),
`))
.then(() => ng('build', '--named-chunks'))
.then(() => readdirSync('dist/test-project'))
Expand All @@ -28,11 +38,14 @@ export default function() {
}
oldNumberOfFiles = currentNumberOfDistFiles;

if (!distFiles.includes('lazy-lazy-module.js')) {
throw new Error('The lazy module chunk did not have a name.');
}
if (!distFiles.includes('too-lazy-lazy-module.js')) {
throw new Error('The lazy module chunk did not use a unique name.');
// Named lazy route chunks are not available with Ivy.
if (!ivyProject) {
if (!distFiles.includes('lazy-lazy-module.js')) {
throw new Error('The lazy module chunk did not have a name.');
}
if (!distFiles.includes('too-lazy-lazy-module.js')) {
throw new Error('The lazy module chunk did not use a unique name.');
}
}
})
// verify System.import still works
Expand Down
2 changes: 2 additions & 0 deletions tests/legacy-cli/e2e_runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ if (argv.ivy) {
.filter(name => !name.endsWith('tests/build/aot/aot-i18n.ts'))
// We don't have a library consumption story yet for Ivy.
.filter(name => !name.endsWith('tests/generate/library/library-consumption.ts'))
// The additional lazy modules array does not work with Ivy because it's not needed.
.filter(name => !name.endsWith('tests/build/dynamic-import.ts'))
// We don't have a platform-server usage story yet for Ivy.
// It's contingent on lazy loading and factory shim considerations that are still being
// discussed.
Expand Down

0 comments on commit 27a84a8

Please sign in to comment.