Skip to content

Commit 9696ff8

Browse files
committed
build: share release output between circle jobs
1 parent 0bd8899 commit 9696ff8

File tree

5 files changed

+91
-34
lines changed

5 files changed

+91
-34
lines changed

.circleci/config.yml

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ var_9: &docker-firefox-image
6060
# See the PR that fixes this: https://github.com/angular/angular/pull/26435
6161
- image: circleci/node:10.12-browsers
6262

63+
# Attaches the release output which has been stored in the workspace to the current job.
64+
# https://circleci.com/docs/2.0/workflows/#using-workspaces-to-share-data-among-jobs
65+
var_10: &attach_release_output
66+
attach_workspace:
67+
at: dist/releases
68+
6369
# -----------------------------
6470
# Container version of CircleCI
6571
# -----------------------------
@@ -86,8 +92,6 @@ jobs:
8692
- run: bazel build src/cdk/... src/lib/...
8793
- run: bazel test src/cdk/... src/lib/...
8894

89-
- *save_cache
90-
9195
# ------------------------------------------------------------------------------------------
9296
# Job that runs the unit tests on locally installed browsers (Chrome and Firefox headless).
9397
# The available browsers are installed through the angular/ngcontainer Docker image.
@@ -106,15 +110,11 @@ jobs:
106110
# variable which has been configured above
107111
- run: yarn gulp ci:test
108112

109-
- *save_cache
110-
111113
# ----------------------------------------------------------------
112-
# Job that runs the e2e tests with Protractor and Chrome w/ Xvfb. We cannot use
113-
# Chrome headless because our tests rely on APIs which are not testable in headless mode.
114-
# For example: the Fullscreen browser API.
114+
# Job that runs the e2e tests with Protractor and Chrome Headless
115115
# ----------------------------------------------------------------
116116
e2e_tests:
117-
docker: *docker-firefox-image
117+
<<: *job_defaults
118118
resource_class: xlarge
119119
steps:
120120
- *checkout_code
@@ -123,8 +123,6 @@ jobs:
123123

124124
- run: yarn gulp ci:e2e
125125

126-
- *save_cache
127-
128126
# ----------------------------------------------------------------------------
129127
# Job that runs the unit tests on Browserstack. The browsers that will be used
130128
# to run the unit tests on Browserstack are set in: test/browser-providers.js
@@ -142,39 +140,33 @@ jobs:
142140

143141
- run: ./scripts/circleci/run-browserstack-tests.sh
144142

145-
- *save_cache
146-
147-
# --------------------------------------
148-
# Job that builds the demo-app with AOT
149-
# --------------------------------------
150-
demo_app_aot:
143+
# -----------------------------------------------------------------------------------------
144+
# Job that builds the demo-app with AOT. In order to speed up this job, the release output
145+
# from the workspace storage will be attached to this job.
146+
# -----------------------------------------------------------------------------------------
147+
build_demoapp_aot:
151148
<<: *job_defaults
152-
resource_class: xlarge
153149
steps:
154150
- *checkout_code
155151
- *restore_cache
156152
- *yarn_install
153+
- *attach_release_output
157154

158155
- run: yarn gulp ci:aot
159156

160-
- *save_cache
161-
162157
# -------------------------------------------------------------------------
163158
# Job that pre-render's the universal app with `@angular/platform-server`.
164159
# This verifies that Angular Material can be rendered within Node.
165160
# -------------------------------------------------------------------------
166161
prerender_build:
167162
<<: *job_defaults
168-
resource_class: xlarge
169163
steps:
170164
- *checkout_code
171165
- *restore_cache
172166
- *yarn_install
173167

174168
- run: yarn gulp ci:prerender
175169

176-
- *save_cache
177-
178170
# ----------------------------------
179171
# Lint job. Runs the gulp lint task.
180172
# ----------------------------------
@@ -187,6 +179,27 @@ jobs:
187179

188180
- run: yarn gulp ci:lint
189181

182+
# -------------------------------------------------------------------------------------------
183+
# Job that builds all release packages with Gulp. The built packages can be then used in the
184+
# same workflow to publish snapshot builds or test the demo-app with the release packages.
185+
# -------------------------------------------------------------------------------------------
186+
build_release_packages:
187+
<<: *job_defaults
188+
resource_class: xlarge
189+
steps:
190+
- *checkout_code
191+
- *restore_cache
192+
- *yarn_install
193+
194+
- run: yarn gulp ci:build-release-packages
195+
196+
# Store the release output in the workspace storage. This means that other jobs
197+
# in the same workflow can attach the release output to their job.
198+
- persist_to_workspace:
199+
root: dist/releases
200+
paths:
201+
- "**/*"
202+
190203
- *save_cache
191204

192205
# ----------------------------------------------------------------------------------------
@@ -214,7 +227,13 @@ workflows:
214227
jobs:
215228
- e2e_tests
216229
- prerender_build
217-
- demo_app_aot
230+
231+
release_output:
232+
jobs:
233+
- build_release_packages
234+
- build_demoapp_aot:
235+
requires:
236+
- build_release_packages
218237

