Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
4.1 kB · 149 lines
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150load("@aspect_bazel_lib//lib:expand_template.bzl", "expand_template")load("@aspect_rules_py//py:defs.bzl", "py_binary", "py_library", "py_pytest_main")load("@rules_pyvenv//:venv.bzl", "py_venv")load("@uv_deps//:requirements.bzl", "all_requirements")expand_template( name = "protoc_betterproto_bin", out = "protoc_betterproto.py", is_executable = True, template = [ "from betterproto.plugin import main", "main()", ],)py_binary( name = "protoc_betterproto", srcs = [":protoc_betterproto_bin"], deps = ["@uv_deps//:betterproto"],)genrule( name = "lvmd_py_files", srcs = ["//:proto/lvmd.proto"], outs = [ "lvmd/__init__.py", "lvmd/py.typed", "lvmd/proto.py", ], cmd = """ mkdir -p $(RULEDIR)/lvmd $(execpath //:protoc) \ --plugin=protoc-gen-python_betterproto=$(execpath :protoc_betterproto) \ --python_betterproto_out=$(RULEDIR)/lvmd \ $(execpath //:proto/lvmd.proto) \ >/dev/null touch $(RULEDIR)/lvmd/py.typed """, tools = [ ":protoc_betterproto", "//:protoc", ],)py_library( name = "lvmd_py", srcs = [":lvmd_py_files"],)expand_template( name = "cloudcoil_model_codegen_bin", out = "cloudcoil_model_codegen.py", data = ["@uv_deps//:ruff"], is_executable = True, substitutions = { "{{RUFF}}": "$(rlocationpath @uv_deps//:ruff)", }, template = [ "import os", "ruff_bin = f'{os.environ['RUNFILES_DIR']}/{{RUFF}}/bin'", "os.environ['PATH'] = f'{ruff_bin}:{os.environ['PATH']}'", "from cloudcoil.codegen.generator import main", "main()", ],)py_binary( name = "cloudcoil_model_codegen", srcs = [":cloudcoil_model_codegen_bin"], deps = ["@uv_deps//:cloudcoil"],)genrule( name = "external_snapshotter_crds", srcs = ["@external_snapshotter//:snapshot_crds"], outs = ["external_snapshotter_crds.yaml"], cmd = "cat $(SRCS) > $@",)genrule( name = "cloudcoil_models_volumesnapshot_files", srcs = [":external_snapshotter_crds"], outs = [ "cloudcoil/__init__.py", "cloudcoil/models/volumesnapshot/__init__.py", "cloudcoil/models/volumesnapshot/py.typed", "cloudcoil/models/volumesnapshot/snapshot/__init__.py", "cloudcoil/models/volumesnapshot/snapshot/v1.py", ], cmd = r""" rm -rf $(RULEDIR)/cloudcoil mkdir -p $(RULEDIR)/cloudcoil $(execpath :cloudcoil_model_codegen) \ --namespace=cloudcoil.models.volumesnapshot \ --input=$(execpath :external_snapshotter_crds) \ --output=$(RULEDIR) \ --transformation='^io\.k8s\.apimachinery\..*\.(.+):apimachinery.\g<1>:cloudcoil' \ --transformation='^io\.k8s\.storage\.(.+)$$:\g<1>' \ >/dev/null # https://github.com/microsoft/pyright/issues/9439 touch $(RULEDIR)/cloudcoil/__init__.py """, tools = [":cloudcoil_model_codegen"],)py_library( name = "cloudcoil_models_volumesnapshot", srcs = [":cloudcoil_models_volumesnapshot_files"], imports = ["."],)py_pytest_main( name = "pytest_main", testonly = False,)GENERATED_DEPS = [ ":cloudcoil_models_volumesnapshot", ":lvmd_py",]filegroup( name = "generated", srcs = GENERATED_DEPS,)# Using py_binary over py_test makes sure that running with `bazel run` leaves# the TTY in place, allowing flags like `--pdb` to work.py_binary( name = "tests", srcs = glob(["**/*.py"]) + ["pytest_main.py"], data = ["vm/_state/kubeconfig.yaml"], main = "pytest_main.py", deps = GENERATED_DEPS + [ ":pytest_main", "@uv_deps//:betterproto", "@uv_deps//:cloudcoil", "@uv_deps//:dbus-fast", "@uv_deps//:grpclib", "@uv_deps//:pytest", "@uv_deps//:pytest-asyncio", ],)py_venv( name = "venv", venv_location = ".venv", deps = all_requirements[:],)