Skip to content

Commit

Permalink
Remove lighthouse performance test
Browse files Browse the repository at this point in the history
  • Loading branch information
limonte committed Oct 12, 2017
1 parent 5b718da commit 5be02f7
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 94 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ before_script:
- gulp lint
- polymer lint --rules polymer-2 --input *.html
- xvfb-run -s '-screen 0 1024x768x24' polymer test
- travis_retry xvfb-run -s '-screen 0 1024x768x24' gulp perf:run

script:
- if [[ "$TRAVIS_EVENT_TYPE" != "pull_request" && "$TRAVIS_BRANCH" != quick/* ]]; then
Expand Down
72 changes: 0 additions & 72 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,6 @@ var gulp = require('gulp');
var eslint = require('gulp-eslint');
var htmlExtract = require('gulp-html-extract');
var stylelint = require('gulp-stylelint');
var log = require('gulp-util').log;
var polyserve = require('polyserve');
var spawn = require('child_process').spawn;
var which = require('which');

var perf = {
lighthouse: './node_modules/.bin/lighthouse',
port: 7777,
element: require('./package.json').name,
dir: 'test/performance',
tests: require('./test/performance/config.json')
};

gulp.task('lint', ['lint:js', 'lint:html', 'lint:css']);

Expand Down Expand Up @@ -59,63 +47,3 @@ gulp.task('lint:css', function() {
]
}));
});

function runCommand(cmd, cb) {
var args = cmd.split(/\s+/);
var proc = spawn(args.shift(), args);
var stdout = '';
proc.stdout.on('data', data => stdout += data);
proc.on('close', status => cb(status, stdout));
}

function runTest(test, threshold, cb) {
const url = `http://localhost:${perf.port}/components/${perf.element}/${perf.dir}/${test}`;
const command = `node ${perf.lighthouse} --perf --output=json ${url}`;

log(`Performance running test=${test} threshold=${threshold} ...`);
runCommand(command, (status, stdout) => {
var error;
if (status) {
error = `Error: status ${status} while running lighthouse CLI`;
} else {
var results = JSON.parse(stdout);
var total = results.aggregations[0].score[0].overall;

if (total === undefined) {
error = `Error: lighthouse has not produced a valid JSON output`;
} else if (total == 1) {
error = `Error: lighthouse reported score=1. It might be server not running or bad url: ${url}`;
} else if (total < threshold) {
error = `Error: low performance scored ${total}`;
} else {
log(`Performance done test=${test} scored with ${total}`);
}
}
if (error) {
log(error);
perf.failed = true;
}
cb();
});
}

gulp.task('perf:run:server', function() {
polyserve.startServer({port: perf.port});
});

gulp.task('perf:env', function(cb) {
which('google-chrome-stable', (err, path) => {
process.env.LIGHTHOUSE_CHROMIUM_PATH = path;
cb();
});
});

gulp.task('perf:run:tests', ['perf:run:server', 'perf:env'], function(cb) {
perf.tests.reduce((prev, test) => () => runTest(test.name, test.threshold, prev), cb)();
});

gulp.task('perf:run', ['perf:run:tests'], function() {
log('Finished \'perf:run\' with ' + (perf.failed ? 'error' : 'great success'));
process.exitCode = perf.failed ? 1 : 0;
process.exit();
});
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"gulp-eslint": "^4.0.0",
"gulp-html-extract": "^0.3.0",
"gulp-stylelint": "^4.0.0",
"lighthouse": "~1.6.5",
"polymer-cli": "^1.2.0",
"stylelint": "^8.0.0",
"stylelint-config-vaadin": "latest",
Expand Down
3 changes: 0 additions & 3 deletions test/performance/config.json

This file was deleted.

17 changes: 0 additions & 17 deletions test/performance/index.html

This file was deleted.

0 comments on commit 5be02f7

Please sign in to comment.