Permalink
Browse files

Added new way for running travis CI

  • Loading branch information...
Parashuram
Parashuram committed Jun 22, 2013
1 parent e8c1abb commit d9119be6b1f18ae01a6bff4c876616e980fae47f
Showing with 84 additions and 45 deletions.
  1. +5 −3 .travis.yml
  2. +13 −13 CONTRIBUTING.md
  3. +7 −29 Gruntfile.js
  4. +59 −0 travis.sh
View
@@ -4,14 +4,16 @@ node_js:
before_script:
- npm install -g grunt-cli
- git submodule update --init --recursive
+ - ./travis.sh before
env:
- [
{secure: "RtkktGYx5Diounj1rD8EbWZICRtN1/LiAkhK49A2eS0dtkfPEEByPWkynC9f\n4FYLDEoNXhRHFNL/j87QNeagpowuG7hRSt0Ftk9g+Qzg7acpiQeQXMuZFgsj\nTGrWvD/yT7VBaoYkAYOTFR5/T0mbUdFZcNUFsohJma8GZ6zug5s="},
{secure: "IYuxUdwc9Xe+UOWoNvD/TS4yNaM3LEtiM3NIYtOaC4AIqUYl6f1pPVOG6kPh\nrAQ4HdtE4XX5m1vdSmeeH8iL6jMQrjeQEK59HEDHU7Pyp1V9tpOVO8CjZ6/j\n5A1GkbdFX4nbIttln83SvUps+ShVbCkiOJDtzUUx6Y7D0n2mqtg="},
- {secure: "Vovnop5k+uNJKvSrk3PrQUYFIhdhWUMCDjmkENtySdsh8+vlr+1oAhcASGb8\nCR4wVZQbn3JFI/Xb4uGFpPiXhGa5pEz6XP8ZEv6toLyi4MJbT/lSqP6Q4HBR\nXoCG0gczJeVlZTg3sU+bYFjGh54sbQ7grv+eB+4e0ElVXeKlfY0="},
- {secure: "F0EXoCWmCupHW2Zlto46v57Ex2em5T1eerNbegrdn91jMSaiBGF6ktCyeNPI\nrIXa8aTGRq7Bw4v8qXVPTaL6X1DBHbNyqGBLxQofN6Szgzii8Fcb93NCZ/xq\nZNYDWM0eZ8LHiVt+w6/Hh5lni0aEmSmD+ZOsGPG9l8x8vQjuupc="},
- {secure: "gbCd30bu/Z8dxGV1hvalBxL5zMsCwWOlpDtPm0Pd4B3HW0+J5+YWhj47nYSG\nb8FbXYe2Sv7qFf5snPMvzV39hFMLfWZ2Pek/u52YRPQKnjs29Kj7SKsHygTw\nA1mqFOI9FQsjqOfXg3SdcF3gf07ThO1x++UCj2LDYTUxZLLfSgE="}
]
notifications:
email:
on_success: never
+after_success:
+ - ./travis.sh merge
+after_failure:
+ - ./travis.sh revert
View
@@ -1,17 +1,17 @@
-# Grunt Sauce labs plugin
+# Please send all pull requests to the __incoming-pr__ branch.
-## Contributing
-Thank you for contributing to the project. There are no formal style guides for the project, but ensure that you have run `grunt test` before submiting the pull request. Here is an informal checklist that could help you before you submit a pull request.
+This repository uses [travis-ci](https://travis-ci.org/axemclion/jquery-indexeddb) for running the continuous integration (CI) tests. It uses [saucelabs](http://saucelabs.com) to run automated test cases on different browsers. The saucelabs server can be only accessed using a secure environment variable that is not accessible in pull requests.
-- Ensure that you have run `grunt test` and that all tests are passing.
-- If you have added a new feature to the plugin, please add corresponding tests for it.
-- Remember to upgrade the version in package.json. Use [Semver](http://semver.org/) as a guideline.
-- If a pull request is in response to a bug, ensure that you have referenced the bug in the commit using `#issue_number`.
+The Pull-Request lifecycle
+------------------------
+Thank you for submitting a patch to this project, we really appretiate it. Here is a quick overview of the process used to ensure that pull requests do not break existing functionality. You just have to do Step 1, all others are done by travis.
-## Filing Issues
-If this plugin is not working for you, please read the documentation, and the examples. You can also look at the [Gruntfile.js](https://github.com/axemclion/grunt-saucelabs/blob/master/Gruntfile.js#L49) in this directory to see a sample of the task used, with all the parameters.
-If you are looking for a feature, it would be best to open a bug and send in a pull request.
-
-## Discussions
-This project is maintained by [Sebastian Tiedtke](https://github.com/sourishkrout) and [Parashuram](http://github.com/axemcion). It would be easy to send them a tweet.
+1. Send a pull request with your changes to `incoming-pr` branch
+2. Travis runs only jslint on your pull request.
+ * If the pull request tests fail, please correct the lint errors
+3. Once the pull request passes the lint test, you pull request is merged into `incoming-pr` branch.
+4. Travis runs *ALL* tests on `incoming-pr` branch. Since `incoming-pr` has access to the secure environment variables, it runs the saucelabs tests also.
+ * If the saucelabs tests fail, `incoming-pr` is reverted to its original state.
+ * Your changes are preserved in a separate branch. Please take a look at this branch and fix any failing tests
+5. Once travis on the `incoming-pr` branch succeeds, your commits are automatically merged into `master`.
View
@@ -103,42 +103,20 @@ module.exports = function(grunt) {
}
}
},
- publish: {
- npm: {
- username: process.env.NPM_USERNAME,
- password: process.env.NPM_PASSWORD,
- email: process.env.NPM_EMAIL
- }
- },
watch: {}
});
- grunt.registerMultiTask('publish', 'Publish the latest version of this plugin', function() {
- var done = this.async(),
- me = this,
- npm = require('npm');
- npm.load({}, function() {
- npm.registry.adduser(me.data.username, me.data.password, me.data.email, function(err) {
- if (err) {
- console.log(err);
- done(true);
- } else {
- npm.config.set("email", me.data.email, "user");
- npm.commands.publish([], function(err) {
- console.log(err || "Published to registry");
- done(true);
- });
- }
- });
- });
- });
-
grunt.loadTasks('tasks');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-watch');
- grunt.registerTask('test', ['connect', 'saucelabs-qunit', 'saucelabs-jasmine', 'saucelabs-yui', 'saucelabs-mocha']);
- grunt.registerTask('default', ['jshint', 'test', 'publish']);
+ var testjobs = ['connect'];
+ if (typeof process.env.SAUCE_ACCESS_KEY !== 'undefined'){
+ testjobs.concat(['saucelabs-qunit', 'saucelabs-jasmine', 'saucelabs-yui', 'saucelabs-mocha']);
+ }
+
+ grunt.registerTask('test', testjobs);
+ grunt.registerTask('default', ['jshint', 'test']);
};
View
@@ -0,0 +1,59 @@
+repo="https://axemclion-travis:$GITHUB_PASSWORD@github.com/$TRAVIS_REPO_SLUG.git"

