Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added an option to --skip-cleanup #18

Merged
merged 1 commit into from
Apr 13, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Especially useful to use on CI to test against multiple `ember` versions.

#### `ember try <scenario> <command (Default: test)>`

This command will run any `ember-cli` command with the specified scenario. The command will default to `ember test`.
This command will run any `ember-cli` command with the specified scenario. The command will default to `ember test`.

For example:

Expand All @@ -37,13 +37,20 @@ or
ember try ember-1.11-with-ember-data-beta-16 serve
```

When running in a CI environment where changes are discarded you can skip reseting your environment back to its original state by specifying --skip-cleanup as an option to ember try.
*Warning: If you use this option and, without cleaning up, build and deploy as the result of a passing test suite, it will build with the last set of dependencies ember try was run with.*

```
ember try ember-1.11 test --skip-cleanup
```

#### `ember try:reset`

This command restores the original `bower.json` from `bower.json.ember-try`, `rm -rf`s `bower_components` and runs `bower install`. For use if any of the other commands fail to clean up after (they run this by default on completion).

### Config

Configuration will be read from a file in your ember app in `config/ember-try.js`. It should look like:
Configuration will be read from a file in your ember app in `config/ember-try.js`. It should look like:

```js
module.exports = {
Expand Down Expand Up @@ -82,7 +89,7 @@ module.exports = {

Scenarios are sets of dependencies (`bower` only). They can be specified exactly as in the `bower.json`
The `name` can be used to try just one scenario using the `ember try` command.

If no `config/ember-try.js` file is present, the default config will be used. This is the current default config:

```js
Expand Down Expand Up @@ -110,7 +117,7 @@ If no `config/ember-try.js` file is present, the default config will be used. Th
}
```

See an example of using `ember-try` for CI [here](https://github.com/kategengler/ember-feature-flags/commit/aaf0226975c76630c875cf6b923fdc23b025aa79), and the resulting build [output](https://travis-ci.org/kategengler/ember-feature-flags/builds/55597086).
See an example of using `ember-try` for CI [here](https://github.com/kategengler/ember-feature-flags/commit/aaf0226975c76630c875cf6b923fdc23b025aa79), and the resulting build [output](https://travis-ci.org/kategengler/ember-feature-flags/builds/55597086).

### Special Thanks

Expand Down
4 changes: 4 additions & 0 deletions lib/commands/testall.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ module.exports = {
description: 'Runs `ember test` with each of the dependency scenarios specified in config.' ,
works: 'insideProject',

availableOptions: [
{ name: 'skip-cleanup', type: Boolean, default: false },
],

run: function(commandOptions, rawArgs) {

var config = require('../utils/config')({ project: this.project });
Expand Down
12 changes: 11 additions & 1 deletion lib/commands/try.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,21 @@ module.exports = {
'<command (Default: test)>'
],

availableOptions: [
{ name: 'skip-cleanup', type: Boolean, default: false },
],

getCommand: function() {
var args = process.argv.slice();
var tryIndex = args.indexOf(this.name);
var subcommandArgs = args.slice(tryIndex + 2);

//remove ember-try options from the args that are passed on to ember
var skipIndex = subcommandArgs.indexOf('--skip-cleanup');
if(skipIndex !== -1){
subcommandArgs.splice(skipIndex, 1);
}

if (subcommandArgs.length === 0) {
subcommandArgs.push('test');
}
Expand Down Expand Up @@ -46,7 +56,7 @@ module.exports = {
config: config
});

return tryTask.run(scenario, commandArgs);
return tryTask.run(scenario, commandArgs, commandOptions);
}
};

Expand Down
9 changes: 8 additions & 1 deletion lib/tasks/testall.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ module.exports = CoreObject.extend({

return BowerHelpers.backupBowerFile(task.project.root).then(function() {
return mapSeries(scenarios, task._testVersion, task).then(function (results) {
return BowerHelpers.cleanup(task.project.root).then(function(){
var promise;
if(options.skipCleanup){
//create a fake promise for consistency
promise = RSVP.Promise.resolve();
} else {
promise = BowerHelpers.cleanup(task.project.root);
}
return promise.then(function(){
task._printResults(scenarios, results);
if(results.indexOf(false) > -1){
process.exit(1);
Expand Down
13 changes: 10 additions & 3 deletions lib/tasks/try.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ var BowerHelpers = require('../utils/bower-helpers');
var findEmberPath = require('./../utils/find-ember-path');

module.exports = CoreObject.extend({
run: function(scenario, commandArgs){
run: function(scenario, commandArgs, commandOptions){
var task = this;

var commandName = commandOptions[1] || 'test';
process.on('SIGINT', function() {
task.ui.writeLine( "\nGracefully shutting down from SIGINT (Ctrl-C)" );
BowerHelpers.cleanup(task.project.root).then(function(){
Expand All @@ -35,7 +35,14 @@ module.exports = CoreObject.extend({
});
})
.then(function(result){
return BowerHelpers.cleanup(task.project.root).then(function(){
var promise;
if(commandOptions.skipCleanup){
//create a fake promise for consistency
promise = RSVP.Promise.resolve();
} else {
promise = BowerHelpers.cleanup(task.project.root);
}
return promise.then(function(){
if(!result){
task.ui.writeLine('');
task.ui.writeLine('ember ' + commandName + ' with scenario ' + scenario.name + ' exited nonzero');
Expand Down