Skip to content

Commit 9a72f1e

Browse files
docs(docs-infra): build examples with Ivy
1 parent 35e45dc commit 9a72f1e

File tree

7 files changed

+926
-493
lines changed

7 files changed

+926
-493
lines changed

.circleci/config.yml

+27
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,29 @@ jobs:
254254
# with either "0", "1" or "2" as node index. This can be passed to the "--shard" argument.
255255
- run: yarn --cwd aio example-e2e --setup --local --shard=${CIRCLE_NODE_INDEX}/${CIRCLE_NODE_TOTAL}
256256

257+
test_docs_examples_ivy:
258+
<<: *job_defaults
259+
docker:
260+
# Needed because the example e2e tests depend on Chrome.
261+
- image: *browsers_docker_image
262+
parallelism: 3
263+
steps:
264+
- checkout:
265+
<<: *post_checkout
266+
- restore_cache:
267+
key: *cache_key
268+
- attach_workspace:
269+
at: dist
270+
- *define_env_vars
271+
# Install root
272+
- *yarn_install
273+
# Install aio
274+
- run: yarn --cwd aio install --frozen-lockfile --non-interactive
275+
# Run examples tests with ivy. The "CIRCLE_NODE_INDEX" will be set if "parallelism" is enabled.
276+
# Since the parallelism is set to "3", there will be three parallel CircleCI containers
277+
# with either "0", "1" or "2" as node index. This can be passed to the "--shard" argument.
278+
- run: yarn --cwd aio example-e2e --setup --local --ivy --shard=${CIRCLE_NODE_INDEX}/${CIRCLE_NODE_TOTAL}
279+
257280
# This job should only be run on PR builds, where `CI_PULL_REQUEST` is not `false`.
258281
aio_preview:
259282
<<: *job_defaults
@@ -516,6 +539,9 @@ workflows:
516539
- test_docs_examples:
517540
requires:
518541
- build-packages-dist
542+
- test_docs_examples_ivy:
543+
requires:
544+
- build-packages-dist
519545
- aio_preview:
520546
# Only run on PR builds. (There can be no previews for non-PR builds.)
521547
filters:
@@ -541,6 +567,7 @@ workflows:
541567
- test_aio_local
542568
- test_aio_local_ivy
543569
- test_docs_examples
570+
- test_docs_examples_ivy
544571
# Get the artifacts to publish from the build-packages-dist job
545572
# since the publishing script expects the legacy outputs layout.
546573
- build-packages-dist

aio/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"preserve-and-sync": "yarn docs",
5858
"serve-and-sync": "run-p \"start\" \"docs-watch --watch-only\"",
5959
"boilerplate:add": "node ./tools/examples/example-boilerplate add",
60+
"boilerplate:add:ivy": "yarn boilerplate:add --ivy",
6061
"boilerplate:remove": "node ./tools/examples/example-boilerplate remove",
6162
"boilerplate:test": "node tools/examples/test.js",
6263
"generate-stackblitz": "node ./tools/stackblitz-builder/generateStackblitz",
@@ -167,4 +168,4 @@
167168
"xregexp": "^4.0.0",
168169
"yargs": "^7.0.2"
169170
}
170-
}
171+
}

aio/tools/examples/example-boilerplate.js

