Skip to content

Commit 1b6602c

Browse files
committed
build: use Bazel from npm
Also hook up bazel format/lint
1 parent 458ba75 commit 1b6602c

File tree

4 files changed

+57
-10
lines changed

4 files changed

+57
-10
lines changed

.circleci/config.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@
1010
# Variables
1111

1212
## IMPORTANT
13-
# If you change the `docker_image` version, also change the `cache_key` suffix and the version of
14-
# `com_github_bazelbuild_buildtools` in the `/WORKSPACE` file.
1513
# If you change the cache key prefix, also sync the restore_cache fallback to match.
1614
# Keep the static part of the cache key as prefix to enable correct fallbacks.
1715
# See https://circleci.com/docs/2.0/caching/#restoring-cache for how prefixes work in CircleCI.
18-
var_1: &docker_image angular/ngcontainer:0.10.0
16+
var_1: &docker_image circleci/node:10.12
1917
var_2: &cache_key angular_devkit-0.10.0-{{ checksum "yarn.lock" }}
2018

2119
# Settings common to each job
@@ -71,6 +69,11 @@ jobs:
7169
steps:
7270
- attach_workspace: *attach_options
7371
- run: npm run lint
72+
- run: 'yarn bazel:format -mode=check ||
73+
(echo "BUILD files not formatted. Please run ''yarn bazel:format''" ; exit 1)'
74+
# Run the skylark linter to check our Bazel rules
75+
- run: 'yarn bazel:lint ||
76+
(echo -e "\n.bzl files have lint errors. Please run ''yarn bazel:lint-fix''"; exit 1)'
7477

7578
validate:
7679
<<: *defaults
@@ -145,7 +148,7 @@ jobs:
145148
steps:
146149
- attach_workspace: *attach_options
147150
- run: sudo cp .circleci/bazel.rc /etc/bazel.bazelrc
148-
- run: bazel test ...
151+
- run: yarn bazel:test
149152

