Skip to content

Commit

Permalink
fixing travis tests for pull requests with headless servers
Browse files Browse the repository at this point in the history
  • Loading branch information
hdngr committed Nov 2, 2014
1 parent a010176 commit bae9eeb
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ site/dist
.grunt
archive
s3.yml
sauce.yml
9 changes: 7 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
language: node_js
node_js:
- "0.10"
- "0.10"
before_install:
# If the build is a pull request set up Mozilla for testing
# If it is not a pull request, Travis will have access to security credentials for sauce labs
- '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && echo "set up sauce labs tests" || export DISPLAY=:99.0'
- '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && echo "set up sauce labs tests" || sh -e /etc/init.d/xvfb start'
before_script:
- gem update --system
- gem install compass
script:
- bower install
- bower install ./test
- grunt
- '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && grunt || grunt -pr'
26 changes: 18 additions & 8 deletions Gruntfile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,13 @@ module.exports = (grunt) ->
configFile: "test/karma.conf.coffee"
dist:
singleRun: true
browsers: ['PhantomJS', 'Chrome', 'Firefox', 'Safari', 'IE']
dev:
singleRun: false
browsers: ['PhantomJS', 'Chrome', 'Firefox', 'Safari', 'IE']
pullRequest:
singleRun: true
browsers: ['PhantomJS', 'Firefox']

# Compiles CoffeeScript to JavaScript
coffee:
Expand Down Expand Up @@ -499,11 +504,13 @@ module.exports = (grunt) ->

grunt.registerTask "test", (target) ->
grunt.task.run ["clean:server", "copy:coffee", "concurrent:test", "autoprefixer"] if target isnt "watch"
if target is "keepalive"
grunt.task.run ["connect:test", "karma:dev"]
# grunt.fail.warn('this task needs to be updated to work with karma')
else
grunt.task.run ["connect:test", "karma:dist"]
switch target
when "keepalive"
grunt.task.run ["connect:test", "karma:dev"]
when "dist"
grunt.task.run ["connect:test", "karma:dist"]
when "pr"
grunt.task.run ["connect:test", "karma:pullRequest"]

grunt.registerTask 'build', ["clean:dist", "useminPrepare",
"copy:coffee", "concurrent:buildAlchemy",
Expand All @@ -514,10 +521,10 @@ module.exports = (grunt) ->
"uglify:buildAlchemy"]

releaseFlag = grunt.option('release')

pullRequest = grunt.option('pr')
grunt.registerTask "default",
if releaseFlag
["test",
["test:dist",
"build",
"string-replace", # apply version to alchemy.js
"bumpBower", # bump bower version
Expand All @@ -529,6 +536,9 @@ module.exports = (grunt) ->
"s3:production" # publish files to s3 for cdn
"shell:docs", # publish docs
]
else if pullRequest
["test:pr",
"build"]
else
["test",
["test:dist",
"build"]
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
"coffee-script": "^1.8.0",
"karma-fixture": "^0.2.1-1",
"karma-html2js-preprocessor": "^0.1.0",
"grunt-mocha": "^0.4.11"
"grunt-mocha": "^0.4.11",
"karma-phantomjs-launcher": "^0.1.4"
},
"engines": {
"node": ">=0.8.0"
Expand Down
13 changes: 7 additions & 6 deletions test/karma.conf.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,13 @@ module.exports = (config) ->

# start these browsers
# available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: [
"Chrome"
"Firefox"
"Safari"
"IE"
]
# defined in grunt files
# browsers: [
# "Chrome"
# "Firefox"
# "Safari"
# "IE"
# ]

# Defined in Gruntfile
# # Continuous Integration mode
Expand Down

0 comments on commit bae9eeb

Please sign in to comment.