Separate the server/client/lint test suites on Travis

no issue
- add separate grunt tasks for validating all/client/server test suites
- modify `grunt validate` to respect the `TEST_SUITE` env var if present
- default to `TEST_SUITE=server` on Travis
- add an individual builds to the Travis matrix that test the client and run linting as separate jobs
- don't run `ensureConfig` task if we're performing client-only tests

Previously we were duplicating the client tests and linting for every node and database version in our build matrix. Duplicating those tasks a waste of time/resources as the client tests are now completely isolated from the server and so different node/database versions have no effect. This PR is an attempt at removing the duplication to speed up our Travis runs.
This commit is contained in:
Kevin Ansfield 2015-11-13 11:54:50 +00:00
parent e5d9865792
commit a102eff0ed
2 changed files with 38 additions and 8 deletions

View File

@ -16,10 +16,17 @@ env:
global:
- GITHUB_OAUTH_KEY=003a44d58f12089d0c0261338298af3813330949
- GHOST_NODE_VERSION_CHECK=false
- TEST_SUITE=server
matrix:
- DB=sqlite3 NODE_ENV=testing
- DB=mysql NODE_ENV=testing-mysql
- DB=pg NODE_ENV=testing-pg
matrix:
include:
- node_js: "0.10"
env: TEST_SUITE=client
- node_js: "0.10"
env: TEST_SUITE=lint
before_install:
- git clone git://github.com/n1k0/casperjs.git ~/casperjs
- cd ~/casperjs

View File

@ -541,11 +541,16 @@ var _ = require('lodash'),
grunt.registerTask('ensureConfig', function () {
var config = require('./core/server/config'),
done = this.async();
config.load().then(function () {
if (!process.env.TEST_SUITE || process.env.TEST_SUITE !== 'client') {
config.load().then(function () {
done();
}).catch(function (err) {
grunt.fail.fatal(err.stack);
});
} else {
done();
}).catch(function (err) {
grunt.fail.fatal(err.stack);
});
}
});
// #### Reset Database to "New" state *(Utility Task)*
@ -584,7 +589,19 @@ var _ = require('lodash'),
// manages the build of your environment and then calls `grunt test`
//
// `grunt validate` is called by `npm test` and is used by Travis.
grunt.registerTask('validate', 'Run tests and lint code',
grunt.registerTask('validate', 'Run tests and lint code', function () {
if (process.env.TEST_SUITE === 'server') {
grunt.task.run(['test-server']);
} else if (process.env.TEST_SUITE === 'client') {
grunt.task.run(['test-client']);
} else if (process.env.TEST_SUITE === 'lint') {
grunt.task.run(['lint']);
} else {
grunt.task.run(['validate-all']);
}
});
grunt.registerTask('validate-all', 'Lint code and run all tests',
['init', 'lint', 'test-all']);
// ### Test-All
@ -592,11 +609,17 @@ var _ = require('lodash'),
//
// `grunt test-all` will lint and test your pre-built local Ghost codebase.
//
// `grunt test-all` runs jshint and jscs as well as all 6 test suites. See the individual sub tasks below for
// `grunt test-all` runs all 6 test suites. See the individual sub tasks below for
// details of each of the test suites.
//
grunt.registerTask('test-all', 'Run tests and lint code',
['test-routes', 'test-module', 'test-unit', 'test-integration', 'test-ember']);
grunt.registerTask('test-all', 'Run tests for both server and client',
['init', 'test-server', 'test-client']);
grunt.registerTask('test-server', 'Run server tests',
['init', 'test-routes', 'test-module', 'test-unit', 'test-integration']);
grunt.registerTask('test-client', 'Run client tests',
['init', 'test-ember']);
// ### Lint
//