forked from oneibmcloud/devops-tutorial-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·129 lines (116 loc) · 3.63 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
var gulp = require('gulp');
// These paths need to be changed based on the location of the respective files on your application
var paths = {
html:['views/**/*.html'],
css:['public/**/*.css'],
js:['app.js','public/**/*.js','routes/**/*.js'],
clean:['reports/**/*']
};
gulp.task('default', function(callback) {
var runSequence=require('run-sequence');
runSequence('clean','lint', 'dev-unit', callback);
});
gulp.task('clean', function () {
var clean = require('gulp-clean');
return gulp.src(paths.clean, {read: false})
.pipe(clean());
});
/*
Gulp tasks for linting
*/
gulp.task('lint', ['lint-js','lint-css', 'lint-jscs']);
// Use jshint to check Javascript syntax
gulp.task('lint-js', function() {
var jshint = require('gulp-jshint');
var mkdirp = require('mkdirp');
mkdirp.sync('./reports');
return gulp.src(paths.js)
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(jshint.reporter('jshint-junit-reporter',{ outputFile: "./reports/jshint.xml"}))
.pipe(jshint.reporter('fail'));
});
// Use jscs to check for code style compliance
gulp.task('lint-jscs', function() {
var jscs = require('gulp-jscs-with-reporter');
var jscsJenkinsReporter = require('gulp-jenkins-reporter');
var logCapture = require('gulp-log-capture');
return gulp.src(paths.js)
.pipe(jscs({
"preset": "node-style-guide",
"requireCapitalizedComments": { "allExcept":["jslint", "jshint"]},
"requireCurlyBraces": null
}))
.pipe(jscs.reporter('fail'))
.pipe(logCapture.start(console, 'log'))
.pipe(jscs.reporter(jscsJenkinsReporter))
.pipe(logCapture.stop('xml'))
.pipe(gulp.dest('./reports'))
;
});
// Use csslint to check for CSS issues
gulp.task('lint-css', function() {
var csslint=require('gulp-csslint');
return gulp.src(paths.css)
.pipe(csslint({
"ids":false,
"adjoining-classes": false,
"box-sizing": false,
"box-model": false,
"compatible-vendor-prefixes": false,
"font-sizes": false,
"gradients": false,
"important": false,
"known-properties": false,
"qualified-headings": false,
"regex-selectors": false,
"shorthand": false,
"text-indent": false,
"unique-headings": false,
"universal-selector": false,
"unqualified-attributes": false,
"vendor-prefix": false,
"overqualified-elements": false,
"star-property-hack": false,
"underscore-property-hack": false
}))
.pipe(csslint.reporter())
.pipe(csslint.reporter('fail'))
;
});
/*
Gulp tasks for unit tests
*/
gulp.task('dev-unit', ['dev-karma','dev-mocha']);
//Task for karma (frontend) unit tests
gulp.task('dev-karma', function(done) {
var karma = require('karma').server;
karma.start({
configFile: __dirname + '/test/karma.conf.js',
singleRun: true,
}, done);
});
//Task for mocha (server) unit tests
gulp.task('dev-mocha', function() {
var mocha = require('gulp-mocha');
var mkdirp = require('mkdirp');
mkdirp.sync('./reports/api');
return gulp.src('test/unit/server/**/*spec.js', {read: false})
.pipe(mocha({
globals:['expect'],
timeout: 3000,
ignoreLeaks: true,
ui: 'bdd',
colors: true,
reporter: 'mocha-jenkins-reporter',
reporterOptions: {
junit_report_name: 'Mocha Unit Tests for Server',
junit_report_path: './reports/mocha-report.xml',
junit_report_stack: 1,
},
}));
});
gulp.task('dev-setup', function() {
var bower = require('gulp-bower');
return bower();
});