forked from rabbitmq/rabbitmq-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BUILD.bazel
271 lines (242 loc) · 6.17 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
261
262
263
264
265
266
267
268
269
270
271
load(
"@bazel_skylib//rules:common_settings.bzl",
"string_flag",
)
load("@rules_pkg//:pkg.bzl", "pkg_tar")
load("@rules_erlang//:dialyze.bzl", "plt")
load("@rules_erlang//:shell.bzl", "shell")
load("@rules_erlang//:erl_eval.bzl", "erl_eval")
load("//bazel/elixir:iex_eval.bzl", "iex_eval")
load(":rabbitmq_home.bzl", "rabbitmq_home")
load(":rabbitmq_run.bzl", "rabbitmq_run", "rabbitmq_run_command")
load(":rabbitmqctl.bzl", "rabbitmqctl")
load(":dist.bzl", "package_generic_unix", "source_archive")
load(":rabbitmq.bzl", "all_plugins")
exports_files([
"scripts/bazel/rabbitmq-run.sh",
"scripts/bazel/rabbitmq-run.bat",
"release-notes",
])
config_setting(
name = "debug_build",
values = {
"compilation_mode": "dbg",
},
)
string_flag(
name = "elixir_home",
build_setting_default = "",
visibility = ["//visibility:public"],
)
plt(
name = "base_plt",
visibility = ["//visibility:public"],
)
PLUGINS = all_plugins(
rabbitmq_workspace = "",
)
rabbitmq_home(
name = "broker-home",
plugins = PLUGINS,
)
rabbitmq_run(
name = "rabbitmq-run",
home = ":broker-home",
visibility = ["//visibility:public"],
)
# Allow us to `bazel run broker`
# for the equivalent of `make run-broker`
rabbitmq_run_command(
name = "broker",
rabbitmq_run = ":rabbitmq-run",
subcommand = "run-broker",
)
# Allow us to `bazel run start-cluster`
# for the equivalent of `make start-cluster`
rabbitmq_run_command(
name = "start-cluster",
rabbitmq_run = ":rabbitmq-run",
subcommand = "start-cluster",
)
# Allow us to `bazel run stop-cluster`
# for the equivalent of `make stop-cluster`
rabbitmq_run_command(
name = "stop-cluster",
rabbitmq_run = ":rabbitmq-run",
subcommand = "stop-cluster",
)
# `bazel run rabbitmqctl`
rabbitmqctl(
name = "rabbitmqctl",
home = ":broker-home",
visibility = ["//visibility:public"],
)
rabbitmqctl(
name = "rabbitmq-diagnostics",
home = ":broker-home",
)
rabbitmqctl(
name = "rabbitmq-plugins",
home = ":broker-home",
)
shell(
name = "repl",
deps = PLUGINS,
)
erl_eval(
name = "otp_version",
outs = ["otp_version.txt"],
expression = """{ok, Version} = file:read_file(filename:join([code:root_dir(), "releases", erlang:system_info(otp_release), "OTP_VERSION"])), file:write_file(os:getenv("OUTS"), Version), halt().""",
)
iex_eval(
name = "elixir_version",
outs = ["elixir_version.txt"],
expression = """File.write!(System.get_env("OUTS"), System.version()); System.halt()""",
)
filegroup(
name = "root-licenses",
srcs = glob(
["LICENSE*"],
exclude = [
"LICENSE.md",
"LICENSE.txt",
],
),
visibility = ["//visibility:public"],
)
pkg_tar(
name = "scripts-tar",
srcs = [
"scripts/bash_autocomplete.sh",
"scripts/rabbitmq-script-wrapper",
"scripts/rabbitmqctl-autocomplete.sh",
"scripts/zsh_autocomplete.sh",
],
package_dir = "scripts",
visibility = ["//visibility:public"],
)
pkg_tar(
name = "release-notes-tar",
srcs = glob([
"release-notes/*.md",
"release-notes/*.txt",
]),
package_dir = "release-notes",
visibility = ["//visibility:public"],
)
package_generic_unix(plugins = PLUGINS)
source_archive(plugins = PLUGINS)
genrule(
name = "test-logs",
outs = ["open-test-logs.sh"],
cmd = """set -euo pipefail
cat << 'EOF' > $@
#!/bin/bash
set -euo pipefail
if [ $$# -eq 0 ]; then
echo "Usage: bazel run test-logs TEST_LABEL [shard_index]"
exit 1
fi
RELATIVE=$${1#//}
PACKAGE=$${RELATIVE%%:*}
SUITE=$${RELATIVE##*:}
OUTPUT_DIR=test.outputs
if [ $$# -gt 1 ]; then
OUTPUT_DIR=shard_$$2_of_*/test.outputs
fi
cd "bazel-testlogs/$$PACKAGE/$$SUITE/$$OUTPUT_DIR"
if [ -f outputs.zip ]; then
unzip -u outputs.zip
fi
set +e
open index.html
rc=$$?
set -e
if [[ $$rc -eq 3 ]]; then
# For xdg-open exit code 3 means "A required tool could not be found." That is, there is no browser.
echo "Open your browser at http://$$(hostname -s):8000/index.html"
python -m http.server 8000
fi
EOF
""",
executable = True,
)
genrule(
name = "remote-test-logs",
outs = ["open-remote-test-logs.sh"],
cmd = """set -euo pipefail
cat << 'EOF' > $@
#!/bin/bash
set -euo pipefail
if [ $$# -eq 0 ]; then
echo "Usage: bazel run remote-test-logs TEST_LABEL [shard_index]"
exit 1
fi
RELATIVE=$${1#//}
PACKAGE=$${RELATIVE%%:*}
SUITE=$${RELATIVE##*:}
OUTPUT_DIR=test.outputs
if [ $$# -gt 1 ]; then
OUTPUT_DIR=shard_$$2_of_*/test.outputs
fi
TESTLOGS=$$(echo $$(bazel info output_path)/k8-*/testlogs)
cd "$$TESTLOGS/$$PACKAGE/$$SUITE/$$OUTPUT_DIR" && unzip -u outputs.zip
open index.html
EOF
""",
executable = True,
)
genrule(
name = "test-node-data",
outs = ["open-test-node-data.sh"],
cmd = """set -euo pipefail
cat << 'EOF' > $@
set -euo pipefail
if [ $$# -eq 0 ]; then
echo "Usage: bazel run test-node-data TEST_LABEL [shard_index]"
exit 1
fi
RELATIVE=$${1#//}
PACKAGE=$${RELATIVE%%:*}
SUITE=$${RELATIVE##*:}
OUTPUT_DIR=test.outputs
if [ $$# -gt 1 ]; then
OUTPUT_DIR=shard_$$2_of_*/test.outputs
fi
cd bazel-testlogs/$$PACKAGE/$$SUITE/$$OUTPUT_DIR
if [ -f outputs.zip ]; then
unzip -u outputs.zip
fi
open index.html
open ct_run.*/deps.*/run.*/log_private
EOF
""",
executable = True,
)
# NOTE: this rule may not work properly if --remote_download_minimal has been used,
# which is currently the default for remote runs
genrule(
name = "remote-test-node-data",
outs = ["open-remote-test-node-data.sh"],
cmd = """set -euo pipefail
cat << 'EOF' > $@
set -euo pipefail
if [ $$# -eq 0 ]; then
echo "Usage: bazel run remote-test-node-data TEST_LABEL [shard_index]"
exit 1
fi
RELATIVE=$${1#//}
PACKAGE=$${RELATIVE%%:*}
SUITE=$${RELATIVE##*:}
OUTPUT_DIR=test.outputs
if [ $$# -gt 1 ]; then
OUTPUT_DIR=shard_$$2_of_*/test.outputs
fi
TESTLOGS=$$(echo $$(bazel info output_path)/k8-*/testlogs)
cd $$TESTLOGS/$$PACKAGE/$$SUITE/$$OUTPUT_DIR && unzip -u outputs.zip
open index.html
open ct_run.*/deps.*/run.*/log_private
EOF
""",
executable = True,
)