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

Migrates the build from Rake to grunt #16

Merged
merged 11 commits into from
Oct 9, 2014
Merged
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
Issues.txt
epub_cfi.js
epub_cfi.js
node_modules
1 change: 0 additions & 1 deletion .rvmrc

This file was deleted.

16 changes: 16 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
branches:
only:
- grunt-migration
language: node_js
node_js:
- '0.10'
env:
global:
- SAUCE_USERNAME=readium
- SAUCE_ACCESS_KEY=a36ebc10-e514-4da6-924c-307aec513550
before_install:
- npm install -g grunt-cli
install:
- npm install
script:
- grunt travis
2 changes: 0 additions & 2 deletions Gemfile

This file was deleted.

38 changes: 0 additions & 38 deletions Gemfile.lock

This file was deleted.

50 changes: 50 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
module.exports = function(grunt) {

//grunt.template.addDelimiters('erb-like-delimiters', '<%= ', ' %>')
var fs = require('fs');

// Project configuration.
grunt.initConfig({
peg: {
cfi:{
src: "cfi_grammar/epubcfi.pegjs",
dest: "src/models/epubcfi.js",
options: { exportVar: "EPUBcfi.Parser" }
},

},
template: {
libraryTemplate: {
options: {
data: {
'cfi_parser': fs.readFileSync('src/models/epubcfi.js', {encoding:'utf8'}),
'cfi_interpreter' : fs.readFileSync('src/models/cfi_instructions.js', {encoding:'utf8'}),
'cfi_instructions' : fs.readFileSync('src/models/cfi_interpreter.js', {encoding:'utf8'}),
'cfi_generator' : fs.readFileSync('src/models/cfi_generator.js', {encoding:'utf8'}),
'runtime_errors' : fs.readFileSync('src/models/runtime_errors.js', {encoding:'utf8'})
}
},
files: {
'dist/epub_cfi.js': ['src/templates/cfi_library_template.js.erb'],
}
}
},
karma: {
local: {
configFile: 'karma.conf.js'
},
travis:{
configFile: 'karma.travis.conf.js'
}
}
});

grunt.loadNpmTasks('grunt-peg');
grunt.loadNpmTasks('grunt-template');
grunt.loadNpmTasks('grunt-karma');

grunt.registerTask('compile', ['peg', 'template']);
grunt.registerTask('default', ['compile', 'karma:local']);
grunt.registerTask('travis', ['compile', 'karma:travis']);

};
120 changes: 0 additions & 120 deletions Rakefile

This file was deleted.

72 changes: 72 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// Karma configuration
// Generated on Tue Oct 07 2014 15:09:42 GMT-0400 (EDT)

module.exports = function(config) {

config.set({

// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',


// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],


// list of files / patterns to load in the browser
files: [
{pattern: 'spec/javascripts/fixtures/*.*', included: false, served: true},
'spec/javascripts/vendor/**/*.js',
'dist/*.js',
'spec/javascripts/helpers/**/*.js',
'spec/javascripts/models/**/*.js'

],


// list of files to exclude
exclude: [
],


// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
},


// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['dots'],


// web server port
port: 9876,


// enable / disable colors in the output (reporters and logs)
colors: true,


// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,


// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,


// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
//browsers: ['Chrome'],
browsers: ['Chrome'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend switching this to PhantomJS instead as not all build machines have Chrome installed (Travis comes to mind).

Edit: just noticed the karma file for travis... in that case, why bother with the two of them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vilmosioo Thanks for the recommendation. For mysterious reasons, some tests consistently fail only on PhantomJS. Therefore, as a team we decided not to use PhantomJS to run the tests.

The travis CI build uses https://saucelabs.com to run the unit tests in a browser since we don't want to use PhantomJS. We want to limit the use of sauce to our CI builds since we are on a free plan and have limited access. Therefore, there is a local config for running the build locally using your installed version of Chrome.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

" For mysterious reasons, some tests consistently fail only on PhantomJS. Therefore, as a team we decided not to use PhantomJS to run the tests." Oddly enough, that sounds very familiar to me.

The decision makes sense. Just a quick suggestion though. Have you considered using only one karma file and override some settings from Gruntfile? It would avoid redundancy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the browser config is less straightforward for using sauce and I didn't want to spend a lot of time trying to make it work. If you're interested in doing this. I would be happy to accept a pull request (after this one is merged)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a big fan of grunt, would be happy to do it!



// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true
});
};
Loading