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`).
This commit is contained in:
Daniel Gasienica 2018-04-10 17:47:25 -04:00
parent 80de7bbd5c
commit 15d221ae0e
6 changed files with 19 additions and 22 deletions

View File

@ -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:

View File

@ -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']);

View File

@ -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

View File

@ -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",

View File

@ -13,7 +13,7 @@ const {
isLineAfterDate,
fetchLog,
fetch,
} = require('../../../app/logging');
} = require('../../app/logging');
describe('app/logging', () => {
let basePath;

View File

@ -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