From 15d221ae0ebe7e51dca0df9be7a9260492977d51 Mon Sep 17 00:00:00 2001 From: Daniel Gasienica Date: Tue, 10 Apr 2018 17:47:25 -0400 Subject: [PATCH] Simplify testing and linting Separate linting from testing as follows: - `yarn jscs`: Run JSCS. - `yarn jshint`: Run JSHint. - `yarn lint`: Run all linters, i.e. ESLint, TSLint, JSHint, and JSHint. - `yarn test-node`: Run Mocha tests in Node.js environment. - `yarn test-electron`: Run tests in Electron environment via Grunt. - `yarn test`: Run all tests. CI - Align Travis and AppVeyor scripts as much as possible. - Run linting before tests to fail fast. - Run Node.js (headless and fast) tests first. - Run Electron tests last (Travis seems to require custom setup in `travis.sh`). --- .travis.yml | 9 ++++----- Gruntfile.js | 3 ++- appveyor.yml | 7 ++----- package.json | 16 ++++++++-------- test/{server => }/app/logging_test.js | 2 +- travis.sh | 4 ++-- 6 files changed, 19 insertions(+), 22 deletions(-) rename test/{server => }/app/logging_test.js (99%) diff --git a/.travis.yml b/.travis.yml index 78cc1bc43919..52521d16a7a6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,12 +8,11 @@ install: - yarn install --frozen-lockfile script: - yarn transpile - - yarn nsp check - - yarn run generate - - yarn prepare-beta-build - - yarn eslint - - yarn test-server - yarn lint + - yarn nsp check + - yarn generate + - yarn prepare-beta-build + - yarn test-node - $(yarn bin)/build --config.extraMetadata.environment=$SIGNAL_ENV --config.mac.bundleVersion='$TRAVIS_BUILD_NUMBER' --publish=never - ./travis.sh env: diff --git a/Gruntfile.js b/Gruntfile.js index 46abd1ec20f2..ab96bbf69f53 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -480,7 +480,8 @@ module.exports = function(grunt) { grunt.registerTask('tx', ['exec:tx-pull', 'locale-patch']); grunt.registerTask('dev', ['default', 'watch']); - grunt.registerTask('test', ['jshint', 'jscs', 'unit-tests', 'lib-unit-tests']); + grunt.registerTask('lint', ['jshint', 'jscs']); + grunt.registerTask('test', ['unit-tests', 'lib-unit-tests']); grunt.registerTask('copy_dist', ['gitinfo', 'copy:res', 'copy:src']); grunt.registerTask('date', ['gitinfo', 'getExpireTime']); grunt.registerTask('prep-release', ['gitinfo', 'clean-release', 'fetch-release']); diff --git a/appveyor.yml b/appveyor.yml index 6e8422b39067..b434efc8b20d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -13,12 +13,9 @@ install: build_script: - yarn transpile - - yarn nsp check - - yarn eslint - - yarn tslint - - yarn test-server - yarn lint - - yarn run icon-gen + - yarn nsp check + - yarn generate - node build\grunt.js - type package.json | findstr /v certificateSubjectName > temp.json - move temp.json package.json diff --git a/package.json b/package.json index 0c962ba8f304..b45cc4fc35af 100644 --- a/package.json +++ b/package.json @@ -12,8 +12,6 @@ "main": "main.js", "scripts": { "postinstall": "electron-builder install-app-deps && rimraf node_modules/dtrace-provider", - "test": "yarn eslint && yarn tslint && yarn test-server && grunt test && yarn test-app && yarn test-modules && yarn test-ts", - "lint": "grunt jshint", "start": "electron .", "asarl": "asar l release/mac/Signal.app/Contents/Resources/app.asar", "icon-gen": "electron-icon-maker --input=images/icon_1024.png --output=./build", @@ -36,13 +34,15 @@ "release-win": "npm run build-release -- -w --prepackaged release/windows --publish=always", "release-lin": "npm run build-release -- -l --prepackaged release/linux && NAME=$npm_package_name VERSION=$npm_package_version ./aptly.sh", "release": "npm run release-mac && npm run release-win && npm run release-lin", - "test-app": "mocha --recursive test/app", - "test-modules": "mocha --recursive test/modules", - "test-ts": "mocha --recursive ts/test-unit", - "test-server": "mocha --recursive test/server", - "test-server-coverage": "nyc --reporter=lcov --reporter=text mocha --recursive test/server", + "test-node": "mocha --recursive test/app test/modules ts/test-unit", + "test-electron": "yarn grunt test", + "test-electron-coverage": "nyc --reporter=lcov --reporter=text mocha --recursive test/app test/modules ts/test-unit", + "test": "yarn test-node && yarn test-electron", + "jscs": "yarn grunt jscs", + "jshint": "yarn grunt jshint", "eslint": "eslint .", - "tslint": "tslint --config tslint.json ts/**/*.{ts,tsx}", + "tslint": "tslint ts/**/*.{ts,tsx}", + "lint": "yarn eslint && yarn tslint && yarn jshint && yarn jscs", "transpile": "tsc", "clean-transpile": "rimraf ts/**/*.js ts/*.js", "open-coverage": "open coverage/lcov-report/index.html", diff --git a/test/server/app/logging_test.js b/test/app/logging_test.js similarity index 99% rename from test/server/app/logging_test.js rename to test/app/logging_test.js index 04f73e1d1458..3cd1383ceaef 100644 --- a/test/server/app/logging_test.js +++ b/test/app/logging_test.js @@ -13,7 +13,7 @@ const { isLineAfterDate, fetchLog, fetch, -} = require('../../../app/logging'); +} = require('../../app/logging'); describe('app/logging', () => { let basePath; diff --git a/travis.sh b/travis.sh index 590d40288367..8515d58514fe 100755 --- a/travis.sh +++ b/travis.sh @@ -8,6 +8,6 @@ if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sleep 3 fi -grunt test +yarn test-electron -NODE_ENV=production grunt test-release:$TRAVIS_OS_NAME +NODE_ENV=production yarn grunt test-release:$TRAVIS_OS_NAME