build: update to clang 1.4.0 and only run clang format on changed files (#36203)

Update to clang@1.4.0 to gain support for optional changing and nullish
coalescing.  Because this would trigger a change on >1800 files in the
repository, also changes our format enforcement to only be run against
changed files.  This will allow us to incramentally roll out the value
add of the upgraded clang format.

PR Close #36203
This commit is contained in:
Joey Perrott 2020-03-23 08:53:42 -07:00 committed by Alex Rickabaugh
parent 51a89c32c4
commit c5c57f6737
6 changed files with 60 additions and 41 deletions

View File

@ -278,7 +278,7 @@ jobs:
- run: 'yarn bazel:lint ||
(echo -e "\n.bzl files have lint errors. Please run ''yarn bazel:lint-fix''"; exit 1)'
- run: yarn lint
- run: yarn lint --branch $CI_GIT_BASE_REVISION
- run: yarn ts-circular-deps:check
- run: yarn -s ng-dev pullapprove:verify

View File

@ -30,6 +30,8 @@ else
setPublicVar CI_COMMIT "$CIRCLE_SHA1";
# `CI_COMMIT_RANGE` is only used on push builds (a.k.a. non-PR, non-scheduled builds and rerun
# workflows of such builds).
setPublicVar CI_GIT_BASE_REVISION "${CIRCLE_GIT_BASE_REVISION}";
setPublicVar CI_GIT_REVISION "${CIRCLE_GIT_REVISION}";
setPublicVar CI_COMMIT_RANGE "$CIRCLE_GIT_BASE_REVISION..$CIRCLE_GIT_REVISION";
setPublicVar CI_PULL_REQUEST "${CIRCLE_PR_NUMBER:-false}";
setPublicVar CI_REPO_NAME "$CIRCLE_PROJECT_REPONAME";

View File

@ -26,26 +26,30 @@ function loadTask(fileName, taskName) {
return task(gulp);
}
// Check source code for formatting errors in all source files.
gulp.task('format:enforce', loadTask('format', 'enforce'));
//#######################################################
// A format and enforce task for different sets of files.
//#######################################################
// Format all source files.
// All source files.
gulp.task('format:all', loadTask('format', 'format'));
gulp.task('format:all:enforce', loadTask('format', 'enforce'));
// Format only untracked source code files.
// Untracked source code files.
gulp.task('format:untracked', loadTask('format', 'format-untracked'));
gulp.task('format:untracked:enforce', loadTask('format', 'enforce-untracked'));
// Format only the changed, tracked source code files.
// Changed, tracked source code files.
gulp.task('format:diff', loadTask('format', 'format-diff'));
gulp.task('format:diff:enforce', loadTask('format', 'enforce-diff'));
// Format only changed lines based on the diff from the provided --branch
// argument (or `master` by default).
// Changed, both tracked and untracked, source code files.
gulp.task('format:changed', ['format:untracked', 'format:diff']);
gulp.task('format:changed:enforce', ['format:untracked:enforce', 'format:diff:enforce']);
// Alias for `format:changed` that formerly formatted all files.
gulp.task('format', ['format:changed']);
gulp.task('lint', ['format:enforce', 'validate-commit-messages']);
gulp.task('lint', ['format:changed:enforce', 'validate-commit-messages']);
gulp.task('validate-commit-messages', loadTask('validate-commit-message'));
gulp.task('source-map-test', loadTask('source-map-test'));
gulp.task('changelog', loadTask('changelog'));

View File

@ -157,7 +157,7 @@
"@yarnpkg/lockfile": "^1.1.0",
"browserstacktunnel-wrapper": "2.0.1",
"check-side-effects": "0.0.21",
"clang-format": "1.0.41",
"clang-format": "^1.4.0",
"cldr": "4.10.0",
"cldr-data": "36.0.0",
"cldrjs": "0.5.0",
@ -167,7 +167,7 @@
"firefox-profile": "1.0.3",
"glob": "7.1.2",
"gulp": "3.9.1",
"gulp-clang-format": "1.0.23",
"gulp-clang-format": "^1.0.27",
"gulp-conventional-changelog": "^2.0.3",
"gulp-filter": "^5.1.0",
"gulp-git": "^2.7.0",

View File

@ -85,7 +85,7 @@ function gulpStatus() {
}
module.exports = {
// Check source code for formatting errors (clang-format)
// Check source code for formatting errors with clang-format
enforce: (gulp) => () => {
const format = require('gulp-clang-format');
const clangFormat = require('clang-format');
@ -93,6 +93,34 @@ module.exports = {
format.checkFormat('file', clangFormat, {verbose: true, fail: true}));
},
// Check only the untracked source code files for formatting errors with .clang-format
'enforce-untracked': (gulp) => () => {
const format = require('gulp-clang-format');
const clangFormat = require('clang-format');
const gulpFilter = require('gulp-filter');
return gulpStatus()
.pipe(gulpFilter(srcsToFmt))
.pipe(format.checkFormat('file', clangFormat, {verbose: true, fail: true}));
},
// Check only the changed source code files diffed from the provided branch for formatting
// errors with clang-format
'enforce-diff': (gulp) => () => {
const format = require('gulp-clang-format');
const clangFormat = require('clang-format');
const gulpFilter = require('gulp-filter');
const minimist = require('minimist');
const gulpGit = require('gulp-git');
const args = minimist(process.argv.slice(2));
const branch = args.branch || 'master';
return gulpGit.diff(branch, {log: false})
.pipe(gulpFilter(srcsToFmt))
.pipe(format.checkFormat('file', clangFormat, {verbose: true, fail: true}));
},
// Format the source code with clang-format (see .clang-format)
format: (gulp) => () => {
const format = require('gulp-clang-format');

View File

@ -3570,19 +3570,10 @@ cjson@^0.3.1:
dependencies:
json-parse-helpfulerror "^1.0.3"
clang-format@1.0.41:
version "1.0.41"
resolved "https://registry.yarnpkg.com/clang-format/-/clang-format-1.0.41.tgz#28552e50b0c9e44d23f85aebe3d2fbd06c93620c"
integrity sha1-KFUuULDJ5E0j+Frr49L70GyTYgw=
dependencies:
async "^1.5.2"
glob "^7.0.0"
resolve "^1.1.6"
clang-format@^1.0.32:
version "1.2.3"
resolved "https://registry.yarnpkg.com/clang-format/-/clang-format-1.2.3.tgz#2763561aa7449c43737480f8df3a2b5b66e6cf37"
integrity sha512-x90Hac4ERacGDcZSvHKK58Ga0STuMD+Doi5g0iG2zf7wlJef5Huvhs/3BvMRFxwRYyYSdl6mpQNrtfMxE8MQzw==
clang-format@^1.0.32, clang-format@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/clang-format/-/clang-format-1.4.0.tgz#1ee2f10637eb5bb0bd7d0b82c949af68e848367e"
integrity sha512-NrdyUnHJOGvMa60vbWk7GJTvOdhibj3uK5C0FlwdNG4301OUvqEJTFce9I9x8qw2odBbIVrJ+9xbsFS3a4FbDA==
dependencies:
async "^1.5.2"
glob "^7.0.0"
@ -7020,18 +7011,17 @@ gtoken@^4.1.0:
jws "^4.0.0"
mime "^2.2.0"
gulp-clang-format@1.0.23:
version "1.0.23"
resolved "https://registry.yarnpkg.com/gulp-clang-format/-/gulp-clang-format-1.0.23.tgz#fe258586b83998491e632fc0c4fc0ecdfa10c89f"
integrity sha1-/iWFhrg5mEkeYy/AxPwOzfoQyJ8=
gulp-clang-format@^1.0.27:
version "1.0.27"
resolved "https://registry.yarnpkg.com/gulp-clang-format/-/gulp-clang-format-1.0.27.tgz#c89716c26745703356c4ff3f2b0964393c73969e"
integrity sha512-Jj4PGuNXKdqVCh9fijvL7wdzma5TQRJz1vv8FjOjnSkfq3s/mvbdE/jq+5HG1c/q+jcYkXTEGkYT3CrdnJOLaQ==
dependencies:
clang-format "^1.0.32"
fancy-log "^1.3.2"
gulp-diff "^1.0.0"
gulp-util "^3.0.4"
pkginfo "^0.3.0"
plugin-error "^1.0.1"
stream-combiner2 "^1.1.1"
stream-equal "0.1.6"
through2 "^0.6.3"
through2 "^2.0.3"
gulp-conventional-changelog@^2.0.3:
version "2.0.3"
@ -7089,7 +7079,7 @@ gulp-tslint@8.1.2:
map-stream "~0.0.7"
through "~2.3.8"
gulp-util@^3.0.0, gulp-util@^3.0.4, gulp-util@^3.0.6, gulp-util@~3.0.8:
gulp-util@^3.0.0, gulp-util@^3.0.6, gulp-util@~3.0.8:
version "3.0.8"
resolved "https://registry.yarnpkg.com/gulp-util/-/gulp-util-3.0.8.tgz#0054e1e744502e27c04c187c3ecc505dd54bbb4f"
integrity sha1-AFTh50RQLifATBh8PsxQXdVLu08=
@ -11459,7 +11449,7 @@ pkg-dir@^4.1.0:
dependencies:
find-up "^4.0.0"
pkginfo@0.3.x, pkginfo@^0.3.0:
pkginfo@0.3.x:
version "0.3.1"
resolved "https://registry.yarnpkg.com/pkginfo/-/pkginfo-0.3.1.tgz#5b29f6a81f70717142e09e765bbeab97b4f81e21"
integrity sha1-Wyn2qB9wcXFC4J52W76rl7T4HiE=
@ -13853,11 +13843,6 @@ stream-each@^1.1.0:
end-of-stream "^1.1.0"
stream-shift "^1.0.0"
stream-equal@0.1.6:
version "0.1.6"
resolved "https://registry.yarnpkg.com/stream-equal/-/stream-equal-0.1.6.tgz#cc522fab38516012e4d4ee47513b147b72359019"
integrity sha1-zFIvqzhRYBLk1O5HUTsUe3I1kBk=
stream-http@^2.7.2:
version "2.8.3"
resolved "https://registry.yarnpkg.com/stream-http/-/stream-http-2.8.3.tgz#b2d242469288a5a27ec4fe8933acf623de6514fc"
@ -14445,7 +14430,7 @@ through2@2.0.1:
readable-stream "~2.0.0"
xtend "~4.0.0"
through2@^0.6.1, through2@^0.6.3:
through2@^0.6.1:
version "0.6.5"
resolved "https://registry.yarnpkg.com/through2/-/through2-0.6.5.tgz#41ab9c67b29d57209071410e1d7a7a968cd3ad48"
integrity sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=