This comment has been minimized.

Show comment
Hide comment
@nschonni

nschonni Jun 22, 2013

Contributor

Better to use a token as it is easier to revoke http://about.travis-ci.org/blog/2013-01-28-token-token-token/

@nschonni

nschonni Jun 22, 2013

Contributor

Better to use a token as it is easier to revoke http://about.travis-ci.org/blog/2013-01-28-token-token-token/

This comment has been minimized.

Show comment
Hide comment
@axemclion

axemclion Jun 22, 2013

Owner

But can I use the token from the command line ? I wanted to write a shell script, and did not want to use the github API. Also, github API does not seem to have way to do revert, simple push, etc.

Did you see any for those ?

Hence the temp github account for travis.

@axemclion

axemclion Jun 22, 2013

Owner

But can I use the token from the command line ? I wanted to write a shell script, and did not want to use the github API. Also, github API does not seem to have way to do revert, simple push, etc.

Did you see any for those ?

Hence the temp github account for travis.

This comment has been minimized.

Show comment
Hide comment
@nschonni

nschonni Jun 23, 2013

Contributor

Yes, we use it on Travis https://github.com/wet-boew/wet-boew/blob/master/build/post_build.sh#L71 but it is longer so you may want to pipe it from a file rather than trying to type it from the command line

@nschonni

nschonni Jun 23, 2013

Contributor

Yes, we use it on Travis https://github.com/wet-boew/wet-boew/blob/master/build/post_build.sh#L71 but it is longer so you may want to pipe it from a file rather than trying to type it from the command line

This comment has been minimized.

Show comment
Hide comment
@axemclion

axemclion Jun 23, 2013

Owner

That sounds good. Will update the password with a token. This is much better, thank you.

@axemclion

axemclion Jun 23, 2013

Owner

That sounds good. Will update the password with a token. This is much better, thank you.

+
+# If this is a pull request, we dont want to continue
+if [ "$TRAVIS_PULL_REQUEST" != "false" ] ; then
+ echo "Nothing to do on a pull request"
+ exit 0
+fi
+
+# All Pull requests are to the branch called incoming-pr
+# If this is not that branch, the rest of the script is irrelevant
+if [ "$TRAVIS_BRANCH" != "incoming-pr" ] ; then
+ echo "Nothing to do on the master branch"
+ exit 0
+fi
+
+git fetch
+git branch --all
+# This part of the script is run before installing deps or tests
+if [ "$1" = "before" ] ; then
+ # So this is incoming-pr branch. Need to check if this is exactly same as the master
+ # If it is, this branch does not have anything new, so no need to try and build it
+ incoming_commit=$(git rev-parse HEAD)
+ git checkout --orphan master
+ git pull origin master --depth=1
+ master_commit=$(git rev-parse HEAD)
+ if [ "$incoming_commit" = "$master_commit" ] ; then
+ echo "Not required to build this as this is same as the master branch"
+ exit 1
+ else
+ git checkout incoming-pr
+ echo "Current branch is - $(git rev-parse HEAD)"
+ exit 0
+ fi
+fi
+
+git checkout incoming-pr
+if [ "$1" = "merge" ] ; then
+ # If the build was successful, travis after-success will send merge
+ echo "Merging incoming-pr to master"
+ git checkout master
+ git merge incoming-pr --log
+ git push $repo master -q 2> /dev/null
+else
+ # If build failed, travis after-failure will send ./travis.sh revert
+ echo "Reverting dev branch to what master was"
+ # Save the current changes to a new branch
+ echo "Creating a new branch for failed build - incoming-pr-fail-$TRAVIS_BUILD_ID"
+ git checkout -b incoming-pr-fail-$TRAVIS_BUILD_ID
+ git push $repo incoming-pr-fail-$TRAVIS_BUILD_ID -q 2> /dev/null
+ git checkout master
+fi
+
+echo "Making incoming-pr same as master"
+# Merge or revert is done, so make incoming-pr branch at par with master
+# This is done to make it ready for accepting the next pull request
+git push $repo --delete incoming-pr -q 2> /dev/null
+git branch -D incoming-pr
+git branch incoming-pr
+git push $repo incoming-pr -q 2> /dev/null

0 comments on commit d9119be

Please sign in to comment.