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

chore: don't run tests on travis if only docs were changed #3908

Merged
merged 1 commit into from
Jan 4, 2017
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
19 changes: 19 additions & 0 deletions build/docs-only.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import sh from 'shelljs';
import path from 'path';


export default function(commit, commitRange) {
const SINGLE_COMMIT = `git diff-tree --no-commit-id --name-only -r ${commit}`;
const COMMIT_RANGE = `git diff --name-only ${commitRange}`;

let command = SINGLE_COMMIT;

if (commitRange) {
command = COMMIT_RANGE
}

const output = sh.exec(command, {async: false, silent: true}).stdout;

const files = output.split('\n').filter(Boolean);
return files.every((file) => file.startsWith('docs') || path.extname(file) === '.md');
};
29 changes: 22 additions & 7 deletions build/grunt.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {gruntCustomizer, gruntOptionsMaker} from './options-customizer.js';
import chg from 'chg';
import npmRun from 'npm-run';
import isDocsOnly from './docs-only.js';

module.exports = function(grunt) {
require('time-grunt')(grunt);
Expand Down Expand Up @@ -550,13 +551,27 @@ module.exports = function(grunt) {
grunt.registerTask('default', ['test']);

// The test script includes coveralls only when the TRAVIS env var is set.
grunt.registerTask('test', [
'build',
'shell:noderequire',
'shell:browserify',
'shell:webpack',
'karma:defaults',
'test-a11y'].concat(process.env.TRAVIS && 'coveralls').filter(Boolean));
grunt.registerTask('test', function() {
const tasks = [
'build',
'shell:noderequire',
'shell:browserify',
'shell:webpack',
'karma:defaults',
'test-a11y'
];

if (process.env.TRAVIS) {
if (isDocsOnly(process.env.TRAVIS_COMMIT, process.env.TRAVIS_COMMIT_RANGE)) {
grunt.log.write('Not running any tests because only docs were changed');
return;
}

tasks.concat(process.env.TRAVIS && 'coveralls').filter(Boolean);
}

grunt.task.run(tasks);
});

// Run while developing
grunt.registerTask('dev', ['connect:dev', 'concurrent:dev']);
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
"remark-lint": "^5.2.0",
"remark-toc": "^3.1.0",
"remark-validate-links": "^5.0.0",
"shelljs": "^0.7.5",
"sinon": "^1.16.1",
"time-grunt": "^1.1.1",
"uglify-js": "~2.7.3",
Expand Down