Skip to content

Commit f853cb0

Browse files
authored
refactor: switch to gazelle (#478)
1 parent c1de639 commit f853cb0

File tree

14 files changed

+175
-53
lines changed

14 files changed

+175
-53
lines changed

.aspect/cli/config.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
configure:
2-
languages:
3-
javascript: true
4-
go: true
5-
protobuf: true
6-
python: true
7-
plugins:
8-
- .aspect/cli/main.star
9-
- .aspect/cli/rules_cc.star
101
plugins:
112
- name: fix-visibility
123
from: github.com/aspect-build/plugin-fix-visibility

.aspect/workflows/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# See https://docs.aspect.build/workflows/configuration
22
tasks:
3-
- configure:
3+
- gazelle:
44
- checkout:
55
update_strategy: rebase
66
- lint:

.bazeliskrc

Lines changed: 0 additions & 6 deletions
This file was deleted.

.bazelrc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ import %workspace%/tools/preset.bazelrc
77
# We have a lot of dependencies and are okay with some of them bringing a newer version via a transitive dep.
88
common --check_direct_dependencies=off
99

10+
# When running locally, warn about unconfigured git hooks.
11+
common --workspace_status_command=githooks/check-config.sh
12+
# But not on CI.
13+
common:ci --workspace_status_command=
1014
# Placeholder for your actual stamping logic
11-
build --workspace_status_command='echo BUILD_VERSION v1.2.3'
15+
build:release --workspace_status_command='echo BUILD_VERSION v1.2.3'
1216

13-
# As an alternative to using Aspect CLI to get the 'bazel lint' command,
14-
# users could run 'bazel build --config=lint' to produce the linter reports.
17+
# 'bazel build --config=lint' will produce the linter reports.
1518
build:lint --aspects=//tools/lint:linters.bzl%buf
1619
build:lint --aspects=//tools/lint:linters.bzl%clang_tidy
1720
build:lint --aspects=//tools/lint:linters.bzl%eslint

.circleci/config.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ workflows:
1616
requires:
1717
- aw-test
1818
workspace: .
19-
- aw-configure:
19+
- aw-format:
2020
context: []
2121
workspace: .
22-
- aw-format:
22+
- aw-gazelle:
2323
context: []
2424
workspace: .
2525
- aw-lint:
@@ -102,7 +102,7 @@ jobs:
102102
name: Delivery
103103
no_output_timeout: 180m
104104
working_directory: /mnt/ephemeral/workdir
105-
aw-configure:
105+
aw-format:
106106
environment:
107107
ASPECT_WORKFLOWS_CIRCLE_PIPELINE_NUMBER: << pipeline.number >>
108108
ASPECT_WORKFLOWS_CIRCLE_PIPELINE_PROJECT_TYPE: << pipeline.project.type >>
@@ -135,8 +135,8 @@ jobs:
135135
name: Checkout health
136136
no_output_timeout: 180m
137137
- run:
138-
command: rosetta run configure --workspace << parameters.workspace >>
139-
name: Configure
138+
command: rosetta run format --workspace << parameters.workspace >>
139+
name: Format
140140
no_output_timeout: 180m
141141
- store_artifacts:
142142
path: /workflows/artifacts
@@ -146,7 +146,7 @@ jobs:
146146
no_output_timeout: 10m
147147
when: always
148148
working_directory: /mnt/ephemeral/workdir
149-
aw-format:
149+
aw-gazelle:
150150
environment:
151151
ASPECT_WORKFLOWS_CIRCLE_PIPELINE_NUMBER: << pipeline.number >>
152152
ASPECT_WORKFLOWS_CIRCLE_PIPELINE_PROJECT_TYPE: << pipeline.project.type >>
@@ -179,8 +179,8 @@ jobs:
179179
name: Checkout health
180180
no_output_timeout: 180m
181181
- run:
182-
command: rosetta run format --workspace << parameters.workspace >>
183-
name: Format
182+
command: rosetta run gazelle --workspace << parameters.workspace >>
183+
name: Gazelle
184184
no_output_timeout: 180m
185185
- store_artifacts:
186186
path: /workflows/artifacts

.pre-commit-config.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@
66
# See https://pre-commit.com for more information
77
# See https://pre-commit.com/hooks.html for more hooks
88
repos:
9-
- repo: local
10-
hooks:
11-
- id: format
12-
name: Format
13-
entry: bazel run //tools/format:format
14-
language: system
15-
types: [text]
169
# Lint for starlark code.
1710
# Special case since rules_lint doesn't want to require that BUILD files are
1811
# listed as the srcs of some *_library target.

BUILD.bazel

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,54 @@
1-
# A top-level build file most often contains tooling and convenience aliases.
21
load("@aspect_rules_js//js:defs.bzl", "js_library")
2+
load("@gazelle//:def.bzl", "gazelle")
33
load("@npm//:defs.bzl", "npm_link_all_packages")
44

5+
package(default_visibility = ["//:__subpackages__"])
6+
7+
# gazelle:prefix github.com/aspect-build/bazel-examples
8+
59
# JS BUILD generation is opt-in per project
6-
# aspect:js disabled
10+
# gazelle:js disabled
711

812
# Global config shared across monorepo.
9-
# aspect:js_npm_package_target_name pkg
10-
# aspect:js_package_rule_kind js_library
11-
# aspect:js_project_naming_convention tsc
13+
# gazelle:js_npm_package_target_name pkg
14+
# gazelle:js_package_rule_kind js_library
15+
# gazelle:js_project_naming_convention tsc
1216

1317
# TODO(alex): refactor this folder to follow python gazelle conventions
1418
# gazelle:exclude py_mypy
15-
package(default_visibility = ["//:__subpackages__"])
16-
17-
npm_link_all_packages(name = "node_modules")
19+
gazelle(
20+
name = "gazelle",
21+
env = {
22+
"ORION_EXTENSIONS_DIR": ".aspect/cli",
23+
"ENABLE_LANGUAGES": ",".join([
24+
"js",
25+
"go",
26+
"proto",
27+
"python",
28+
]),
29+
},
30+
extra_args = ["-index=lazy"],
31+
gazelle = "@multitool//tools/gazelle",
32+
)
1833

19-
alias(
20-
name = "format",
21-
actual = "//tools/format",
34+
gazelle(
35+
name = "gazelle.check",
36+
env = {
37+
"ORION_EXTENSIONS_DIR": ".aspect/cli",
38+
"ENABLE_LANGUAGES": ",".join([
39+
"js",
40+
"go",
41+
"proto",
42+
"python",
43+
]),
44+
},
45+
extra_args = ["-index=lazy"],
46+
gazelle = "@multitool//tools/gazelle",
47+
mode = "diff",
2248
)
2349

50+
npm_link_all_packages(name = "node_modules")
51+
2452
exports_files(
2553
[
2654
".clang-tidy",
@@ -42,3 +70,9 @@ js_library(
4270
":node_modules/typescript-eslint",
4371
],
4472
)
73+
74+
alias(
75+
name = "format",
76+
actual = "//tools/format:format",
77+
visibility = ["//visibility:public"],
78+
)

README.bazel.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ This repository uses Bazel to provide a monorepo developer experience.
44

55
## Formatting code
66

7-
- Run `bazel run format` to re-format all files locally.
8-
- Run `bazel run format path/to/file` to re-format a single file.
7+
- Run `bazel run //tools/format` to re-format all files locally.
8+
- Run `bazel run //tools/format path/to/file` to re-format a single file.
99
- Run `pre-commit install` to auto-format changed files on `git commit`; see https://pre-commit.com/.
1010

1111
## Linting code

0 commit comments

Comments
 (0)