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 continuous integration tasks #3

Merged
merged 3 commits into from
Oct 22, 2013
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/node_modules/
/build/
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
language: node_js
node_js:
- "0.10"
before_script:
- npm install -g grunt-cli
script:
- grunt
- grunt coverage
- node node_modules/coveralls/bin/coveralls.js < build/reports/coverage/lcov.info
54 changes: 51 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ var path = require("path");

module.exports = function(grunt) {
"use strict";
var jsFiles = ["Gruntfile.js", "src/**/*.js"];
var jsFiles = ["Gruntfile.js", "src/**/*.js", "test/**/*.js"];

grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),

// cleaning output directories
clean: ["build", "lib"],

// Run JSHint on all sources
jshint: {
options: {
Expand All @@ -27,7 +30,7 @@ module.exports = function(grunt) {

// browserify for packing all commonjs files
browserify: {
client: {
lib: {
src: ["src/QRCode.js"],
dest: "lib/qrcode.js",
options: {
Expand All @@ -43,16 +46,61 @@ module.exports = function(grunt) {
"lib/qrcode.min.js": ["lib/qrcode.js"]
}
}
},

// Run tests using mocha
mochaTest: {
libRaw: {
options: {
require: ["./test/testStandard.js"],
reporter: "spec"
},
src: ["test/**/*Test.js"]
},
coverage: {
options: {
require: ["./test/testCoverage.js"],
reporter: "min"
},
src: ["test/**/*Test.js"]
}
},

// tasks for coverage analysis (istanbul)
instrument: {
files: ["src/**/*.js"],
options: {
basePath: "build/instrumented/"
}
},
storeCoverage: {
options: {
dir: "build/reports/coverage/"
}
},
makeReport: {
src: "build/reports/coverage/**/*.json",
options: {
type: "lcov",
dir: "build/reports/coverage/",
print: "text-summary"
}
}
});

grunt.loadNpmTasks("grunt-browserify");
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.loadNpmTasks("grunt-istanbul");
grunt.loadNpmTasks("grunt-jsbeautifier");
grunt.loadNpmTasks("grunt-mocha-test");

grunt.registerTask("lint", ["jshint", "jsbeautifier"]);
grunt.registerTask("test", ["mochaTest:libRaw"]);
grunt.registerTask("compile", ["browserify", "uglify"]);

grunt.registerTask("default", ["lint", "compile"]);
grunt.registerTask("coverage", ["instrument", "mochaTest:coverage", "storeCoverage", "makeReport"]);

grunt.registerTask("default", ["clean", "lint", "test", "compile"]);
};
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![Build Status](https://secure.travis-ci.org/janantala/qrcode.js.png?branch=master)](http://travis-ci.org/janantala/qrcode.js) [![Coverage Status](https://coveralls.io/repos/janantala/qrcode.js/badge.png?branch=master)](https://coveralls.io/r/janantala/qrcode.js?branch=master)

# qrcode.js v1.0.0

QR code generator, supports Numeric, Alphanumeric and Binary inputMode up to lvl 40.
Expand Down
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,17 @@
},
"dependencies": {},
"devDependencies": {
"coveralls": "~2.2.0",
"expect.js": "~0.2.0",
"grunt": "~0.4.1",
"grunt-browserify": "~1.2.4",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-jshint": "~0.4.3",
"grunt-contrib-uglify": "~0.2.2",
"grunt-jsbeautifier": "~0.2.0"
"grunt-contrib-yuidoc": "~0.4.0",
"grunt-istanbul": "~0.2.2",
"grunt-jsbeautifier": "~0.2.0",
"grunt-mocha-test": "~0.6.3"
},
"engines": {
"node": ">=0.10.x"
Expand Down
23 changes: 23 additions & 0 deletions test/QRMathTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* global describe, it, global */
var expect = require("expect.js");

var QRMath = require(global.resolveSource("QRMath.js"));

describe("QRMath", function() {
"use strict";

describe("glog", function() {
it("should return 1 for 2", function() {
var result = QRMath.glog(2);

expect(result).to.be(1);
});

it("should return 53 for 40", function() {
var result = QRMath.glog(40);

expect(result).to.be(53);
});

});
});
10 changes: 10 additions & 0 deletions test/testCoverage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* global global, __dirname */
var path = require("path");

var testSourceBase = path.resolve(path.join(__dirname, "..", "build", "instrumented", "src"));

global.resolveSource = function(file) {
"use strict";

return path.join(testSourceBase, file);
};
10 changes: 10 additions & 0 deletions test/testStandard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* global global, __dirname */
var path = require("path");

var testSourceBase = path.resolve(path.join(__dirname, "..", "src"));

global.resolveSource = function(file) {
"use strict";

return path.join(testSourceBase, file);
};