mirror of
https://github.com/google/blockly.git
synced 2026-01-07 17:10:11 +01:00
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:
27
.github/workflows/check_clang_format.yml
vendored
Normal file
27
.github/workflows/check_clang_format.yml
vendored
Normal 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`.'
|
||||
})
|
||||
@@ -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
979
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -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",
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user