From cab5927bd52c802dd21574595a3f584bb7dc55ac Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Wed, 5 Dec 2018 12:16:14 -0800 Subject: [PATCH] ci: use buildifier binary release (#27489) Switch from Skylint to buildifier --lint - this is required for the Bazel 0.20 upgrade since Bazel no longer lets us use the embedded JDK to build and run Java programs, and Skylint is a Java program PR Close #27489 --- .circleci/config.yml | 10 ++++------ WORKSPACE | 1 + package.json | 9 ++++----- packages/bazel/package.bzl | 15 --------------- yarn.lock | 18 ++++++++++++++++++ 5 files changed, 27 insertions(+), 26 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4f51ff9ffa..c299b9a782 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -53,21 +53,19 @@ version: 2 jobs: lint: <<: *job_defaults - resource_class: xlarge steps: - checkout: <<: *post_checkout - restore_cache: key: *cache_key - *define_env_vars - - *setup_circleci_bazel_config - *yarn_install - - run: 'yarn buildifier -mode=check || - (echo "BUILD files not formatted. Please run ''yarn buildifier''" ; exit 1)' + - run: 'yarn bazel:format -mode=check || + (echo "BUILD files not formatted. Please run ''yarn bazel:format''" ; exit 1)' # Run the skylark linter to check our Bazel rules - - run: 'yarn skylint || - (echo -e "\n.bzl files have lint errors. Please run ''yarn skylint''"; exit 1)' + - run: 'yarn bazel:lint || + (echo -e "\n.bzl files have lint errors. Please run ''yarn bazel:lint-fix''"; exit 1)' - run: ./node_modules/.bin/gulp lint diff --git a/WORKSPACE b/WORKSPACE index f0f8c13193..ed1795bec3 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,5 +1,6 @@ workspace(name = "angular") +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load( "//packages/bazel:package.bzl", "rules_angular_dependencies", diff --git a/package.json b/package.json index 134abf2e65..1a7c57e4f1 100644 --- a/package.json +++ b/package.json @@ -16,11 +16,9 @@ "url": "https://github.com/angular/angular.git" }, "scripts": { - "preskylint": "bazel build --noshow_progress @io_bazel//src/tools/skylark/java/com/google/devtools/skylark/skylint:Skylint", - "//": "deprecated-api is disabled because we use actions.new_file(genfiles_dir) which has no replacement, see https://github.com/bazelbuild/bazel/issues/4858", - "skylint": "find . -type f -name \"*.bzl\" ! -path \"*/node_modules/*\" ! -path \"./dist/*\" | xargs $(bazel info bazel-bin)/external/io_bazel/src/tools/skylark/java/com/google/devtools/skylark/skylint/Skylint --disable-checks=deprecated-api", - "prebuildifier": "bazel build --noshow_progress @com_github_bazelbuild_buildtools//buildifier", - "buildifier": "find . -type f \\( -name \"*.bzl\" -or -name BUILD -or -name BUILD.bazel \\) ! -path \"*/node_modules/*\" | xargs $(bazel info bazel-bin)/external/com_github_bazelbuild_buildtools/buildifier/*/buildifier", + "bazel:format": "find . -type f \\( -name \"*.bzl\" -or -name BUILD -or -name BUILD.bazel -or -name WORKSPACE \\) ! -path \"*/node_modules/*\" | xargs buildifier -v", + "bazel:lint": "yarn bazel:format --lint=warn", + "bazel:lint-fix": "yarn bazel:format --lint=fix", "preinstall": "node tools/yarn/check-yarn.js", "postinstall": "yarn update-webdriver && node ./tools/postinstall-patches.js", "update-webdriver": "webdriver-manager update --gecko false $CHROMEDRIVER_VERSION_ARG", @@ -91,6 +89,7 @@ "// 2": "devDependencies are not used under Bazel. Many can be removed after test.sh is deleted.", "devDependencies": { "@bazel/bazel": "^0.18.1", + "@bazel/buildifier": "^0.19.2", "@bazel/ibazel": "~0.8.2", "@types/angular": "^1.6.47", "@types/base64-js": "1.2.5", diff --git a/packages/bazel/package.bzl b/packages/bazel/package.bzl index e956f0d058..d417094d27 100644 --- a/packages/bazel/package.bzl +++ b/packages/bazel/package.bzl @@ -74,21 +74,6 @@ def rules_angular_dev_dependencies(): url = "https://github.com/google/brotli/archive/v1.0.5.zip", ) - # Fetching the Bazel source code allows us to compile the Skylark linter - http_archive( - name = "io_bazel", - sha256 = "978f7e0440dd82182563877e2e0b7c013b26b3368888b57837e9a0ae206fd396", - strip_prefix = "bazel-0.18.0", - url = "https://github.com/bazelbuild/bazel/archive/0.18.0.zip", - ) - - http_archive( - name = "com_github_bazelbuild_buildtools", - sha256 = "a82d4b353942b10c1535528b02bff261d020827c9c57e112569eddcb1c93d7f6", - strip_prefix = "buildtools-0.17.2", - url = "https://github.com/bazelbuild/buildtools/archive/0.17.2.zip", - ) - ############################################# # Dependencies for generating documentation # ############################################# diff --git a/yarn.lock b/yarn.lock index ac5745fd5a..20edea23f7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -64,6 +64,24 @@ "@bazel/bazel-linux_x64" "0.18.0" "@bazel/bazel-win32_x64" "0.18.0" +"@bazel/buildifier-darwin_x64@0.19.2": + version "0.19.2" + resolved "https://registry.yarnpkg.com/@bazel/buildifier-darwin_x64/-/buildifier-darwin_x64-0.19.2.tgz#1182862b4a3578fb9367ab42e807131187a61702" + integrity sha512-f6CITRj8jFhhZFrQkIao3IgJjZAXGYwUkW/QBSeAu0HIltBerJ0FTt/Nmu9ji1QZYT2aO4RpZ8oJksG6xv1dcQ== + +"@bazel/buildifier-linux_x64@0.19.2": + version "0.19.2" + resolved "https://registry.yarnpkg.com/@bazel/buildifier-linux_x64/-/buildifier-linux_x64-0.19.2.tgz#8b26eaf1f091cd3846a7dd7ea94008b55498401e" + integrity sha512-kJjzbrjuAW4yVms5mbTWSHpJF6ogDLkuq4MjVP6a03umQ7E15o9YoxbDoiN+CzAj9ZMWPWfc5/N5TouiwXkGzA== + +"@bazel/buildifier@^0.19.2": + version "0.19.2" + resolved "https://registry.yarnpkg.com/@bazel/buildifier/-/buildifier-0.19.2.tgz#3e077de346ad98561cee703297aa8db50cfb3c76" + integrity sha512-MwkuoQdOdZ/VYKJvZe3qVCn3/20pLJyJpzNl3cBmaccWeUtdDKhtOm8YlLU08lxrt0VcKNcTYt4uiA62e/315A== + optionalDependencies: + "@bazel/buildifier-darwin_x64" "0.19.2" + "@bazel/buildifier-linux_x64" "0.19.2" + "@bazel/ibazel@~0.8.2": version "0.8.2" resolved "https://registry.yarnpkg.com/@bazel/ibazel/-/ibazel-0.8.2.tgz#a837d93922c0d273361ed4f141c792384c0e10bb"