-
Notifications
You must be signed in to change notification settings - Fork 3
/
BUILD.bazel
260 lines (229 loc) · 7.15 KB
/
BUILD.bazel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# Add rules here to build your software
# See https://docs.bazel.build/versions/master/build-ref.html#BUILD_files
# Allow any ts_library rules in this workspace to reference the config
# Note: if you move the tsconfig.json file to a subdirectory, you can add an alias() here instead
# so that ts_library rules still use it by default.
# See https://www.npmjs.com/package/@bazel/typescript#installation
load("@aspect_rules_py//py:defs.bzl", "py_venv")
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
load("@bazel_skylib//rules:native_binary.bzl", "native_test")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@npm//:renovate/package_json.bzl", "bin")
load("@pip//:requirements.bzl", "all_whl_requirements")
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
load("@rules_python_gazelle_plugin//manifest:defs.bzl", "gazelle_python_manifest")
load("@rules_python_gazelle_plugin//modules_mapping:def.bzl", "modules_mapping")
load("//bzl:rules.bzl", "bazel_lint")
load("//js:rules.bzl", "copy_to_bin", "js_library")
load("//ts:rules.bzl", "ts_config")
package(default_visibility = [":__subpackages__"])
compile_pip_requirements(
name = "requirements",
src = "requirements.in",
requirements_txt = "requirements.txt",
)
# implement fix api
alias(
name = "requirements_test.fix",
actual = "requirements.update",
)
# Useful commands to run!
alias(
name = "fix",
actual = "//bzl/fix_api:fix_all",
)
alias(
name = "pnpm",
# bazel run -- //:pnpm --dir $PWD
actual = "@pnpm//:pnpm",
)
alias(
name = "buildifier",
actual = "@com_github_bazelbuild_buildtools//buildifier:buildifier",
)
ts_config(
name = "tsconfig",
src = "tsconfig.json",
deps = [],
)
js_library(
name = "base_defs",
srcs = ["Global.d.ts"],
)
exports_files(
[
"ruff.toml",
".prettierrc.json",
"package.json",
".gitignore",
".editorconfig",
"css_loader.d.ts",
".git",
"jsconfig.json",
],
visibility = ["//visibility:public"],
)
copy_to_bin(
name = "swcrc",
srcs = [".swcrc.json"],
visibility = ["//visibility:public"],
)
copy_to_bin(
name = "prettierrc",
srcs = [".prettierrc.json"],
)
copy_to_bin(
name = "gitignore",
srcs = [".gitignore"],
)
copy_to_bin(
name = "editorconfig",
srcs = [".editorconfig"],
)
copy_to_bin(
name = "package_json",
srcs = ["package.json"],
)
bin.renovate_config_validator_test(
name = "validate_renovate_config_test",
args = ["$(location renovate.json)"],
data = ["renovate.json"],
)
npm_link_all_packages(name = "node_modules")
native_test(
name = "go_versions_synced",
size = "small",
src = "//go/cmd/version_sync",
out = "version_sync_test.o",
data = [
"MODULE.bazel",
"go.mod",
],
)
sh_binary(
name = "go_versions_synced.fix",
srcs = ["fix_go_version_sync.sh"],
data = [
"//go/cmd/version_sync",
],
env = {
"VERSION_SYNC": "$(rlocationpath //go/cmd/version_sync)",
},
deps = [
"@bazel_tools//tools/bash/runfiles",
],
)
js_library(
name = "eslintrc",
srcs = [
":eslint.config.js",
"//:.gitignore",
"//:editorconfig",
"//:package_json",
"//:prettierrc",
"//:tsconfig",
],
deps = [
"//:node_modules/@eslint/compat",
"//:node_modules/@eslint/js",
"//:node_modules/@next/eslint-plugin-next",
"//:node_modules/eslint-mdx",
"//:node_modules/eslint-plugin-jest",
"//:node_modules/eslint-plugin-mdx",
"//:node_modules/eslint-plugin-react",
"//:node_modules/eslint-plugin-react-hooks",
"//:node_modules/eslint-plugin-simple-import-sort",
"//:node_modules/typescript-eslint",
],
)
# This rule fetches the metadata for python packages we depend on. That data is
# required for the gazelle_python_manifest rule to update our manifest file.
modules_mapping(
name = "modules_map",
wheels = all_whl_requirements,
)
# gazelle:resolve py google.protobuf @com_google_protobuf//:protobuf_python
# gazelle:resolve py python.runfiles @rules_python//python/runfiles
# gazelle:map_kind py_binary py_binary //py:rules.bzl
# gazelle:map_kind py_library py_library //py:rules.bzl
# gazelle:map_kind py_test py_test //py:rules.bzl
# Gazelle python extension needs a manifest file mapping from
# an import to the installed package that provides it.
# This macro produces two targets:
# - //:gazelle_python_manifest.update can be used with `bazel run`
# to recalculate the manifest
# - //:gazelle_python_manifest.test is a test target ensuring that
# the manifest doesn't need to be updated
gazelle_python_manifest(
name = "gazelle_python_manifest",
modules_mapping = ":modules_map",
# This is what we called our `pip_parse` rule, where third-party
# python libraries are loaded in BUILD files.
pip_repository_name = "pip",
# This should point to wherever we declare our python dependencies
# (the same as what we passed to the modules_mapping rule in WORKSPACE)
# This argument is optional. If provided, the `.test` target is very
# fast because it just has to check an integrity field. If not provided,
# the integrity field is not added to the manifest which can help avoid
# merge conflicts in large repos.
requirements = "//:requirements.txt",
)
# this alias allows the gazelle python manifest fixer to conform to
# the fix api (bzl/fix_api).
alias(
name = "gazelle_python_manifest.test.fix",
actual = "gazelle_python_manifest.update",
)
gazelle_binary(
name = "gazelle_bin",
languages = [
"@rules_python_gazelle_plugin//python",
"@bazel_gazelle//language/go", # Built-in rule from gazelle for Golang.
"@bazel_gazelle//language/proto", # Built-in rule from gazelle for Protos.
"//go/gazelle/bazel",
"//go/gazelle/ts/config",
"//go/gazelle/js",
"//go/gazelle/venv",
# Any languages that depend on Gazelle's proto plugin must come after it.
],
visibility = ["//visibility:public"],
)
# gazelle:prefix github.com/zemn-me/monorepo
# gazelle:map_kind go_binary go_binary //go:rules.bzl
# gazelle:map_kind go_library go_library //go:rules.bzl
# gazelle:map_kind ts_project ts_project //ts:rules.bzl
# gazelle:resolve proto go google/protobuf/struct.proto @com_github_golang_protobuf//ptypes/struct:struct
gazelle(
name = "gazelle",
command = "fix",
gazelle = ":gazelle_bin",
)
bazel_lint(
name = "bazel_lint",
srcs = [
"BUILD.bazel",
"MODULE.bazel",
],
)
# gazelle:python_default_visibility //:__subpackages__
# gazelle:exclude .venv
py_venv(
name = "venv",
deps = [
"//.vscode/prep:prep_bin",
"//bzl/versioning",
"//ini/git/merge_drivers/bazel_lockfile",
"//project/cultist/gen/testing",
"//py/ci/postUpgrade:postUpgrade_bin",
"//py/hello_world:hello_world_bin",
"//py/ibazel:ibazel_bin",
"//py/ipynb",
"//py/ipynb:ipynb_bin",
"//ts/pulumi/lib/oci/example/python:python_bin",
],
)
# gazelle:exclude third_party
alias(
name = "go",
actual = "//sh/bin:go",
)