+16-9
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,23 @@ class ExampleBoilerPlate {
8484
/**
8585
* Add boilerplate files to all the examples
8686
*/
87-
add() {
87+
add(ivy = false) {
8888
// Get all the examples folders, indicated by those that contain a `example-config.json` file
8989
const exampleFolders = this.getFoldersContaining(EXAMPLES_BASE_PATH, EXAMPLE_CONFIG_FILENAME, 'node_modules');
90-
exampleFolders.forEach(exampleFolder => {
91-
const exampleConfig = this.loadJsonFile(path.resolve(exampleFolder, EXAMPLE_CONFIG_FILENAME));
9290

93-
if (!fs.existsSync(SHARED_NODE_MODULES_PATH)) {
94-
throw new Error(`The shared node_modules folder for the examples (${SHARED_NODE_MODULES_PATH}) is missing.\n` +
91+
if (!fs.existsSync(SHARED_NODE_MODULES_PATH)) {
92+
throw new Error(`The shared node_modules folder for the examples (${SHARED_NODE_MODULES_PATH}) is missing.\n` +
9593
`Perhaps you need to run "yarn example-use-npm" or "yarn example-use-local" to install the dependencies?`);
96-
}
94+
}
95+
96+
if (ivy) {
97+
shelljs.exec(`yarn --cwd ${SHARED_PATH} ivy-ngcc`);
98+
99+
BOILERPLATE_PATHS.common.push('src/tsconfig.app.json');
100+
}
101+
102+
exampleFolders.forEach(exampleFolder => {
103+
const exampleConfig = this.loadJsonFile(path.resolve(exampleFolder, EXAMPLE_CONFIG_FILENAME));
97104

98105
// Link the node modules - requires admin access (on Windows) because it adds symlinks
99106
const destinationNodeModules = path.resolve(exampleFolder, 'node_modules');
@@ -114,13 +121,13 @@ class ExampleBoilerPlate {
114121
* Remove all the boilerplate files from all the examples
115122
*/
116123
remove() {
117-
shelljs.exec('git clean -xdfq', {cwd: EXAMPLES_BASE_PATH});
124+
shelljs.exec('git clean -xdfq', { cwd: EXAMPLES_BASE_PATH });
118125
}
119126

120127
main() {
121128
yargs
122129
.usage('$0 <cmd> [args]')
123-
.command('add', 'add the boilerplate to each example', () => this.add())
130+
.command('add', 'add the boilerplate to each example', (yrgs) => this.add(yrgs.argv.ivy))
124131
.command('remove', 'remove the boilerplate from each example', () => this.remove())
125132
.demandCommand(1, 'Please supply a command from the list above')
126133
.argv;
@@ -144,7 +151,7 @@ class ExampleBoilerPlate {
144151
}
145152

146153
loadJsonFile(filePath) {
147-
return fs.readJsonSync(filePath, {throws: false}) || {};
154+
return fs.readJsonSync(filePath, { throws: false }) || {};
148155
}
149156

150157
normalizePath(filePath) {

aio/tools/examples/run-example-e2e.js

+17-17
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function runE2e() {
4444
// Run setup.
4545
console.log('runE2e: setup boilerplate');
4646
const installPackagesCommand = `example-use-${argv.local ? 'local' : 'npm'}`;
47-
const addBoilerplateCommand = 'boilerplate:add';
47+
const addBoilerplateCommand = `boilerplate:add${argv.ivy ? ':ivy' : ''}`;
4848
shelljs.exec(`yarn ${installPackagesCommand}`, { cwd: AIO_PATH });
4949
shelljs.exec(`yarn ${addBoilerplateCommand}`, { cwd: AIO_PATH });
5050
}
@@ -102,16 +102,16 @@ function findAndRunE2eTests(filter, outputFile, shard) {
102102
});
103103
});
104104
}, Promise.resolve())
105-
.then(() => {
106-
return e2eSpecPaths.cli.reduce((promise, specPath) => {
107-
return promise.then(() => {
108-
return runE2eTestsCLI(specPath, outputFile).then(ok => {
109-
const arr = ok ? status.passed : status.failed;
110-
arr.push(specPath);
105+
.then(() => {
106+
return e2eSpecPaths.cli.reduce((promise, specPath) => {
107+
return promise.then(() => {
108+
return runE2eTestsCLI(specPath, outputFile).then(ok => {
109+
const arr = ok ? status.passed : status.failed;
110+
arr.push(specPath);
111+
});
111112
});
112-
});
113-
}, Promise.resolve());
114-
});
113+
}, Promise.resolve());
114+
});
115115
})
116116
.then(() => {
117117
const stopTime = new Date().getTime();
@@ -172,8 +172,8 @@ function runProtractorSystemJS(prepPromise, appDir, appRunSpawnInfo, outputFile)
172172
});
173173
})
174174
.then(
175-
function () { return finish(appRunSpawnInfo.proc.pid, true); },
176-
function () { return finish(appRunSpawnInfo.proc.pid, false); }
175+
function () { return finish(appRunSpawnInfo.proc.pid, true); },
176+
function () { return finish(appRunSpawnInfo.proc.pid, false); }
177177
);
178178
}
179179

@@ -206,20 +206,20 @@ function runE2eTestsCLI(appDir, outputFile) {
206206
console.log(`\n\n=========== Running aio example tests for: ${appDir}`);
207207
// `--no-webdriver-update` is needed to preserve the ChromeDriver version already installed.
208208
const config = loadExampleConfig(appDir);
209-
const commands = config.e2e || [{ cmd: 'yarn', args: ['e2e', '--no-webdriver-update'] }];
209+
const commands = config.e2e || [{ cmd: 'yarn', args: ['e2e', (argv.ivy ? '--prod' : ''), '--no-webdriver-update'] }];
210210

211211
const e2eSpawnPromise = commands.reduce((prevSpawnPromise, { cmd, args }) => {
212212
return prevSpawnPromise.then(() => {
213213
const currSpawn = spawnExt(cmd, args, { cwd: appDir });
214214
return currSpawn.promise.then(
215-
() => Promise.resolve(finish(currSpawn.proc.pid, true)),
216-
() => Promise.reject(finish(currSpawn.proc.pid, false)));
215+
() => Promise.resolve(finish(currSpawn.proc.pid, true)),
216+
() => Promise.reject(finish(currSpawn.proc.pid, false)));
217217
});
218218
}, Promise.resolve());
219219

220220
return e2eSpawnPromise.then(
221-
() => { fs.appendFileSync(outputFile, `Passed: ${appDir}\n\n`); return true; },
222-
() => { fs.appendFileSync(outputFile, `Failed: ${appDir}\n\n`); return false; });
221+
() => { fs.appendFileSync(outputFile, `Passed: ${appDir}\n\n`); return true; },
222+
() => { fs.appendFileSync(outputFile, `Failed: ${appDir}\n\n`); return false; });
223223
}
224224

225225
// Report final status.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../out-tsc/app",
5+
"types": []
6+
},
7+
"exclude": [
8+
"test.ts",
9+
"**/*.spec.ts"
10+
],
11+
"angularCompilerOptions": {
12+
"enableIvy": "ngtsc"
13+
}
14+
}

