-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMODULE.bazel
148 lines (125 loc) · 4.94 KB
/
MODULE.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
module(name = "${project}")
########################################
# Setings
########################################
PY_VERSION = "3.11.6"
GO_VERSION = "1.22.0"
########################################
# Generic deps
########################################
bazel_dep(name = "aspect_bazel_lib", version = "2.5.1")
bazel_dep(name = "platforms", version = "0.0.8")
########################################
# Set up rules_python and pip
########################################
bazel_dep(name = "rules_python", version = "0.31.0")
bazel_dep(name = "aspect_rules_py", version = "0.7.1")
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
is_default = True,
python_version = PY_VERSION,
)
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
pip.parse(
hub_name = "pip",
python_version = PY_VERSION,
requirements_lock = "//:requirements_lock.txt",
)
use_repo(pip, "pip")
########################################
# Set up rules_go
########################################
bazel_dep(name = "rules_go", version = "0.46.0")
bazel_dep(name = "gazelle", version = "0.35.0")
go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
go_sdk.download(version = GO_VERSION)
go_sdk.nogo(nogo = "//:nogo")
go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")
use_repo(
go_deps,
"com_github_stretchr_testify",
)
########################################
# Set up hermetic Buildifier tools
########################################
# This is helpful because the old version used an http_archive to fetch the buildtools
# WORKSPACE, but it is incompatible with bzlmod Go toolchains. Instead let's just use
# a prebuilt version.
bazel_dep(
name = "buildifier_prebuilt",
version = "6.4.0",
dev_dependency = True,
)
########################################
# Set up rules_pkg
########################################
bazel_dep(name = "rules_pkg", version = "0.10.1")
########################################
# Set up hermetic C/C++ tools
########################################
# NOTE: We don't really use/support C/C++ in this repo, and if you need to you'll
# almost certainly want your own proper toolchains to do so, but rules_oci requires
# CC toolchains to be registered for packaging python interpreters, so we will cheat a
# little using zig/hermetic_cc_toolchain to provide cross-compilation toolchains for
# packaging OCI images.
bazel_dep(name = "hermetic_cc_toolchain", version = "3.0.1")
toolchains = use_extension("@hermetic_cc_toolchain//toolchain:ext.bzl", "toolchains")
use_repo(toolchains, "zig_sdk")
register_toolchains(
"@zig_sdk//toolchain:linux_amd64_gnu.2.31",
"@zig_sdk//toolchain:linux_arm64_gnu.2.31",
)
########################################
# Set up rules_oci
########################################
bazel_dep(name = "rules_oci", version = "1.7.4")
oci = use_extension("@rules_oci//oci:extensions.bzl", "oci")
oci.pull(
name = "distroless_base",
# 'latest' is not reproducible, but it's convenient.
# During the build we print a WARNING message that includes recommended 'digest' and 'platforms'
# values which you can use here in place of 'tag' to pin for reproducibility.
# tag = "latest",
digest = "sha256:9d4e5680d67c984ac9c957f66405de25634012e2d5d6dc396c4bdd2ba6ae569f",
image = "gcr.io/distroless/base",
platforms = [
"linux/amd64",
"linux/arm64/v8",
],
)
oci.pull(
name = "ubuntu_base",
# tag = "24.04",
digest = "sha256:723ad8033f109978f8c7e6421ee684efb624eb5b9251b70c6788fdb2405d050b",
image = "ubuntu",
platforms = [
"linux/amd64",
"linux/arm64/v8",
],
)
# For each oci.pull call, repeat the "name" here to expose them as dependencies.
use_repo(oci, "distroless_base", "ubuntu_base")
########################################
# Set up rules_js
########################################
# NOTE: We don't really use/support JS in this repo, and if you need to you'll
# have some more config to do, but we register rules_js here so we can use it to
# pull a few javascript packages used for repo tooling, like prettier for linting.
bazel_dep(name = "aspect_rules_js", version = "1.38.0")
####### OPTIONAL: Customize Node.js version #########
# By default you get the node version from DEFAULT_NODE_VERSION in @rules_nodejs//nodejs:repositories.bzl
# Optionally you can pin a different node version:
# bazel_dep(name = "rules_nodejs", version = "5.8.2")
# node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node")
# node.toolchain(node_version = "16.14.2")
#################################
npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm", dev_dependency = True)
pnpm = use_extension("@aspect_rules_js//npm:extensions.bzl", "pnpm", dev_dependency = True)
npm.npm_translate_lock(
name = "npm",
pnpm_lock = "//:pnpm-lock.yaml",
verify_node_modules_ignored = "//:.bazelignore",
)
use_repo(npm, "npm")
use_repo(pnpm, "pnpm")