Skip to content

Commit 225906e

Browse files
committed
CI stuff
1 parent a142ccd commit 225906e

File tree

4 files changed

+42
-39
lines changed

4 files changed

+42
-39
lines changed

gulpfile.js

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const outLibDir = path.join(outDir, '@angular2-material');
3636
/**
3737
* Create a TS Build Task, based on the options.
3838
*/
39-
function makeTsBuildTask(options) {
39+
function createTsBuildTask(options) {
4040
const tsConfigDir = options.tsConfigPath;
4141
const tsConfigPath = path.join(tsConfigDir, 'tsconfig.json');
4242
const tsConfig = JSON.parse(fs.readFileSync(tsConfigPath, 'utf-8'));
@@ -64,7 +64,7 @@ function makeTsBuildTask(options) {
6464
/**
6565
* Create a SASS Build Task.
6666
*/
67-
function makeSassBuildTask(options) {
67+
function createSassBuildTask(options) {
6868
const dest = options.dest;
6969
const glob = path.join(options.root, '**/*.scss');
7070
const sassOptions = {
@@ -84,7 +84,7 @@ function makeSassBuildTask(options) {
8484
/**
8585
* Create a Gulp task that executes a process.
8686
*/
87-
function makeExecTask(packageName, executable, args) {
87+
function createExecTask(packageName, executable, args) {
8888
if (!args) {
8989
args = executable;
9090
executable = undefined;
@@ -106,13 +106,13 @@ function makeExecTask(packageName, executable, args) {
106106
/***************************************************************************************************
107107
* Components Build Tasks.
108108
*/
109-
gulp.task(':build:components:ts', makeTsBuildTask({ tsConfigPath: componentsDir }));
109+
gulp.task(':build:components:ts', createTsBuildTask({ tsConfigPath: componentsDir }));
110110
gulp.task(':build:components:assets', function() {
111111
return gulp.src(path.join(componentsDir, '*/**/*.!(ts|spec.ts)'))
112112
.pipe(gulp.dest(outLibDir));
113113
});
114114
gulp.task(':build:components:scss', function() {
115-
const cssTask = makeSassBuildTask({
115+
const cssTask = createSassBuildTask({
116116
dest: outLibDir,
117117
root: componentsDir,
118118
includePaths: path.join(componentsDir, 'core/style')
@@ -131,16 +131,16 @@ gulp.task('build:components', [
131131
], function() {
132132
inlineResources([outLibDir]);
133133
});
134-
gulp.task(':build:components:ngc', ['build:components'], makeExecTask(
134+
gulp.task(':build:components:ngc', ['build:components'], createExecTask(
135135
'@angular/compiler-cli', 'ngc', ['-p', path.relative(__dirname, componentsDir)]
136136
));
137137

138138

139139
/***************************************************************************************************
140140
* DevApp Build Tasks.
141141
*/
142-
gulp.task(':build:devapp:ts', [':build:components:ts'], makeTsBuildTask({ tsConfigPath: devAppDir }));
143-
gulp.task(':build:devapp:scss', [':build:components:scss'], makeSassBuildTask({
142+
gulp.task(':build:devapp:ts', [':build:components:ts'], createTsBuildTask({ tsConfigPath: devAppDir }));
143+
gulp.task(':build:devapp:scss', [':build:components:scss'], createSassBuildTask({
144144
dest: outDir,
145145
root: devAppDir,
146146
// Change this once we have a better strategy for releasing SCSS files.
@@ -177,8 +177,8 @@ gulp.task('build:devapp', [
177177
/***************************************************************************************************
178178
* DevApp Build Tasks.
179179
*/
180-
gulp.task(':build:e2eapp:ts', [':build:components:ts'], makeTsBuildTask({ tsConfigPath: e2eAppDir }));
181-
gulp.task(':build:e2eapp:scss', [':build:components:scss'], makeSassBuildTask({
180+
gulp.task(':build:e2eapp:ts', [':build:components:ts'], createTsBuildTask({ tsConfigPath: e2eAppDir }));
181+
gulp.task(':build:e2eapp:scss', [':build:components:scss'], createSassBuildTask({
182182
dest: outDir,
183183
root: e2eAppDir,
184184
// Change this once we have a better strategy for releasing SCSS files.
@@ -221,6 +221,7 @@ gulp.task('default', ['help']);
221221
gulp.task('help', function() {
222222
const tasks = Object.keys(gulp.tasks)
223223
.filter(x => !x.startsWith(':'))
224+
.filter(x => !x.startsWith('ci:'))
224225
.filter(x => x != 'default')
225226
.sort();
226227

@@ -243,6 +244,10 @@ gulp.task(':clean:assets', function() {
243244
.pipe(gulpClean());
244245
});
245246

247+
gulp.task('lint', createExecTask('tslint', ['-c', 'tslint.json', '\'src/**/*.ts\'']));
248+
gulp.task('stylelint', createExecTask(
249+
'stylelint', ['stylelint', '\'src/**/*.scss\'', '--config stylelint-config.json', '--syntax scss']
250+
));
246251

247252
/***************************************************************************************************
248253
* Watch Tasks.
@@ -319,9 +324,9 @@ gulp.task('test:single-run', function(done) {
319324
}, done).start();
320325
});
321326

322-
gulp.task(':test:protractor:setup', makeExecTask('protractor', 'webdriver-manager', ['update']));
327+
gulp.task(':test:protractor:setup', createExecTask('protractor', 'webdriver-manager', ['update']));
323328

324-
gulp.task(':test:protractor', makeExecTask(
329+
gulp.task(':test:protractor', createExecTask(
325330
'protractor', [path.join(__dirname, 'test/protractor.conf.js')]
326331
));
327332

@@ -359,3 +364,15 @@ gulp.task('build:release', function(done) {
359364
done
360365
);
361366
});
367+
368+
369+
/***************************************************************************************************
370+
* Continuous Integration.
371+
*/
372+
gulp.task('ci:lint', ['lint', 'stylelint']);
373+
gulp.task('ci:test', ['test']);
374+
gulp.task('ci:e2e', ['e2e']);
375+
gulp.task('ci:extract-metadata', [':build:components:ngc']);
376+
gulp.task('ci:forbidden-identifiers', function() {
377+
require('./scripts/ci/forbidden-identifiers.js');
378+
});

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88
"url": "https://github.com/angular/material2.git"
99
},
1010
"scripts": {
11-
"ci:forbidden-identifiers": "node ./scripts/ci/forbidden-identifiers.js",
1211
"build": "gulp build",
1312
"demo-app": "gulp serve:devapp",
14-
"test": "karma start test/karma.conf.js",
15-
"tslint": "tslint -c tslint.json 'src/**/*.ts'",
16-
"stylelint": "stylelint 'src/**/*.scss' --config stylelint-config.json --syntax scss",
13+
"test": "gulp test",
14+
"tslint": "gulp lint",
15+
"stylelint": "gulp lint",
1716
"check-circular-deps": "madge --circular ./dist",
18-
"e2e": "protractor test/protractor.conf.js",
17+
"e2e": "gulp e2e",
1918
"deploy": "firebase deploy",
2019
"webdriver-manager": "webdriver-manager"
2120
},

scripts/ci/build-and-test.sh

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,23 @@ start_tunnel
1414

1515
wait_for_tunnel
1616
if is_lint; then
17-
npm run tslint
18-
npm run ci:forbidden-identifiers
19-
npm run stylelint
17+
$(npm bin)/gulp ci:lint
18+
$(npm bin)/gulp ci:forbidden-identifiers
2019
elif is_circular_deps_check; then
2120
# Build first because madge needs the JavaScript output.
2221
$(npm bin)/gulp build
2322
npm run check-circular-deps
2423
elif is_e2e; then
25-
# Start up the e2e app. This will take some time.
26-
echo "Starting e2e app"
27-
$(npm bin)/gulp serve:e2eapp &
28-
sleep 1
29-
30-
# Wait until the dist/ directory is created, indicating that the e2e app is ready.
31-
# Use the presence of `button.js` to determine whether the compiled output is ready to be served.
32-
echo "Waiting for e2e app to start"
33-
while [ ! -f ./dist/components/button/button.js ]; do
34-
sleep 2
35-
echo -n ".."
36-
done
37-
3824
# Run the e2e tests on the served e2e app.
3925
echo "Starting e2e tests"
40-
npm run e2e
26+
$(npm bin)/gulp ci:e2e
4127
elif is_extract_metadata; then
42-
$(npm bin)/gulp build:components:ngc
28+
$(npm bin)/gulp ci:extract-metadata
4329
else
4430
# Unit tests
45-
npm run build
46-
47-
karma start test/karma.conf.js --single-run --no-auto-watch --reporters='dots'
31+
$(npm bin)/gulp ci:test
32+
# npm run build
33+
#
34+
# karma start test/karma.conf.js --single-run --no-auto-watch --reporters='dots'
4835
fi
4936
teardown_tunnel

scripts/ci/forbidden-identifiers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const blocked_statements = [
2929
];
3030

3131
const sourceFolders = ['./src', './e2e'];
32-
const scopePackages = glob(['src/lib/*']);
32+
const scopePackages = glob('src/lib/*');
3333
const blockedRegex = new RegExp(blocked_statements.join('|'), 'g');
3434
const importRegex = /from\s+'(.*)';/g;
3535

0 commit comments

Comments
 (0)