aio/tools/examples/shared/package.json

+22-22
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,22 @@
1818
"author": "",
1919
"license": "MIT",
2020
"dependencies": {
21-
"@angular/animations": "^7.0.0",
22-
"@angular/common": "^7.0.0",
23-
"@angular/compiler": "^7.0.0",
24-
"@angular/core": "^7.0.0",
25-
"@angular/elements": "^7.0.0",
26-
"@angular/forms": "^7.0.0",
27-
"@angular/http": "^7.0.0",
28-
"@angular/platform-browser": "^7.0.0",
29-
"@angular/platform-browser-dynamic": "^7.0.0",
30-
"@angular/router": "^7.0.0",
31-
"@angular/service-worker": "^7.0.0",
32-
"@angular/upgrade": "^7.0.0",
33-
"@nguniversal/common": "^7.0.0",
34-
"@nguniversal/express-engine": "^7.0.0",
35-
"@nguniversal/module-map-ngfactory-loader": "^7.0.0",
36-
"angular-in-memory-web-api": "^0.6.0",
21+
"@angular/animations": "^7.1.0",
22+
"@angular/common": "^7.1.0",
23+
"@angular/compiler": "^7.1.0",
24+
"@angular/core": "^7.1.0",
25+
"@angular/elements": "^7.1.0",
26+
"@angular/forms": "^7.1.0",
27+
"@angular/http": "^7.1.0",
28+
"@angular/platform-browser": "^7.1.0",
29+
"@angular/platform-browser-dynamic": "^7.1.0",
30+
"@angular/router": "^7.1.0",
31+
"@angular/service-worker": "^7.1.0",
32+
"@angular/upgrade": "^7.1.0",
33+
"@nguniversal/common": "^7.1.0",
34+
"@nguniversal/express-engine": "^7.1.0",
35+
"@nguniversal/module-map-ngfactory-loader": "^7.1.0",
36+
"angular-in-memory-web-api": "git+ssh://[email protected]:brandonroberts/in-memory-web-api#14ce89b",
3737
"core-js": "^2.5.4",
3838
"express": "^4.14.1",
3939
"rxjs": "^6.3.0",
@@ -42,11 +42,11 @@
4242
"zone.js": "~0.8.26"
4343
},
4444
"devDependencies": {
45-
"@angular-devkit/build-angular": "^0.10.0",
46-
"@angular/cli": "^7.0.0",
47-
"@angular/compiler-cli": "^7.0.0",
48-
"@angular/language-service": "^7.0.0",
49-
"@angular/platform-server": "^7.0.0",
45+
"@angular-devkit/build-angular": "^0.11.0",
46+
"@angular/cli": "^7.1.0",
47+
"@angular/compiler-cli": "^7.1.0",
48+
"@angular/language-service": "^7.1.0",
49+
"@angular/platform-server": "^7.1.0",
5050
"@types/angular": "^1.6.47",
5151
"@types/angular-animate": "^1.5.10",
5252
"@types/angular-mocks": "^1.6.0",
@@ -86,4 +86,4 @@
8686
"webpack-cli": "^3.1.0"
8787
},
8888
"repository": {}
89-
}
89+
}

0 commit comments

Comments
 (0)