Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.1.0
8.5.1
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,11 @@ jobs:
python3 -m pip install -r requirements_dev.txt
sudo apt install cmake ninja-build graphviz
- name: Setup bazel (for lobster-gtest)
uses: jwlawson/actions-setup-bazel@v2
uses: bazel-contrib/setup-bazel@0.15.0
with:
bazel-version: '7.1.0'
bazelisk-cache: true
disk-cache: ${{ github.workflow }}
repository-cache: true
- name: Run integration tests
run: |
make integration-tests
Expand Down
3,569 changes: 291 additions & 3,278 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

Empty file added bazel/BUILD
Empty file.
Empty file added bazel/private/BUILD
Empty file.
47 changes: 47 additions & 0 deletions bazel/private/lobster_gtest.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
load("//bazel:providers.bzl", "LobsterProvider")

def _lobster_gtest_subrule_impl(ctx, tests, _lobster_gtest):
lobster_gtest_trace = ctx.actions.declare_file(ctx.label.name + ".lobster")

args = ctx.actions.args()
args.add_all(["--out", lobster_gtest_trace.path])
args.add(".")

ctx.actions.run(
executable = _lobster_gtest,
inputs = tests,
outputs = [lobster_gtest_trace],
arguments = [args],
progress_message = "lobster-gtest {}".format(lobster_gtest_trace.path),
)

return [
lobster_gtest_trace,
LobsterProvider(lobster_input = {lobster_gtest_trace.basename: lobster_gtest_trace.path}),
]

subrule_lobster_gtest = subrule(
implementation = _lobster_gtest_subrule_impl,
attrs = {
"_lobster_gtest": attr.label(
default = "//:lobster-gtest",
executable = True,
cfg = "exec",
),
},
)

def _lobster_gtest(ctx):
lobster_gtest_trace, lobster_provider = subrule_lobster_gtest(ctx.files.tests)
return [DefaultInfo(files = depset([lobster_gtest_trace])), lobster_provider]

lobster_gtest = rule(
implementation = _lobster_gtest,
attrs = {
"tests": attr.label_list(
allow_empty = False,
mandatory = True,
),
},
subrules = [subrule_lobster_gtest],
)
19 changes: 19 additions & 0 deletions bazel/private/lobster_raw.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
load("//bazel:providers.bzl", "LobsterProvider")

def _lobster_raw_impl(ctx):
name = "{}.lobster".format(ctx.attr.name)

return [
DefaultInfo(files = depset([ctx.file.src])),
LobsterProvider(lobster_input = {name: ctx.file.src.path}),
]

lobster_raw = rule(
implementation = _lobster_raw_impl,
attrs = {
"src": attr.label(
allow_single_file = [".lobster"],
mandatory = True,
),
},
)
113 changes: 113 additions & 0 deletions bazel/private/lobster_test.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
load("//bazel:providers.bzl", "LobsterProvider")

def _lobster_report_subrule_impl(ctx, inputs, lobster_config, _lobster_report):
lobster_report = ctx.actions.declare_file(ctx.label.name + "_report.json")

args = ctx.actions.args()
args.add_all(["--lobster-config", lobster_config.path])
args.add_all(["--out", lobster_report.path])

ctx.actions.run(
executable = _lobster_report,
inputs = depset(inputs + [lobster_config]),
outputs = [lobster_report],
arguments = [args],
progress_message = "lobster-report {}".format(lobster_report.path),
)

return lobster_report

subrule_lobster_report = subrule(
implementation = _lobster_report_subrule_impl,
attrs = {
"_lobster_report": attr.label(
default = "//:lobster-report",
executable = True,
cfg = "exec",
),
},
)

def _lobster_html_report_subrule_impl(ctx, lobster_report, _lobster_html_report):
lobster_html_report = ctx.actions.declare_file("{}_report.html".format(ctx.label.name))

args = ctx.actions.args()
args.add(lobster_report.path)
args.add_all(["--out", lobster_html_report.path])