219238
# Lint workflow. As we want to lint in one job, this is a workflow with just one job.
220239
lint:

src/demo-app/tsconfig-aot.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"outDir": "../../dist/packages/demo-app",
1515
"rootDirs": [
1616
".",
17+
// Include the package output here because otherwise NGC won't be able to load
18+
// the SCSS files.
1719
"../../dist/packages/demo-app"
1820
],
1921
"paths": {
@@ -26,7 +28,7 @@
2628
"@angular/cdk-experimental/*": ["../../dist/releases/cdk-experimental/*"],
2729
"@angular/cdk-experimental": ["../../dist/releases/cdk-experimental"],
2830
"@angular/material-moment-adapter": ["../../dist/releases/material-moment-adapter"],
29-
"@angular/material-examples": ["../../dist/packages/material-examples"]
31+
"@angular/material-examples": ["../../dist/releases/material-examples"]
3032
}
3133
},
3234
"files": [

tools/gulp/packages.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,13 @@ cdkPackage.copySecondaryEntryPointStylesToRoot = true;
2424
// Build and copy the schematics of the CDK and Material package.
2525
cdkPackage.hasSchematics = true;
2626
materialPackage.hasSchematics = true;
27+
28+
/** List of all build packages defined for this project. */
29+
export const allBuildPackages = [
30+
cdkPackage,
31+
materialPackage,
32+
cdkExperimentalPackage,
33+
materialExperimentalPackage,
34+
momentAdapterPackage,
35+
examplesPackage
36+
];

tools/gulp/tasks/aot.ts

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,24 @@ const demoAppSource = join(packagesDir, 'demo-app');
1111
/** Path to the tsconfig file that builds the AOT files. */
1212
const tsconfigFile = join(demoAppSource, 'tsconfig-aot.json');
1313

14+
/**
15+
* Build the demo-app wit the release output in order confirm that the library is
16+
* working with AOT compilation enabled.
17+
*/
18+
task('build-aot', sequenceTask(
19+
'clean',
20+
['build-aot:release-packages', 'build-aot:assets'],
21+
'build-aot:compiler-cli'
22+
));
23+
24+
/**
25+
* Task that can be used to build the demo-app with AOT without building the
26+
* release output. This can be run if the release output is already built.
27+
*/
28+
task('build-aot:no-release-build', sequenceTask('build-aot:assets', 'build-aot:compiler-cli'));
29+
1430
/** Builds the demo-app assets and builds the required release packages. */
15-
task('aot:deps', sequenceTask(
31+
task('build-aot:release-packages', sequenceTask(
1632
[
1733
'cdk:build-release',
1834
'material:build-release',
@@ -21,15 +37,15 @@ task('aot:deps', sequenceTask(
2137
'material-moment-adapter:build-release',
2238
'material-examples:build-release',
2339
],
24-
// Build the assets after the releases have been built, because the demo-app assets import
25-
// SCSS files from the release packages.
26-
[':build:devapp:assets', ':build:devapp:scss'],
2740
));
2841

29-
/** Build the demo-app and a release to confirm that the library is AOT-compatible. */
30-
task('aot:build', sequenceTask('clean', 'aot:deps', 'aot:compiler-cli'));
42+
/**
43+
* Task that builds the assets which are required for building with AOT. Since the demo-app uses
44+
* Sass files, we need to provide the transpiled CSS sources in the package output.
45+
*/
46+
task('build-aot:assets', [':build:devapp:assets', ':build:devapp:scss']);
3147

3248
/** Build the demo-app and a release to confirm that the library is AOT-compatible. */
33-
task('aot:compiler-cli', execNodeTask(
49+
task('build-aot:compiler-cli', execNodeTask(
3450
'@angular/compiler-cli', 'ngc', ['-p', tsconfigFile]
3551
));

tools/gulp/tasks/ci.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {task} from 'gulp';
2-
2+
import {sequenceTask} from 'material2-build-tools';
3+
import {allBuildPackages} from '../packages';
34

45
task('ci:lint', ['lint']);
56

@@ -8,8 +9,11 @@ task('ci:test', ['test:single-run'], () => process.exit(0));
89

910
task('ci:e2e', ['e2e']);
1011

11-
/** Task to verify that all components work with AOT compilation. */
12-
task('ci:aot', ['aot:build']);
12+
/**
13+
* Task to verify that all components work with AOT compilation. This task requires the
14+
* release output to be built already.
15+
*/
16+
task('ci:aot', ['build-aot:no-release-build']);
1317

1418
/** Task which reports the size of the library and stores it in a database. */
1519
task('ci:payload', ['payload']);
@@ -19,3 +23,9 @@ task('ci:coverage', ['coverage:upload']);
1923

2024
/** Task that verifies if all Material components are working with platform-server. */
2125
task('ci:prerender', ['prerender']);
26+
27+
/** Task that builds all release packages. */
28+
task('ci:build-release-packages', sequenceTask(
29+
'clean',
30+
allBuildPackages.map(buildPackage => `${buildPackage.name}:build-release`)
31+
));

0 commit comments

Comments
 (0)