chore: adds a check for properly formatted files (#5624)

* chore: add check for clang format

* chore: updates clang format script
This commit is contained in:
alschmiedt
2021-10-25 11:43:59 -07:00
committed by GitHub
parent 52c0427d85
commit 8a89e080fd
5 changed files with 1014 additions and 7 deletions

View File

@@ -0,0 +1,27 @@
name: test-clang-format
on: [pull_request]
jobs:
clang-formatter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: DoozyX/clang-format-lint-action@v0.12
with:
source: 'core'
extensions: 'js'
clangFormatVersion: 12
style: Google
- uses: actions/github-script@v5
if: failure()
with:
script: |
console.log(context.issue.number)
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'It looks like some of your files have not been formatted properly. Please run `npm run format`.'
})

View File

@@ -35,6 +35,7 @@ module.exports = {
buildAdvancedCompilationTest: buildTasks.advancedCompilationTest,
checkin: gulp.parallel(buildTasks.checkinBuilt, typings.checkinTypings),
checkinBuilt: buildTasks.checkinBuilt,
clangFormat: buildTasks.format,
clean: gulp.parallel(buildTasks.cleanBuildDir, packageTasks.cleanReleaseDir),
cleanBuildDir: buildTasks.cleanBuildDir,
cleanReleaseDir: packageTasks.cleanReleaseDir,

979
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -37,7 +37,7 @@
"checkin:typings": "gulp checkinTypings",
"deployDemos": "gulp deployDemos",
"deployDemos:beta": "gulp deployDemosBeta",
"format": "git-clang-format",
"format": "gulp clangFormat",
"format:sortrequires": "gulp sortRequires",
"generate:langfiles": "gulp generateLangfiles",
"license": "gulp checkLicenses",
@@ -78,6 +78,7 @@
"google-closure-compiler": "^20211006.0.0",
"google-closure-deps": "^20210808.0.0",
"gulp": "^4.0.2",
"gulp-clang-format": "^1.0.27",
"gulp-concat": "^2.6.1",
"gulp-insert": "^0.5.0",
"gulp-rename": "^2.0.0",

View File

@@ -18,6 +18,7 @@ var fs = require('fs');
var execSync = require('child_process').execSync;
var through2 = require('through2');
const clangFormatter = require('gulp-clang-format');
var closureCompiler = require('google-closure-compiler').gulp();
var closureDeps = require('google-closure-deps');
var argv = require('yargs').argv;
@@ -510,6 +511,15 @@ function cleanBuildDir(done) {
rimraf(BUILD_DIR, done);
}
/**
* Runs clang format on all files in the core directory.
*/
function format() {
return gulp.src(['core/**/*.js'], {base: '.'})
.pipe(clangFormatter.format('file'))
.pipe(gulp.dest('.'));
};
module.exports = {
build: build,
deps: buildDeps,
@@ -518,6 +528,7 @@ module.exports = {
generateLangfiles: generateLangfiles,
langfiles: buildLangfiles,
compressed: buildCompressed,
format: format,
generators: buildGenerators,
checkinBuilt: checkinBuilt,
cleanBuildDir: cleanBuildDir,