From 5936624d114d32f8b6f10f5c044f625b03b76a37 Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Wed, 25 May 2016 19:54:34 -0700 Subject: [PATCH] chore(lint): re-enable clang-format on tools/ --- .travis.yml | 2 -- circle.yml | 12 +----------- gulpfile.js | 36 ++++++++++++++++++++++++------------ scripts/ci-lite/lint.sh | 15 --------------- scripts/ci-lite/test.sh | 1 - tools/check-environment.js | 6 +++++- 6 files changed, 30 insertions(+), 42 deletions(-) delete mode 100755 scripts/ci-lite/lint.sh diff --git a/.travis.yml b/.travis.yml index b9a5411c05..0af99eb77a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,8 +40,6 @@ env: matrix: # Order: a slower build first, so that we don't occupy an idle travis worker waiting for others to complete. - CI_MODE=js - # disabled because it currently doesn't do anything - #- CI_MODE=lint - CI_MODE=e2e - CI_MODE=saucelabs_required - CI_MODE=browserstack_required diff --git a/circle.yml b/circle.yml index 7c14beeb3b..289b1b8863 100644 --- a/circle.yml +++ b/circle.yml @@ -5,17 +5,7 @@ machine: dependencies: pre: - npm install -g npm - override: - - npm install: - environment: - # Token for tsd to increase github rate limit - # See https://github.com/DefinitelyTyped/tsd#tsdrc - # This is not hidden using https://circleci.com/docs/fork-pr-builds#details - # because those are not visible for pull requests, and those should also be reliable. - # This SSO token belongs to github account angular-github-ratelimit-token which has no access - # (password is in Valentine) - TSD_GITHUB_TOKEN: ef474500309daea53d5991b3079159a29520a40b test: override: - - npm run build + - gulp lint diff --git a/gulpfile.js b/gulpfile.js index d3e897353f..bd450456dd 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -3,16 +3,30 @@ // THIS CHECK SHOULD BE THE FIRST THING IN THIS FILE // This is to ensure that we catch env issues before we error while requiring other dependencies. require('./tools/check-environment')( - {requiredNpmVersion: '>=3.5.3 <4.0.0', requiredNodeVersion: '>=5.4.1 <6.0.0'}); + {requiredNpmVersion: '>=3.5.3 <4.0.0', requiredNodeVersion: '>=5.4.1 <6.0.0'}); -let gulp = require('gulp'); +const gulp = require('gulp'); +const path = require('path'); +const srcsToFmt = ['tools/**/*.ts']; -gulp.task('tools:build', (done) => { - tsc('tools/', done) +gulp.task('lint', () => { + const format = require('gulp-clang-format'); + const clangFormat = require('clang-format'); + return gulp.src(srcsToFmt).pipe( + format.checkFormat('file', clangFormat, {verbose: true, fail: true})); }); +gulp.task('format', () => { + const format = require('gulp-clang-format'); + const clangFormat = require('clang-format'); + return gulp.src(srcsToFmt, { base: '.' }).pipe( + format.format('file', clangFormat)).pipe(gulp.dest('.')); +}); + +gulp.task('tools:build', (done) => { tsc('tools/', done); }); + gulp.task('serve', () => { let connect = require('gulp-connect'); @@ -23,9 +37,7 @@ gulp.task('serve', () => { port: 8000, livereload: false, open: false, - middleware: (connect, opt) => { - return [cors()]; - } + middleware: (connect, opt) => [cors()] }); }); @@ -33,9 +45,9 @@ gulp.task('serve', () => { function tsc(projectPath, done) { let child_process = require('child_process'); - child_process.spawn( - `${__dirname}/node_modules/.bin/tsc`, - ['-p', `${__dirname}/projectPath`], - {stdio: 'inherit'} - ).on('close', (errorCode) => done(errorCode)); + child_process + .spawn( + `${__dirname}/node_modules/.bin/tsc`, ['-p', path.join(__dirname, projectPath)], + {stdio: 'inherit'}) + .on('close', (errorCode) => done(errorCode)); } diff --git a/scripts/ci-lite/lint.sh b/scripts/ci-lite/lint.sh deleted file mode 100755 index f69c585d61..0000000000 --- a/scripts/ci-lite/lint.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash - -set -ex -o pipefail - -if [[ ${TRAVIS} && ${CI_MODE} != "lint" ]]; then - exit 0; -fi - - -echo 'travis_fold:start:lint' - -gulp lint -gulp check-format - -echo 'travis_fold:end:lint' diff --git a/scripts/ci-lite/test.sh b/scripts/ci-lite/test.sh index 739d2eafed..deaa8b03f6 100755 --- a/scripts/ci-lite/test.sh +++ b/scripts/ci-lite/test.sh @@ -9,7 +9,6 @@ cd `dirname $0` source ./env.sh cd ../.. -./scripts/ci-lite/lint.sh ./scripts/ci-lite/test_js.sh ./scripts/ci-lite/test_e2e.sh ./scripts/ci-lite/test_saucelabs.sh diff --git a/tools/check-environment.js b/tools/check-environment.js index 7c21b88652..8cbede5837 100644 --- a/tools/check-environment.js +++ b/tools/check-environment.js @@ -79,9 +79,13 @@ function printWarning(issues) { console.warn(''); console.warn(Array(110).join('!')); console.warn('!!! Your environment is not in a good shape. Following issues were found:'); - issues.forEach(function(issue) {console.warn('!!! - ' + issue)}); + issues.forEach(function(issue) {console.warn('!!! - ' + issue);}); console.warn(Array(110).join('!')); console.warn(''); + + if (process.env.CI) { + process.exit(1); + } }