From d9b2034550a2f1cc29f1d99741b99b0710dd3a86 Mon Sep 17 00:00:00 2001 From: Pete Richards Date: Tue, 1 Mar 2016 12:53:32 -0800 Subject: [PATCH 1/4] [Tests] Add jUnit reporter Add jUnit reporter to allow CircleCI to store test results. --- karma.conf.js | 6 +++++- package.json | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/karma.conf.js b/karma.conf.js index e63b6712ef..d4abaf1e93 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -58,7 +58,7 @@ module.exports = function(config) { // Test results reporter to use // Possible values: 'dots', 'progress' // Available reporters: https://npmjs.org/browse/keyword/karma-reporter - reporters: ['progress', 'coverage', 'html'], + reporters: ['progress', 'coverage', 'html', 'junit'], // Web server port. port: 9876, @@ -89,6 +89,10 @@ module.exports = function(config) { foldAll: false }, + junitReporter: { + outputDir: process.env.CIRCLE_TEST_REPORTS || 'target/junit', + }, + // Continuous Integration mode. // If true, Karma captures browsers, runs the tests and exits. singleRun: true diff --git a/package.json b/package.json index e93587bc49..c88861d0b0 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "karma-coverage": "^0.5.3", "karma-html-reporter": "^0.2.7", "karma-jasmine": "^0.1.5", + "karma-junit-reporter": "^0.3.8", "karma-phantomjs-launcher": "^1.0.0", "karma-requirejs": "^0.2.2", "lodash": "^3.10.1", From b9e0a7765549093c91d3b8281313dc4c2cf313ad Mon Sep 17 00:00:00 2001 From: Pete Richards Date: Tue, 1 Mar 2016 13:00:08 -0800 Subject: [PATCH 2/4] [CI] Run JSHINT after tests --- circle.yml | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index eb88167f53..d163b3ee0c 100644 --- a/circle.yml +++ b/circle.yml @@ -13,3 +13,6 @@ deployment: branch: mobile heroku: appname: openmctweb-staging-deux +test: + post: + - npm run jshint --silent diff --git a/package.json b/package.json index c88861d0b0..c0afb1c9ce 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "scripts": { "start": "node app.js", "test": "karma start --single-run", - "jshint": "jshint platform example || exit 0", + "jshint": "jshint platform example", "watch": "karma start", "jsdoc": "jsdoc -c jsdoc.json -r -d target/docs/api", "otherdoc": "node docs/gendocs.js --in docs/src --out target/docs --suppress-toc 'docs/src/index.md|docs/src/process/index.md'", From 668b09b789819dc6780282102758e267b7fb2921 Mon Sep 17 00:00:00 2001 From: Pete Richards Date: Tue, 1 Mar 2016 13:25:37 -0800 Subject: [PATCH 3/4] [Style] Pull functions out of loop Pull functions out of loop for jshint compliance. --- example/export/ExportTelemetryAsCSVAction.js | 23 ++++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/example/export/ExportTelemetryAsCSVAction.js b/example/export/ExportTelemetryAsCSVAction.js index d8d29ef83c..89a1324f59 100644 --- a/example/export/ExportTelemetryAsCSVAction.js +++ b/example/export/ExportTelemetryAsCSVAction.js @@ -57,14 +57,23 @@ define([], function () { rows = [], row, i; + + function copyDomainsToRow(row, index) { + domains.forEach(function (domain) { + row[domain.name] = series.getDomainValue(index, domain.key); + }); + } + + function copyRangesToRow(row, index) { + ranges.forEach(function (range) { + row[range.name] = series.getRangeValue(index, range.key); + }); + } + for (i = 0; i < series.getPointCount(); i += 1) { row = {}; - domains.forEach(function (domain) { - row[domain.name] = series.getDomainValue(i, domain.key); - }); - ranges.forEach(function (range) { - row[range.name] = series.getRangeValue(i, range.key); - }); + copyDomainsToRow(row, i); + copyRangesToRow(row, i); rows.push(row); } exportService.exportCSV(rows, { headers: headers }); @@ -77,4 +86,4 @@ define([], function () { }; return ExportTelemetryAsCSVAction; -}); \ No newline at end of file +}); From 751414a686d75df4bfb52da8efaa4222e421fef8 Mon Sep 17 00:00:00 2001 From: Pete Richards Date: Tue, 1 Mar 2016 13:37:52 -0800 Subject: [PATCH 4/4] [CI] Save coverage in artifacts Save code coverage results in artifacts when building on circleci. --- karma.conf.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/karma.conf.js b/karma.conf.js index d4abaf1e93..20624e4713 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -20,7 +20,7 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global module*/ +/*global module,process*/ module.exports = function(config) { config.set({ @@ -79,7 +79,9 @@ module.exports = function(config) { // Code coverage reporting. coverageReporter: { - dir: "dist/coverage" + dir: process.env.CIRCLE_ARTIFACTS ? + process.env.CIRCLE_ARTIFACTS + '/coverage' : + "dist/coverage" }, // HTML test reporting. @@ -90,7 +92,7 @@ module.exports = function(config) { }, junitReporter: { - outputDir: process.env.CIRCLE_TEST_REPORTS || 'target/junit', + outputDir: process.env.CIRCLE_TEST_REPORTS || 'target/junit' }, // Continuous Integration mode.