Skip to content

Commit 0609e29

Browse files
devversionmmalerba
authored andcommitted
build: create a util directory (#3558)
* Introduces a new directory called `util` in the gulp setup. This should make the gulp setup more clear and maintainable. * The utility `task_helpers` no longer includes random utilities like for Firebase. Those have been moved to their own util file (similar as in `e2e/`) * Refactors the Github Status utility because it can be useful for other things as well (e.g upcoming coverage, payload)
1 parent 529eaf8 commit 0609e29

File tree

16 files changed

+111
-89
lines changed

16 files changed

+111
-89
lines changed

tools/gulp/tasks/aot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {task} from 'gulp';
22
import {join} from 'path';
33
import {DIST_ROOT} from '../constants';
4-
import {execNodeTask, sequenceTask} from '../task_helpers';
4+
import {execNodeTask, sequenceTask} from '../util/task_helpers';
55

66
/** Copies the source files of the demo-app to the dist folder. */
77
task('aot:copy', [':build:devapp:scss', ':build:devapp:assets']);

tools/gulp/tasks/clean.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {task} from 'gulp';
22
import {DIST_ROOT} from '../constants';
3-
import {cleanTask} from '../task_helpers';
3+
import {cleanTask} from '../util/task_helpers';
44

55

66
task('clean', cleanTask(DIST_ROOT));

tools/gulp/tasks/components.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
import {
88
sassBuildTask, tsBuildTask, execNodeTask, copyTask, sequenceTask,
99
triggerLivereload
10-
} from '../task_helpers';
10+
} from '../util/task_helpers';
1111

1212
// No typings for these.
1313
const inlineResources = require('../../../scripts/release/inline-resources');

tools/gulp/tasks/coverage.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import {task} from 'gulp';
22
import {existsSync} from 'fs-extra';
33
import {COVERAGE_RESULT_FILE} from '../constants';
44
import {spawnSync} from 'child_process';
5-
import {isTravisPushBuild, openFirebaseDashboardDatabase} from '../task_helpers';
5+
import {isTravisPushBuild} from '../util/travis-ci';
6+
import {openFirebaseDashboardDatabase} from '../util/firebase';
67

78
task('coverage:upload', () => {
89
if (!existsSync(COVERAGE_RESULT_FILE)) {

tools/gulp/tasks/development.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {DIST_ROOT, SOURCE_ROOT} from '../constants';
55
import {
66
sassBuildTask, tsBuildTask, copyTask, buildAppTask, vendorTask,
77
serverTask, sequenceTask, triggerLivereload
8-
} from '../task_helpers';
8+
} from '../util/task_helpers';
99

1010

1111
const appDir = path.join(SOURCE_ROOT, 'demo-app');

tools/gulp/tasks/e2e.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {SOURCE_ROOT, DIST_ROOT, PROJECT_ROOT} from '../constants';
55
import {
66
tsBuildTask, copyTask, buildAppTask, execNodeTask,
77
vendorTask, sequenceTask, serverTask
8-
} from '../task_helpers';
8+
} from '../util/task_helpers';
99

1010
const gulpRunSequence = require('run-sequence');
1111
const gulpConnect = require('gulp-connect');

tools/gulp/tasks/lint.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import gulp = require('gulp');
2-
import {execNodeTask} from '../task_helpers';
2+
import {execNodeTask} from '../util/task_helpers';
33

44
gulp.task('lint', ['tslint', 'stylelint', 'madge']);
55

tools/gulp/tasks/payload.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import {task} from 'gulp';
22
import {join} from 'path';
33
import {statSync, readFileSync} from 'fs';
44
import {DIST_COMPONENTS_ROOT} from '../constants';
5-
import {openFirebaseDashboardDatabase, isTravisPushBuild} from '../task_helpers';
65
import {spawnSync} from 'child_process';
6+
import {isTravisPushBuild} from '../util/travis-ci';
7+
import {openFirebaseDashboardDatabase} from '../util/firebase';
78

89
// Those imports lack types.
910
const uglifyJs = require('uglify-js');

tools/gulp/tasks/release.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import gulpRunSequence = require('run-sequence');
55
import path = require('path');
66
import minimist = require('minimist');
77

8-
import {execTask, cleanTask} from '../task_helpers';
8+
import {execTask, cleanTask} from '../util/task_helpers';
99
import {DIST_COMPONENTS_ROOT} from '../constants';
1010

1111
const argv = minimist(process.argv.slice(3));

tools/gulp/tasks/screenshots.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import {task} from 'gulp';
22
import {readdirSync, statSync, existsSync, mkdirp} from 'fs-extra';
33
import * as path from 'path';
44
import * as admin from 'firebase-admin';
5-
import {openScreenshotsBucket, openFirebaseScreenshotsDatabase} from '../task_helpers';
6-
import {updateGithubStatus} from '../util-functions';
5+
import {openScreenshotsBucket, openFirebaseScreenshotsDatabase} from '../util/firebase';
6+
import {setGithubStatus} from '../util/github';
77

88
const imageDiff = require('image-diff');
99

@@ -19,7 +19,7 @@ task('screenshots', () => {
1919
return getScreenshotFiles(database)
2020
.then((files: any[]) => downloadAllGoldsAndCompare(files, database, prNumber))
2121
.then((results: boolean) => updateResult(database, prNumber, results))
22-
.then((result: boolean) => updateGithubStatus(result, prNumber))
22+
.then((result: boolean) => updateGithubStatus(prNumber, result))
2323
.then(() => uploadScreenshots('diff', prNumber))
2424
.then(() => uploadScreenshots('test', prNumber))
2525
.then(() => updateTravis(database, prNumber))
@@ -159,3 +159,13 @@ function setScreenFilenames(database: admin.database.Database,
159159
database.ref(FIREBASE_FILELIST);
160160
return filelistDatabase.set(filenames);
161161
}
162+
163+
/** Updates the Github Status of the given Pullrequest. */
164+
function updateGithubStatus(prNumber: number, result: boolean) {
165+
setGithubStatus(process.env['TRAVIS_PULL_REQUEST_SHA'], {
166+
result: result,
167+
name: 'Screenshot Tests',
168+
description: `Screenshot Tests ${result ? 'passed' : 'failed'})`,
169+
url: `http://material2-screenshots.firebaseapp.com/${prNumber}`
170+
});
171+
}

0 commit comments

Comments
 (0)