Skip to content

Commit

Permalink
Jenkinsfile for build (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgtcoolguy committed Apr 4, 2017
1 parent 028c854 commit 19026c4
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 6 deletions.
27 changes: 27 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
timestamps {
node('osx || linux') {
stage('Checkout') {
checkout scm
}

nodejs(nodeJSInstallationName: 'node 6.9.5') {
ansiColor('xterm') {
stage('Build') {
sh 'npm install'
}

stage('Test') {
sh 'npm run-script coverage'
junit 'junit_report.xml'
// TODO Can we somehow consume the coverage report too?
sh 'npm run-script clean'
}

stage('Package') {
sh 'npm run-script dist'
archiveArtifacts '*-commonjs-*.zip'
}
} // ansiColor
} //nodejs
} // node
} // timestamps
16 changes: 14 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ const coverageDir = path.join(__dirname, 'coverage');
const distDir = path.join(__dirname, 'dist');
const docsDir = path.join(__dirname, 'documentation');
const stagingDir = path.join(__dirname, 'staging');
const junitReport = path.join(__dirname, 'junit_report.xml');

/*
* Clean tasks
*/
gulp.task('clean', ['clean-coverage', 'clean-dist', 'clean-docs', 'clean-staging', 'clean-zip']);
gulp.task('clean', ['clean-coverage', 'clean-dist', 'clean-docs', 'clean-reports', 'clean-staging', 'clean-zip']);

gulp.task('clean-coverage', function (done) {
del([coverageDir]).then(function () { done(); });
Expand All @@ -28,6 +29,10 @@ gulp.task('clean-docs', function (done) {
del([docsDir]).then(function () { done(); });
});

gulp.task('clean-reports', function (done) {
del([junitReport]).then(function () { done(); });
});

gulp.task('clean-staging', function (done) {
del([stagingDir]).then(function () { done(); });
});
Expand Down Expand Up @@ -135,7 +140,14 @@ gulp.task('coverage', ['lint-src', 'lint-test', 'clean-coverage'], function (cb)
.pipe($.debug({ title: 'test' }))
.pipe($.babel())
.pipe($.injectModules())
.pipe($.mocha())
.pipe($.mocha({
reporter: 'mocha-jenkins-reporter',
reporterOptions: {
junit_report_name: 'Tests',
junit_report_path: junitReport,
junit_report_stack: 1
}
}))
.pipe($.babelIstanbul.writeReports())
.on('end', cb);
});
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"build": "gulp build",
"dist": "gulp dist",
"coverage": "gulp coverage",
"clean": "gulp clean",
"docs": "gulp docs",
"prepublish": "gulp build && npm shrinkwrap",
"test": "gulp test"
Expand Down Expand Up @@ -56,6 +57,7 @@
"gulp-rollup": "^1.7.0",
"gulp-sourcemaps": "^1.6.0",
"gulp-zip": "^3.2.0",
"mocha-jenkins-reporter": "^0.3.7",
"sinon": "^1.17.3",
"sinon-chai": "^2.8.0"
},
Expand Down
1 change: 0 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const AUTH_WINDOW_OPTIONS = {
const isiOS = Ti.Platform.osname == 'iphone' || Ti.Platform.osname == 'ipad';

/********** Helpers **********/

function buildURL(baseURL, params) {
var encodedParams = [];

Expand Down
3 changes: 3 additions & 0 deletions test/setup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { expect } from 'chai';

import Titanium from './ti-mock';
global.Ti = global.Titanium = Titanium;

global.chai = require('chai');
global.chai.use(require('sinon-chai'));
global.expect = global.chai.expect;
Expand Down
4 changes: 1 addition & 3 deletions test/test-oauth.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import Titanium from './ti-mock';
const Ti = global.Ti = global.Titanium = Titanium;

/* global Ti */
import OAuth from '../src/index';

const implicit = {
Expand Down
3 changes: 3 additions & 0 deletions test/ti-mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ let Ti = {
}
}
},
Platform: {
osname: 'android'
},
UI: {
ActivityIndicator: TiUIActivityIndicator,
Window: TiUIWindow,
Expand Down

0 comments on commit 19026c4

Please sign in to comment.