ctx.actions.run(
executable = _lobster_html_report,
inputs = [lobster_report],
outputs = [lobster_html_report],
arguments = [args],
progress_message = "lobster-html-report {}".format(lobster_html_report.path),
)

return lobster_html_report

subrule_lobster_html_report = subrule(
implementation = _lobster_html_report_subrule_impl,
attrs = {
"_lobster_html_report": attr.label(
default = "//:lobster-html-report",
executable = True,
cfg = "exec",
),
},
)

def _lobster_test_impl(ctx):
lobster_config_substitutions = {}
for input_config in ctx.attr.inputs:
lobster_config_substitutions.update(input_config[LobsterProvider].lobster_input)

# We have to adjust the paths from the config, with the paths used by Bazel
lobster_config = ctx.actions.declare_file("{}_expanded_lobster.conf".format(ctx.attr.name))
ctx.actions.expand_template(
template = ctx.file.config,
output = lobster_config,
substitutions = lobster_config_substitutions,
)

lobster_report = subrule_lobster_report(ctx.files.inputs, lobster_config)
lobster_html_report = subrule_lobster_html_report(lobster_report)

test_executable = ctx.actions.declare_file("{}_lobster_ci_test_executable".format(ctx.attr.name))
command = "set -o pipefail; {} {}".format(ctx.executable._lobster_ci_report.short_path, lobster_report.short_path)

ctx.actions.write(
output = test_executable,
content = command,
)

return [DefaultInfo(
runfiles = ctx.runfiles(
files = [
ctx.executable._lobster_ci_report,
lobster_report,
],
).merge(ctx.attr._lobster_ci_report[DefaultInfo].default_runfiles),
files = depset([lobster_report, lobster_html_report]),
executable = test_executable,
)]

lobster_test = rule(
implementation = _lobster_test_impl,
attrs = {
"inputs": attr.label_list(
providers = [LobsterProvider],
mandatory = True,
),
"config": attr.label(
mandatory = True,
allow_single_file = True,
),
"_lobster_ci_report": attr.label(
default = "//:lobster-ci-report",
executable = True,
cfg = "exec",
),
},
test = True,
subrules = [subrule_lobster_report, subrule_lobster_html_report],
)
53 changes: 53 additions & 0 deletions bazel/private/lobster_trlc.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
load("@trlc//:trlc.bzl", "TrlcProviderInfo")
load("//bazel:providers.bzl", "LobsterProvider")

def _lobster_trlc_subrule_impl(ctx, requirements, config, _lobster_trlc):
lobster_trlc_trace = ctx.actions.declare_file(ctx.label.name + ".lobster")

args = ctx.actions.args()
args.add_all(["--config", config.path])
args.add_all(["--out", lobster_trlc_trace.path])

ctx.actions.run(
executable = _lobster_trlc,
inputs = requirements + [config],
outputs = [lobster_trlc_trace],
arguments = [args],
progress_message = "lobster-trlc {}".format(lobster_trlc_trace.path),
)

return [
lobster_trlc_trace,
LobsterProvider(lobster_input = {lobster_trlc_trace.basename: lobster_trlc_trace.path}),
]

subrule_lobster_trlc = subrule(
implementation = _lobster_trlc_subrule_impl,
attrs = {
"_lobster_trlc": attr.label(
default = "//:lobster-trlc",
executable = True,
cfg = "exec",
),
},
)

def _lobster_trlc_impl(ctx):
lobster_trlc_trace, lobster_provider = subrule_lobster_trlc(ctx.files.requirements, ctx.file.config)
return [DefaultInfo(files = depset([lobster_trlc_trace])), lobster_provider]

lobster_trlc = rule(
implementation = _lobster_trlc_impl,
attrs = {
"requirements": attr.label_list(
doc = "Targets that define requirements in the form of TRLC files.",
providers = [TrlcProviderInfo],
mandatory = True,
),
"config": attr.label(
allow_single_file = True,
mandatory = True,
),
},
subrules = [subrule_lobster_trlc],
)
5 changes: 5 additions & 0 deletions bazel/providers.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
LobsterProvider = provider(
fields = {
"lobster_input": "ABC",
},
)
Loading
Loading