150153
snapshot_publish:
151154
<<: *defaults

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
],
2121
"scripts": {
2222
"admin": "node ./bin/devkit-admin",
23+
"bazel:format": "find . -type f \\( -name \"*.bzl\" -or -name WORKSPACE -or -name BUILD -or -name BUILD.bazel \\) ! -path \"*/node_modules/*\" | xargs buildifier -v --warnings=args-order,attr-cfg,attr-license,attr-non-empty,attr-output-default,attr-single-file,constant-glob,ctx-args,depset-iteration,depset-union,dict-concatenation,duplicated-name,filetype,git-repository,http-archive,integer-division,load,load-on-top,native-build,native-package,output-group,package-name,package-on-top,positional-args,redefined-variable,repository-name,same-origin-load,string-iteration,unused-variable",
24+
"bazel:lint": "yarn bazel:format --lint=warn",
25+
"bazel:lint-fix": "yarn bazel:format --lint=fix",
26+
"bazel:test": "bazel test //...",
2327
"build": "npm run admin -- build",
2428
"build-tsc": "tsc -p tsconfig.json",
2529
"fix": "npm run admin -- lint --fix",
@@ -80,6 +84,8 @@
8084
"devDependencies": {
8185
"@angular/compiler": "^8.0.0-beta.12",
8286
"@angular/compiler-cli": "^8.0.0-beta.12",
87+
"@bazel/bazel": "^0.24.0",
88+
"@bazel/buildifier": "^0.22.0",
8389
"@bazel/karma": "~0.26.0",
8490
"@bazel/typescript": "~0.26.0",
8591
"@ngtools/json-schema": "^1.1.0",

tools/ts_json_schema.bzl

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,14 @@ _ts_json_schema_interface = rule(
2626
_ts_json_schema_interface_impl,
2727
attrs = {
2828
"src": attr.label(
29-
allow_files = FileType([
30-
".json",
31-
]),
29+
allow_files = [".json"],
3230
mandatory = True,
3331
),
3432
"out": attr.string(
3533
mandatory = True,
3634
),
3735
"data": attr.label_list(
38-
allow_files = FileType([
39-
".json",
40-
]),
36+
allow_files = [".json"],
4137
),
4238
"_binary": attr.label(
4339
default = Label("//tools:quicktype_runner"),

yarn.lock

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,48 @@
188188
lodash "^4.17.10"
189189
to-fast-properties "^2.0.0"
190190

191+
"@bazel/bazel-darwin_x64@0.24.0":
192+
version "0.24.0"
193+
resolved "https://registry.yarnpkg.com/@bazel/bazel-darwin_x64/-/bazel-darwin_x64-0.24.0.tgz#828ef298d8d542961df388f17b0244f4f4302a74"
194+
integrity sha512-xly44vkcD/fauUb7Lm5Lme4qhEZdkuuyBKSVQUHPbYAGDdbj/W8dupI3bZREkJAgG/WrRU+WXUemMj4U8ZcLcw==
195+
196+
"@bazel/bazel-linux_x64@0.24.0":
197+
version "0.24.0"
198+
resolved "https://registry.yarnpkg.com/@bazel/bazel-linux_x64/-/bazel-linux_x64-0.24.0.tgz#9ef2e7266833ad2221fe4af4ceb6763d2897e3ff"
199+
integrity sha512-p5ylPLWnJZDGbaIFBrtD/tp3Su5rMdzeeNJKU24XyiWQTHVZ3OD3I2Fb0ILCgfBjY8AlA7EtCtOI4hYnAuIOtg==
200+
201+
"@bazel/bazel-win32_x64@0.24.0":
202+
version "0.24.0"
203+
resolved "https://registry.yarnpkg.com/@bazel/bazel-win32_x64/-/bazel-win32_x64-0.24.0.tgz#02d83113a6c6ed99795a3e41bff5631aa141638d"
204+
integrity sha512-/bcSEx+GoV/q7H4WM0jazfxTcurSiIIePhRv+d05mxRDcaWwhCO8KzmmZRWH1abW6npvq5tLkbSQi7G7nUBhgg==
205+
206+
"@bazel/bazel@^0.24.0":
207+
version "0.24.0"
208+
resolved "https://registry.yarnpkg.com/@bazel/bazel/-/bazel-0.24.0.tgz#f4e68e3680ac299858c24c26be3d08d1151e78fc"
209+
integrity sha512-/5E55tqH9ogAGF9Dd7RSCJmk7/xdlsPTAhsX3yEsEMs7GLdHlgD3jbeePsKUiHKKr8LXAufjTs2pXQfjrkZRMg==
210+
optionalDependencies:
211+
"@bazel/bazel-darwin_x64" "0.24.0"
212+
"@bazel/bazel-linux_x64" "0.24.0"
213+
"@bazel/bazel-win32_x64" "0.24.0"
214+
215+
"@bazel/buildifier-darwin_x64@0.22.0":
216+
version "0.22.0"
217+
resolved "https://registry.yarnpkg.com/@bazel/buildifier-darwin_x64/-/buildifier-darwin_x64-0.22.0.tgz#00dde7ce03be8c550b3908dd91cf1fc0baef7ff7"
218+
integrity sha512-tpJ6w3mmh8wBm/k5AidAZvjWm3Hge3ipSjGtxTfq/xgUCacAtGt219nwyAMs0CwLPuABLbcINQmmKtG5VpxK9A==
219+
220+
"@bazel/buildifier-linux_x64@0.22.0":
221+
version "0.22.0"
222+
resolved "https://registry.yarnpkg.com/@bazel/buildifier-linux_x64/-/buildifier-linux_x64-0.22.0.tgz#146c44bafbb1e4711725414582a49835d04b8618"
223+
integrity sha512-qaE7QF2YHKOXFBk2QcwOBfA3Ipm08vP9ZK9Vxtubbq9O0MM5tWvfKI48VkfX6pg8QNXDJ+sBndznxQSSWstsWQ==
224+
225+
"@bazel/buildifier@^0.22.0":
226+
version "0.22.0"
227+
resolved "https://registry.yarnpkg.com/@bazel/buildifier/-/buildifier-0.22.0.tgz#d1abc2ce4317ba71351276c6b1b9e1533abf8e3d"
228+
integrity sha512-S+mrUwanR8HMcp92iEDk4D1oOLsVhCM42Hx0rqL1eVmXPwLYL+F/sIjeGTw/6BgxMEHVSl2M3CcTFAS0b60BTQ==
229+
optionalDependencies:
230+
"@bazel/buildifier-darwin_x64" "0.22.0"
231+
"@bazel/buildifier-linux_x64" "0.22.0"
232+
191233
"@bazel/karma@~0.26.0":
192234
version "0.26.0"
193235
resolved "https://registry.yarnpkg.com/@bazel/karma/-/karma-0.26.0.tgz#6ad796686f5775df33a96fa5ef3df76a66aed3b2"

0 commit comments

Comments
 (0)