[internal] Reject CI builds if any .rej files exist

.rej are the byproduct of failed patches via git-apply or artifacts of
the backporting process through jasper. Any build that has them should
be rejected early.
This commit is contained in:
Court Ewing 2016-03-29 13:24:24 -04:00
parent 520f9a737a
commit 55e429cc4f
2 changed files with 31 additions and 0 deletions

View file

@ -16,6 +16,7 @@ module.exports = function (grunt) {
grunt.option('os-packages', true);
grunt.task.run(compact([
'rejectRejFiles',
'test',
process.env.JOB_NAME === 'kibana_core' ? 'build' : null
]));

30
tasks/reject_rej_files.js Normal file
View file

@ -0,0 +1,30 @@
import { startsWith } from 'lodash';
// Fails if any .rej files are found
// .rej files are an artifact from a failed git-apply or a jasper backport
// This check is intentionally performed on the files in the repo rather than
// on the files that are to be committed.
export default grunt => {
grunt.registerTask('rejectRejFiles', 'Reject any git-apply .rej files', () => {
const ignoredTopLevelDirs = [
'esvm',
'installedPlugins',
'node_modules',
'optimize'
];
const matchBase = true;
const filter = file => (
ignoredTopLevelDirs.every(dir => !startsWith(file, dir))
);
const files = grunt.file.expand({ filter, matchBase }, '*.rej');
if (files.length > 0) {
const err = `.rej files are not allowed:\n${files.join('\n')}`;
grunt.log.error(err);
return false;
}
});
};