Skip to content
This repository has been archived by the owner on Mar 14, 2022. It is now read-only.

Commit

Permalink
Enable Whitesource scanning on CI (#497)
Browse files Browse the repository at this point in the history
* move unit tests to folder /test/unit/

* Use origami service makefile instead of custom npm run scripts

* Add whitesource config and use it on travis via `make ci`

* Add whitesource api key to  travis

* Remove color codes as they are not output on ci environments

* use npm v5
  • Loading branch information
JakeChampion authored Nov 8, 2017
1 parent e1d4282 commit 065507a
Show file tree
Hide file tree
Showing 53 changed files with 87 additions and 53 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ npm-debug.log*
.editorconfig
bower_components/
/test/integration/*/fixtures/*/package-lock.json
ws-*
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ node_js:
- '7'
- '8'
script:
- npm i -g npm@^5
- npm i
- npm run lint
- npm test
- make ci
cache:
directories:
- node_modules
Expand All @@ -26,3 +26,6 @@ deploy:
tags: true
node: '6'
repo: Financial-Times/origami-build-tools
env:
matrix:
secure: AQxsQuxjPpHLC48eezr/uHSthqT7x2R37HkbUT1co1YNtFad5bNYkS8dbbskoW33s8MX8DGZ0YFVB2W2j5VidXwby6Vbg2xBeHt7eIw23D3XeePZOUBgdbM9rpq7yB2nI0tJv+VmKdiFLFHc0EALnu1GMlvw7+n9KA8FO6IFxZM=
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Origami Service Makefile
# ------------------------
# This section of the Makefile should not be modified, it includes
# commands from the Origami service Makefile.
# https://github.com/Financial-Times/origami-service-makefile
include node_modules/@financial-times/origami-service-makefile/index.mk
# [edit below this line]
# ------------------------

# Configuration
# -------------

INTEGRATION_TIMEOUT = 10000
INTEGRATION_SLOW = 2000

SERVICE_NAME = Origami Build Tools
SERVICE_SYSTEM_CODE = origami-build-tools
SERVICE_SALESFORCE_ID = $(SERVICE_NAME)

6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
"node": ">= 6.0.0",
"npm": ">= 4.0.0"
},
"scripts": {
"lint": "eslint .",
"test": "mocha -t 50000 `find . -name '*.test.js' -path './test/*'`"
},
"dependencies": {
"aliases": "^0.1.0",
"autoprefixer": "^7.1.5",
Expand Down Expand Up @@ -87,6 +83,7 @@
"webpack-merge": "^4.1.0"
},
"devDependencies": {
"@financial-times/origami-service-makefile": "^6.0.0",
"eslint-plugin-filenames": "^1.2.0",
"eslint-plugin-json": "^1.2.0",
"eslint-plugin-mocha": "^4.11.0",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

const proclaim = require('proclaim');

const commandLine = require('../../lib/helpers/command-line');
const commandLine = require('../../../lib/helpers/command-line');

describe('Command line helper', function () {
it('should return output from stdout', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ describe('construct-polyfill-url', function() {

mockery.registerMock('globby', globby);

mockery.registerAllowable('../../lib/helpers/construct-polyfill-url');
mockery.registerAllowable('../../../lib/helpers/construct-polyfill-url');

constructPolyfillUrl = require('../../lib/helpers/construct-polyfill-url');
constructPolyfillUrl = require('../../../lib/helpers/construct-polyfill-url');
});

afterEach(() => {
Expand Down Expand Up @@ -104,8 +104,8 @@ describe('construct-polyfill-url', function() {
});

it('does not duplicate features in the polyfill url', () => {
fs.readFile.withArgs(path.join(__dirname, '../../', '/origami.json'), 'utf-8').resolves('{"browserFeatures": {"required": ["Array.prototype.every"]}}');
fs.readFile.withArgs(path.join(__dirname, '../../', '/bower_components/example/origami.json'), 'utf-8').resolves('{"browserFeatures": {"required": ["Array.prototype.every","Array.prototype.some"]}}');
fs.readFile.withArgs(path.join(__dirname, '../../../', '/origami.json'), 'utf-8').resolves('{"browserFeatures": {"required": ["Array.prototype.every"]}}');
fs.readFile.withArgs(path.join(__dirname, '../../../', '/bower_components/example/origami.json'), 'utf-8').resolves('{"browserFeatures": {"required": ["Array.prototype.every","Array.prototype.some"]}}');
globby.resolves(['/origami.json', '/bower_components/example/origami.json']);

return constructPolyfillUrl()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ const expect = require('expect.js');
const fs = require('fs-extra');
const path = require('path');

const files = require('../../lib/helpers/files');
const files = require('../../../lib/helpers/files');

const obtPath = process.cwd();
const oTestPath = 'test/fixtures/o-test';
const oTestPath = 'test/unit/fixtures/o-test';
const pathSuffix = '-file';
const filesTestPath = path.resolve(obtPath, oTestPath + pathSuffix);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('SpecReporter', function () {
let errors;

beforeEach(() => {
const listrKarmaReporter = require('../../lib/plugins/listr-karma.js')();
const listrKarmaReporter = require('../../../lib/plugins/listr-karma.js')();
SpecReporter = listrKarmaReporter.reporter['reporter:listr'];
errors = listrKarmaReporter.errors;
});
Expand Down Expand Up @@ -103,9 +103,9 @@ describe('SpecReporter', function () {

it('should add error message to the errors array', function () {
proclaim.deepEqual(errors, [
'\u001b[37mTest Browser failed specs:\u001b[39m',
'\u001b[37msuite name > description of test\u001b[39m',
'\u001b[31mlog message\t\u001b[39m',
'Test Browser failed specs:',
'suite name > description of test',
'log message\t',
'',
'1 tests failed across 1 browsers.'
]);
Expand All @@ -121,9 +121,9 @@ describe('SpecReporter', function () {
});

proclaim.deepEqual(errors, [
'\u001b[37mTest Browser failed specs:\u001b[39m',
'\u001b[37msuite name > description of test\u001b[39m',
'\u001b[31mlog message\t\u001b[39m',
'Test Browser failed specs:',
'suite name > description of test',
'log message\t',
'',
'1 tests failed across 1 browsers.'
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

const proclaim = require('proclaim');

const silentSass = require('../../lib/plugins/silent-sass.js');
const silentSass = require('../../../lib/plugins/silent-sass.js');

describe('Silent Sass', function () {
it('Should succeed if silent is false and file has content', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ const fs = require('fs-extra');
const path = require('path');
const process = require('process');

const build = require('../../lib/tasks/build-js');
const build = require('../../../lib/tasks/build-js');

const obtPath = process.cwd();
const oTestPath = 'test/fixtures/o-test';
const oTestPath = 'test/unit/fixtures/o-test';

describe('build-js', function () {
const pathSuffix = '-build-js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ const fs = require('fs-extra');
const path = require('path');
const process = require('process');

const build = require('../../lib/tasks/build-sass');
const build = require('../../../lib/tasks/build-sass');

const obtPath = process.cwd();
const oTestPath = 'test/fixtures/o-test';
const oTestPath = 'test/unit/fixtures/o-test';

describe('Build Sass', function () {
const pathSuffix = '-build-sass';
Expand Down
4 changes: 2 additions & 2 deletions test/tasks/build.test.js → test/unit/tasks/build.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ describe('Build task', function() {
mockery.registerMock('./build-js', buildJS);
mockery.registerMock('./build-sass', buildSass);

mockery.registerAllowable('../../lib/tasks/build');
mockery.registerAllowable('../../../lib/tasks/build');

build = require('../../lib/tasks/build');
build = require('../../../lib/tasks/build');

mockery.resetCache();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ const fs = require('fs-extra');
const path = require('path');
const sinon = require('sinon');

const demo = require('../../lib/tasks/demo-build');
const demo = require('../../../lib/tasks/demo-build');

const obtPath = process.cwd();
const oTestPath = 'test/fixtures/o-test';
const oTestPath = 'test/unit/fixtures/o-test';
const pathSuffix = '-demo';
const demoTestPath = path.resolve(obtPath, oTestPath + pathSuffix);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ sinon.assert.expose(proclaim, {
});

const obtPath = process.cwd();
const oTestPath = 'test/fixtures/o-test';
const oTestPath = 'test/unit/fixtures/o-test';
const pathSuffix = '-verify';
const verifyTestPath = path.resolve(obtPath, oTestPath + pathSuffix);

Expand All @@ -37,9 +37,9 @@ describe('install-bower', function () {

mockery.registerMock('listr', Listr);

mockery.registerAllowable('../../lib/tasks/install-bower');
mockery.registerAllowable('../../../lib/tasks/install-bower');

bowerInstall = require('../../lib/tasks/install-bower');
bowerInstall = require('../../../lib/tasks/install-bower');

mockery.resetCache();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ sinon.assert.expose(proclaim, {
});

const obtPath = process.cwd();
const oTestPath = 'test/fixtures/o-test';
const oTestPath = 'test/unit/fixtures/o-test';
const pathSuffix = '-verify';
const verifyTestPath = path.resolve(obtPath, oTestPath + pathSuffix);

Expand All @@ -37,9 +37,9 @@ describe('npm-install', function () {

mockery.registerMock('listr', Listr);

mockery.registerAllowable('../../lib/tasks/install-npm');
mockery.registerAllowable('../../../lib/tasks/install-npm');

npmInstall = require('../../lib/tasks/install-npm');
npmInstall = require('../../../lib/tasks/install-npm');

mockery.resetCache();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ describe('Install task', function() {
mockery.registerMock('./install-bower', bowerInstall);
mockery.registerMock('./install-npm', npmInstall);

mockery.registerAllowable('../../lib/tasks/install');
mockery.registerAllowable('../../../lib/tasks/install');

install = require('../../lib/tasks/install');
install = require('../../../lib/tasks/install');

mockery.resetCache();
});
Expand Down
9 changes: 5 additions & 4 deletions test/tasks/pa11y.test.js → test/unit/tasks/pa11y.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ const process = require('process');
const fs = require('fs-extra');
const path = require('path');

const demo = require('../../lib/tasks/demo-build');
const pa11y = require('../../lib/tasks/pa11y');
const demo = require('../../../lib/tasks/demo-build');
const pa11y = require('../../../lib/tasks/pa11y');

const obtPath = process.cwd();
const oTestPath = 'test/fixtures/o-test';
const oTestPath = 'test/unit/fixtures/o-test';

describe('Test task', function() {
describe('Pa11y', function() {
Expand Down Expand Up @@ -54,7 +54,8 @@ describe('Test task', function() {
});

describe('task', () => {
it('should run pa11y correctly', function() {
it('should run pa11y correctly', function () {
this.timeout(10000);
return pa11y().task()
.catch(function (results) {
expect(results).to.be.an(Error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ describe('run-bower-install', function() {

mockery.registerMock('../helpers/command-line', commandLine);

mockery.registerAllowable('../../lib/helpers/run-bower-install');
mockery.registerAllowable('../../../lib/helpers/run-bower-install');

runBowerInstall = require('../../lib/tasks/run-bower-install');
runBowerInstall = require('../../../lib/tasks/run-bower-install');
});

afterEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ describe('run-npm-install', function() {

mockery.registerMock('../helpers/command-line', commandLine);

mockery.registerAllowable('../../lib/helpers/run-npm-install');
mockery.registerAllowable('../../../lib/helpers/run-npm-install');

runNpmInstall = require('../../lib/tasks/run-npm-install');
runNpmInstall = require('../../../lib/tasks/run-npm-install');
});

afterEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ const path = require('path');
const rimraf = require('rimraf');
const process = require('process');

const verifyJavascript = require('../../lib/tasks/verify-javascript');
const verifyJavascript = require('../../../lib/tasks/verify-javascript');

const obtPath = process.cwd();
const oTestPath = 'test/fixtures/o-test';
const oTestPath = 'test/unit/fixtures/o-test';
const pathSuffix = '-verify';
const verifyTestPath = path.resolve(obtPath, oTestPath + pathSuffix);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ const process = require('process');
const fs = require('fs-extra');
const path = require('path');

const verifyOrigamiJson = require('../../lib/tasks/verify-origami-json');
const verifyOrigamiJson = require('../../../lib/tasks/verify-origami-json');

const obtPath = process.cwd();
const oTestPath = 'test/fixtures/o-test';
const oTestPath = 'test/unit/fixtures/o-test';
const pathSuffix = '-verify';
const verifyTestPath = path.resolve(obtPath, oTestPath + pathSuffix);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ const rimraf = require('rimraf');
const fs = require('fs-extra');
const path = require('path');

const verify = require('../../lib/tasks/verify-sass');
const verify = require('../../../lib/tasks/verify-sass');

const obtPath = process.cwd();
const oTestPath = 'test/fixtures/o-test';
const oTestPath = 'test/unit/fixtures/o-test';
const pathSuffix = '-verify';
const verifyTestPath = path.resolve(obtPath, oTestPath + pathSuffix);

Expand Down
4 changes: 2 additions & 2 deletions test/tasks/verify.test.js → test/unit/tasks/verify.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ describe('Verify task', function() {
mockery.registerMock('./verify-javascript', verifyJavaScript);
mockery.registerMock('./verify-sass', verifySass);

mockery.registerAllowable('../../lib/tasks/verify');
mockery.registerAllowable('../../../lib/tasks/verify');

verify = require('../../lib/tasks/verify');
verify = require('../../../lib/tasks/verify');

mockery.resetCache();
});
Expand Down
7 changes: 7 additions & 0 deletions whitesource.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"checkPolicies": true,
"projectName": "origami-build-tools",
"productName": "origami-build-tools",
"devDep": false,
"failOnError": true
}

0 comments on commit 065507a

Please sign in to comment.