Merge pull request #4 from sergerdn/feature/travis-js
add make test-js to Travis, minor modification in gulp build
This commit is contained in:
commit
83e6d153a5
14
.travis.yml
14
.travis.yml
|
@ -10,6 +10,9 @@ jobs:
|
||||||
env: TOXENV=py37
|
env: TOXENV=py37
|
||||||
addons:
|
addons:
|
||||||
postgresql: "9.4"
|
postgresql: "9.4"
|
||||||
|
chrome: stable
|
||||||
|
services:
|
||||||
|
- xvfb
|
||||||
- name: "python3.7-postgresql-10-bionic"
|
- name: "python3.7-postgresql-10-bionic"
|
||||||
dist: bionic
|
dist: bionic
|
||||||
language: python
|
language: python
|
||||||
|
@ -17,6 +20,7 @@ jobs:
|
||||||
env: TOXENV=py37
|
env: TOXENV=py37
|
||||||
addons:
|
addons:
|
||||||
postgresql: '10'
|
postgresql: '10'
|
||||||
|
chrome: stable
|
||||||
apt:
|
apt:
|
||||||
packages:
|
packages:
|
||||||
- postgresql-10
|
- postgresql-10
|
||||||
|
@ -24,6 +28,7 @@ jobs:
|
||||||
- postgresql-server-dev-10
|
- postgresql-server-dev-10
|
||||||
services:
|
services:
|
||||||
- postgresql
|
- postgresql
|
||||||
|
- xvfb
|
||||||
- name: "python3.8-postgresql-12-focal"
|
- name: "python3.8-postgresql-12-focal"
|
||||||
dist: focal
|
dist: focal
|
||||||
language: python
|
language: python
|
||||||
|
@ -31,6 +36,7 @@ jobs:
|
||||||
env: TOXENV=py38
|
env: TOXENV=py38
|
||||||
addons:
|
addons:
|
||||||
postgresql: '12'
|
postgresql: '12'
|
||||||
|
chrome: stable
|
||||||
apt:
|
apt:
|
||||||
packages:
|
packages:
|
||||||
- postgresql-12
|
- postgresql-12
|
||||||
|
@ -38,6 +44,7 @@ jobs:
|
||||||
- postgresql-server-dev-12
|
- postgresql-server-dev-12
|
||||||
services:
|
services:
|
||||||
- postgresql
|
- postgresql
|
||||||
|
- xvfb
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
|
@ -53,6 +60,9 @@ env:
|
||||||
# https://github.com/travis-ci/travis-ci/issues/5246#issuecomment-166460882
|
# https://github.com/travis-ci/travis-ci/issues/5246#issuecomment-166460882
|
||||||
- BOTO_CONFIG=/doesnotexist
|
- BOTO_CONFIG=/doesnotexist
|
||||||
|
|
||||||
|
before_install:
|
||||||
|
- export CHROME_BIN=/usr/bin/google-chrome
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- sudo systemctl stop postgresql
|
- sudo systemctl stop postgresql
|
||||||
# the port may have been auto-configured to use 5433 if it thought 5422 was already in use,
|
# the port may have been auto-configured to use 5433 if it thought 5422 was already in use,
|
||||||
|
@ -64,8 +74,9 @@ before_script:
|
||||||
- psql -c "create user lemur with password 'lemur;'" -U postgres
|
- psql -c "create user lemur with password 'lemur;'" -U postgres
|
||||||
- psql lemur -c "create extension IF NOT EXISTS pg_trgm;" -U postgres
|
- psql lemur -c "create extension IF NOT EXISTS pg_trgm;" -U postgres
|
||||||
- npm config set registry https://registry.npmjs.org
|
- npm config set registry https://registry.npmjs.org
|
||||||
- npm install -g bower
|
- npm install -g npm@latest bower
|
||||||
- pip install --upgrade setuptools
|
- pip install --upgrade setuptools
|
||||||
|
- export DISPLAY=:99.0
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- pip install coveralls
|
- pip install coveralls
|
||||||
|
@ -74,6 +85,7 @@ install:
|
||||||
script:
|
script:
|
||||||
- make test
|
- make test
|
||||||
- bandit -r . -ll -ii -x lemur/tests/,docs
|
- bandit -r . -ll -ii -x lemur/tests/,docs
|
||||||
|
- make test-js
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
- coveralls
|
- coveralls
|
||||||
|
|
|
@ -7,7 +7,7 @@ var gulp = require('gulp'),
|
||||||
gulpif = require('gulp-if'),
|
gulpif = require('gulp-if'),
|
||||||
gutil = require('gulp-util'),
|
gutil = require('gulp-util'),
|
||||||
foreach = require('gulp-foreach'),
|
foreach = require('gulp-foreach'),
|
||||||
path =require('path'),
|
path = require('path'),
|
||||||
merge = require('merge-stream'),
|
merge = require('merge-stream'),
|
||||||
del = require('del'),
|
del = require('del'),
|
||||||
size = require('gulp-size'),
|
size = require('gulp-size'),
|
||||||
|
@ -28,6 +28,23 @@ var gulp = require('gulp'),
|
||||||
replace = require('gulp-replace'),
|
replace = require('gulp-replace'),
|
||||||
argv = require('yargs').argv;
|
argv = require('yargs').argv;
|
||||||
|
|
||||||
|
// http://stackoverflow.com/questions/1144783/replacing-all-occurrences-of-a-string-in-javascript
|
||||||
|
function escapeRegExp(string) {
|
||||||
|
return string.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, '\\$1');
|
||||||
|
}
|
||||||
|
|
||||||
|
function replaceAll(string, find, replace) {
|
||||||
|
return string.replace(new RegExp(escapeRegExp(find), 'g'), replace);
|
||||||
|
}
|
||||||
|
|
||||||
|
function stringSrc(filename, string) {
|
||||||
|
let src = require('stream').Readable({objectMode: true});
|
||||||
|
src._read = function () {
|
||||||
|
this.push(new gutil.File({cwd: '', base: '', path: filename, contents: new Buffer(string)}));
|
||||||
|
this.push(null);
|
||||||
|
};
|
||||||
|
return src;
|
||||||
|
}
|
||||||
|
|
||||||
gulp.task('clean', function (done) {
|
gulp.task('clean', function (done) {
|
||||||
del(['.tmp', 'lemur/static/dist'], done);
|
del(['.tmp', 'lemur/static/dist'], done);
|
||||||
|
@ -39,12 +56,18 @@ gulp.task('default', gulp.series(['clean'], function () {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
gulp.task('test', function (done) {
|
gulp.task('test', function (done) {
|
||||||
// returning the promise
|
new karma.Server({
|
||||||
return new karma.Server({
|
|
||||||
configFile: __dirname + '/karma.conf.js',
|
configFile: __dirname + '/karma.conf.js',
|
||||||
singleRun: true
|
singleRun: true
|
||||||
}, function() {
|
}, function (err) {
|
||||||
|
if (err === 0) {
|
||||||
done();
|
done();
|
||||||
|
} else {
|
||||||
|
// if karma server failed to start raise error
|
||||||
|
done(new gutil.PluginError('karma', {
|
||||||
|
message: 'Karma Tests failed'
|
||||||
|
}));
|
||||||
|
}
|
||||||
}).start();
|
}).start();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -73,7 +96,7 @@ gulp.task('dev:styles', function () {
|
||||||
return fileName.indexOf(suffix) === 0;
|
return fileName.indexOf(suffix) === 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
var fileList = [
|
let fileList = [
|
||||||
'bower_components/bootswatch/sandstone/bootswatch.less',
|
'bower_components/bootswatch/sandstone/bootswatch.less',
|
||||||
'bower_components/fontawesome/css/font-awesome.css',
|
'bower_components/fontawesome/css/font-awesome.css',
|
||||||
'bower_components/angular-chart.js/dist/angular-chart.css',
|
'bower_components/angular-chart.js/dist/angular-chart.css',
|
||||||
|
@ -89,10 +112,8 @@ gulp.task('dev:styles', function () {
|
||||||
return gulp.src(fileList)
|
return gulp.src(fileList)
|
||||||
.pipe(gulpif(isBootswatchFile, foreach(function (stream, file) {
|
.pipe(gulpif(isBootswatchFile, foreach(function (stream, file) {
|
||||||
let themeName = path.basename(path.dirname(file.path)),
|
let themeName = path.basename(path.dirname(file.path)),
|
||||||
content = replaceAll(baseContent, '$theme$', themeName),
|
content = replaceAll(baseContent, '$theme$', themeName);
|
||||||
file2 = string_src('bootstrap-' + themeName + '.less', content);
|
return stringSrc('bootstrap-' + themeName + '.less', content);
|
||||||
|
|
||||||
return file2;
|
|
||||||
})))
|
})))
|
||||||
.pipe(less())
|
.pipe(less())
|
||||||
.pipe(gulpif(isBootstrapFile, foreach(function (stream, file) {
|
.pipe(gulpif(isBootstrapFile, foreach(function (stream, file) {
|
||||||
|
@ -101,7 +122,7 @@ gulp.task('dev:styles', function () {
|
||||||
|
|
||||||
// http://stackoverflow.com/questions/21719833/gulp-how-to-add-src-files-in-the-middle-of-a-pipe
|
// http://stackoverflow.com/questions/21719833/gulp-how-to-add-src-files-in-the-middle-of-a-pipe
|
||||||
// https://github.com/gulpjs/gulp/blob/master/docs/recipes/using-multiple-sources-in-one-task.md
|
// https://github.com/gulpjs/gulp/blob/master/docs/recipes/using-multiple-sources-in-one-task.md
|
||||||
return merge(stream, gulp.src(['.tmp/styles/font-awesome.css', '.tmp/styles/lemur.css'], { allowEmpty: true }))
|
return merge(stream, gulp.src(['.tmp/styles/font-awesome.css', '.tmp/styles/lemur.css'], {allowEmpty: true}))
|
||||||
.pipe(concat('style-' + themeName + '.css'));
|
.pipe(concat('style-' + themeName + '.css'));
|
||||||
})))
|
})))
|
||||||
.pipe(plumber())
|
.pipe(plumber())
|
||||||
|
@ -112,24 +133,6 @@ gulp.task('dev:styles', function () {
|
||||||
.pipe(size());
|
.pipe(size());
|
||||||
});
|
});
|
||||||
|
|
||||||
// http://stackoverflow.com/questions/1144783/replacing-all-occurrences-of-a-string-in-javascript
|
|
||||||
function escapeRegExp(string) {
|
|
||||||
return string.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, '\\$1');
|
|
||||||
}
|
|
||||||
|
|
||||||
function replaceAll(string, find, replace) {
|
|
||||||
return string.replace(new RegExp(escapeRegExp(find), 'g'), replace);
|
|
||||||
}
|
|
||||||
|
|
||||||
function string_src(filename, string) {
|
|
||||||
let src = require('stream').Readable({ objectMode: true });
|
|
||||||
src._read = function () {
|
|
||||||
this.push(new gutil.File({ cwd: '', base: '', path: filename, contents: new Buffer(string) }));
|
|
||||||
this.push(null);
|
|
||||||
};
|
|
||||||
return src;
|
|
||||||
}
|
|
||||||
|
|
||||||
gulp.task('dev:scripts', function () {
|
gulp.task('dev:scripts', function () {
|
||||||
return gulp.src(['lemur/static/app/angular/**/*.js'])
|
return gulp.src(['lemur/static/app/angular/**/*.js'])
|
||||||
.pipe(jshint())
|
.pipe(jshint())
|
||||||
|
@ -145,7 +148,7 @@ gulp.task('build:extras', function () {
|
||||||
function injectHtml(isDev) {
|
function injectHtml(isDev) {
|
||||||
return gulp.src('lemur/static/app/index.html')
|
return gulp.src('lemur/static/app/index.html')
|
||||||
.pipe(
|
.pipe(
|
||||||
inject(gulp.src(bowerFiles({ base: 'app' })), {
|
inject(gulp.src(bowerFiles({base: 'app'})), {
|
||||||
starttag: '<!-- inject:bower:{{ext}} -->',
|
starttag: '<!-- inject:bower:{{ext}} -->',
|
||||||
addRootSlash: false,
|
addRootSlash: false,
|
||||||
ignorePath: isDev ? ['lemur/static/app/', '.tmp/'] : null
|
ignorePath: isDev ? ['lemur/static/app/', '.tmp/'] : null
|
||||||
|
@ -163,7 +166,7 @@ function injectHtml(isDev) {
|
||||||
}))
|
}))
|
||||||
.pipe(
|
.pipe(
|
||||||
gulpif(!isDev,
|
gulpif(!isDev,
|
||||||
inject(gulp.src('lemur/static/dist/ngviews/ngviews.min.js', { allowEmpty: true }), {
|
inject(gulp.src('lemur/static/dist/ngviews/ngviews.min.js', {allowEmpty: true}), {
|
||||||
starttag: '<!-- inject:ngviews -->',
|
starttag: '<!-- inject:ngviews -->',
|
||||||
addRootSlash: false
|
addRootSlash: false
|
||||||
})
|
})
|
||||||
|
@ -231,27 +234,27 @@ gulp.task('package:strip', function () {
|
||||||
.pipe(size());
|
.pipe(size());
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('addUrlContextPath:revision', function(){
|
gulp.task('addUrlContextPath:revision', function () {
|
||||||
return gulp.src(['lemur/static/dist/**/*.css','lemur/static/dist/**/*.js'])
|
return gulp.src(['lemur/static/dist/**/*.css', 'lemur/static/dist/**/*.js'])
|
||||||
.pipe(rev())
|
.pipe(rev())
|
||||||
.pipe(gulp.dest('lemur/static/dist'))
|
.pipe(gulp.dest('lemur/static/dist'))
|
||||||
.pipe(rev.manifest())
|
.pipe(rev.manifest())
|
||||||
.pipe(gulp.dest('lemur/static/dist'))
|
.pipe(gulp.dest('lemur/static/dist'));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('addUrlContextPath:revreplace', gulp.series(['addUrlContextPath:revision'], function(){
|
gulp.task('addUrlContextPath:revreplace', gulp.series(['addUrlContextPath:revision'], function () {
|
||||||
return gulp.src( "lemur/static/dist/index.html")
|
return gulp.src('lemur/static/dist/index.html')
|
||||||
.pipe(gulp.dest('lemur/static/dist'));
|
.pipe(gulp.dest('lemur/static/dist'));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
gulp.task('addUrlContextPath', gulp.series(['addUrlContextPath:revreplace'], function(){
|
gulp.task('addUrlContextPath', gulp.series(['addUrlContextPath:revreplace'], function () {
|
||||||
let urlContextPathExists = argv.urlContextPath ? true : false;
|
let urlContextPathExists = !!argv.urlContextPath;
|
||||||
return gulp.src(['lemur/static/dist/scripts/main*.js', 'lemur/static/dist/angular/**/*.html'])
|
return gulp.src(['lemur/static/dist/scripts/main*.js', 'lemur/static/dist/angular/**/*.html'])
|
||||||
.pipe(gulpif(urlContextPathExists, replace('api/', argv.urlContextPath + '/api/')))
|
.pipe(gulpif(urlContextPathExists, replace('api/', argv.urlContextPath + '/api/')))
|
||||||
.pipe(gulpif(urlContextPathExists, replace('/angular/', '/' + argv.urlContextPath + '/angular/')))
|
.pipe(gulpif(urlContextPathExists, replace('/angular/', '/' + argv.urlContextPath + '/angular/')))
|
||||||
.pipe(gulp.dest(function(file){
|
.pipe(gulp.dest(function (file) {
|
||||||
return file.base;
|
return file.base;
|
||||||
}))
|
}));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
gulp.task('build', gulp.series(['build:images', 'build:fonts', 'build:html', 'build:extras']));
|
gulp.task('build', gulp.series(['build:images', 'build:fonts', 'build:html', 'build:extras']));
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
// Contents of: config/karma.conf.js
|
// Contents of: config/karma.conf.js
|
||||||
|
'use strict';
|
||||||
|
|
||||||
module.exports = function (config) {
|
module.exports = function (config) {
|
||||||
config.set({
|
config.set({
|
||||||
basePath : '../',
|
basePath: '../',
|
||||||
|
|
||||||
// Fix for "JASMINE is not supported anymore" warning
|
// Fix for "JASMINE is not supported anymore" warning
|
||||||
frameworks : ["jasmine"],
|
frameworks: ['jasmine'],
|
||||||
|
|
||||||
files : [
|
files: [
|
||||||
'app/lib/angular/angular.js',
|
'app/lib/angular/angular.js',
|
||||||
'app/lib/angular/angular-*.js',
|
'app/lib/angular/angular-*.js',
|
||||||
'test/lib/angular/angular-mocks.js',
|
'test/lib/angular/angular-mocks.js',
|
||||||
|
@ -14,14 +16,22 @@ module.exports = function (config) {
|
||||||
'test/unit/**/*.js'
|
'test/unit/**/*.js'
|
||||||
],
|
],
|
||||||
|
|
||||||
autoWatch : true,
|
autoWatch: true,
|
||||||
|
|
||||||
browsers : ['Chrome'],
|
browsers: [process.env.TRAVIS ? 'Chrome_travis_ci' : 'Chrome'],
|
||||||
|
customLaunchers: {
|
||||||
|
'Chrome_travis_ci': {
|
||||||
|
base: 'Chrome',
|
||||||
|
flags: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-gpu',],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
junitReporter : {
|
junitReporter: {
|
||||||
outputFile : 'test_out/unit.xml',
|
outputFile: 'test_out/unit.xml',
|
||||||
suite : 'unit'
|
suite: 'unit'
|
||||||
//...
|
//...
|
||||||
}
|
},
|
||||||
|
|
||||||
|
failOnEmptyTestSuite: false,
|
||||||
});
|
});
|
||||||
};
|
};
|
|
@ -37,11 +37,10 @@
|
||||||
"gulp-size": "^2.1.0",
|
"gulp-size": "^2.1.0",
|
||||||
"gulp-uglify": "^2.0.0",
|
"gulp-uglify": "^2.0.0",
|
||||||
"gulp-useref": "^3.1.2",
|
"gulp-useref": "^3.1.2",
|
||||||
"gulp-util": "^3.0.1",
|
|
||||||
"http-proxy": ">=1.18.1",
|
"http-proxy": ">=1.18.1",
|
||||||
"jshint-stylish": "^2.2.1",
|
"jshint-stylish": "^2.2.1",
|
||||||
"karma": "^5.2.3",
|
"karma": "^6.0.3",
|
||||||
"karma-jasmine": "^1.1.0",
|
"karma-jasmine": "^4.0.1",
|
||||||
"main-bower-files": "^2.13.1",
|
"main-bower-files": "^2.13.1",
|
||||||
"merge-stream": "^1.0.1",
|
"merge-stream": "^1.0.1",
|
||||||
"require-dir": "~0.3.0",
|
"require-dir": "~0.3.0",
|
||||||
|
@ -59,7 +58,8 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"gulp": "^4.0.2",
|
"gulp": "^4.0.2",
|
||||||
|
"gulp-util": "^3.0.8",
|
||||||
"jshint": "^2.11.0",
|
"jshint": "^2.11.0",
|
||||||
"karma-chrome-launcher": "^2.0.0"
|
"karma-chrome-launcher": "^3.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue