From b30b62c17f9933aef7e58820d7bad672abb40108 Mon Sep 17 00:00:00 2001 From: Charles Guo Date: Tue, 30 Jul 2024 20:05:01 -0400 Subject: [PATCH] Package API rules --- ark_nova_stats/api/BUILD.bazel | 2 +- ark_nova_stats/api/migrations/BUILD.bazel | 2 +- fitbit_challenges/api/BUILD.bazel | 2 +- fitbit_challenges/api/migrations/BUILD.bazel | 2 +- home_api/api/BUILD.bazel | 2 +- home_api/api/migrations/BUILD.bazel | 2 +- mc_manager/api/BUILD.bazel | 2 +- mc_manager/api/migrations/BUILD.bazel | 2 +- proto_registry/api/BUILD.bazel | 2 +- proto_registry/api/migrations/BUILD.bazel | 2 +- skeleton/api/BUILD.bazel | 2 +- skeleton/api/migrations/BUILD.bazel | 2 +- tools/build_rules/api/BUILD.bazel | 3 +++ tools/build_rules/{ => api}/api_image.bzl | 2 +- tools/build_rules/api/defs.bzl | 11 +++++++++++ tools/build_rules/{ => api}/main_py.bzl | 0 tools/build_rules/{ => api}/templates/__main__.py.tpl | 0 17 files changed, 27 insertions(+), 13 deletions(-) rename tools/build_rules/{ => api}/api_image.bzl (98%) rename tools/build_rules/{ => api}/main_py.bzl (100%) rename tools/build_rules/{ => api}/templates/__main__.py.tpl (100%) diff --git a/ark_nova_stats/api/BUILD.bazel b/ark_nova_stats/api/BUILD.bazel index 1822d611..674d019f 100644 --- a/ark_nova_stats/api/BUILD.bazel +++ b/ark_nova_stats/api/BUILD.bazel @@ -1,5 +1,5 @@ load("@rules_python//python:defs.bzl", "py_library") -load("//tools/build_rules:api_image.bzl", "api_image") +load("//tools/build_rules/api:defs.bzl", "api_image") py_library( name = "app", diff --git a/ark_nova_stats/api/migrations/BUILD.bazel b/ark_nova_stats/api/migrations/BUILD.bazel index 98adb77d..ad4ccc90 100644 --- a/ark_nova_stats/api/migrations/BUILD.bazel +++ b/ark_nova_stats/api/migrations/BUILD.bazel @@ -1,4 +1,4 @@ -load("//tools/build_rules/api/migrations:defs.bzl", "migrations") +load("//tools/build_rules/api:defs.bzl", migrations = "api_migrations") migrations( app_config = "//ark_nova_stats:config_py", diff --git a/fitbit_challenges/api/BUILD.bazel b/fitbit_challenges/api/BUILD.bazel index 3785a58b..0fbd1df9 100644 --- a/fitbit_challenges/api/BUILD.bazel +++ b/fitbit_challenges/api/BUILD.bazel @@ -1,6 +1,6 @@ load("@py_deps//:requirements.bzl", "requirement") load("@rules_python//python:defs.bzl", "py_library") -load("//tools/build_rules:api_image.bzl", "api_image") +load("//tools/build_rules/api:defs.bzl", "api_image") py_library( name = "api_lib", diff --git a/fitbit_challenges/api/migrations/BUILD.bazel b/fitbit_challenges/api/migrations/BUILD.bazel index 6663ea51..66943bc9 100644 --- a/fitbit_challenges/api/migrations/BUILD.bazel +++ b/fitbit_challenges/api/migrations/BUILD.bazel @@ -1,4 +1,4 @@ -load("//tools/build_rules/api/migrations:defs.bzl", "migrations") +load("//tools/build_rules/api:defs.bzl", migrations = "api_migrations") migrations( app_config = "//fitbit_challenges:config_py", diff --git a/home_api/api/BUILD.bazel b/home_api/api/BUILD.bazel index e4dc7b62..68f08d36 100644 --- a/home_api/api/BUILD.bazel +++ b/home_api/api/BUILD.bazel @@ -1,6 +1,6 @@ load("@py_deps//:requirements.bzl", "requirement") load("@rules_python//python:defs.bzl", "py_library") -load("//tools/build_rules:api_image.bzl", "api_image") +load("//tools/build_rules/api:defs.bzl", "api_image") py_library( name = "api_lib", diff --git a/home_api/api/migrations/BUILD.bazel b/home_api/api/migrations/BUILD.bazel index 90ae1f98..43449d4b 100644 --- a/home_api/api/migrations/BUILD.bazel +++ b/home_api/api/migrations/BUILD.bazel @@ -1,4 +1,4 @@ -load("//tools/build_rules/api/migrations:defs.bzl", "migrations") +load("//tools/build_rules/api:defs.bzl", migrations = "api_migrations") migrations( app_config = "//home_api:config_py", diff --git a/mc_manager/api/BUILD.bazel b/mc_manager/api/BUILD.bazel index 2c7a24f7..46fc4399 100644 --- a/mc_manager/api/BUILD.bazel +++ b/mc_manager/api/BUILD.bazel @@ -1,5 +1,5 @@ load("@py_deps//:requirements.bzl", "requirement") -load("//tools/build_rules:api_image.bzl", "api_image") +load("//tools/build_rules/api:defs.bzl", "api_image") py_library( name = "api_lib", diff --git a/mc_manager/api/migrations/BUILD.bazel b/mc_manager/api/migrations/BUILD.bazel index 0cc41e75..0562bebe 100644 --- a/mc_manager/api/migrations/BUILD.bazel +++ b/mc_manager/api/migrations/BUILD.bazel @@ -1,4 +1,4 @@ -load("//tools/build_rules/api/migrations:defs.bzl", "migrations") +load("//tools/build_rules/api:defs.bzl", migrations = "api_migrations") migrations( app_config = "//mc_manager:config_py", diff --git a/proto_registry/api/BUILD.bazel b/proto_registry/api/BUILD.bazel index 680efd86..969c97ca 100644 --- a/proto_registry/api/BUILD.bazel +++ b/proto_registry/api/BUILD.bazel @@ -1,6 +1,6 @@ load("@py_deps//:requirements.bzl", "requirement") load("@rules_python//python:defs.bzl", "py_library") -load("//tools/build_rules:api_image.bzl", "api_image") +load("//tools/build_rules/api:defs.bzl", "api_image") py_library( name = "api_lib", diff --git a/proto_registry/api/migrations/BUILD.bazel b/proto_registry/api/migrations/BUILD.bazel index b92d968e..67e84356 100644 --- a/proto_registry/api/migrations/BUILD.bazel +++ b/proto_registry/api/migrations/BUILD.bazel @@ -1,4 +1,4 @@ -load("//tools/build_rules/api/migrations:defs.bzl", "migrations") +load("//tools/build_rules/api:defs.bzl", migrations = "api_migrations") migrations( app_config = "//proto_registry:config_py", diff --git a/skeleton/api/BUILD.bazel b/skeleton/api/BUILD.bazel index 2f69f3e1..df6c56e5 100644 --- a/skeleton/api/BUILD.bazel +++ b/skeleton/api/BUILD.bazel @@ -1,5 +1,5 @@ load("@rules_python//python:defs.bzl", "py_library") -load("//tools/build_rules:api_image.bzl", "api_image") +load("//tools/build_rules/api:defs.bzl", "api_image") py_library( name = "app", diff --git a/skeleton/api/migrations/BUILD.bazel b/skeleton/api/migrations/BUILD.bazel index 22711f6d..5b4a3ffa 100644 --- a/skeleton/api/migrations/BUILD.bazel +++ b/skeleton/api/migrations/BUILD.bazel @@ -1,4 +1,4 @@ -load("//tools/build_rules/api/migrations:defs.bzl", "migrations") +load("//tools/build_rules/api:defs.bzl", migrations = "api_migrations") migrations( app_config = "//skeleton:config_py", diff --git a/tools/build_rules/api/BUILD.bazel b/tools/build_rules/api/BUILD.bazel index e69de29b..8a72905f 100644 --- a/tools/build_rules/api/BUILD.bazel +++ b/tools/build_rules/api/BUILD.bazel @@ -0,0 +1,3 @@ +exports_files([ + "templates/__main__.py.tpl", +]) diff --git a/tools/build_rules/api_image.bzl b/tools/build_rules/api/api_image.bzl similarity index 98% rename from tools/build_rules/api_image.bzl rename to tools/build_rules/api/api_image.bzl index 8e4dcebe..d90b3ce1 100644 --- a/tools/build_rules/api_image.bzl +++ b/tools/build_rules/api/api_image.bzl @@ -6,8 +6,8 @@ A macro used to define an API container image. load("@rules_python//python:defs.bzl", "py_binary") load("//tools/build_rules:cross_platform_image.bzl", "cross_platform_image") -load("//tools/build_rules:main_py.bzl", "main_py") load("//tools/build_rules:py_layer.bzl", "py_oci_image") +load("//tools/build_rules/api:main_py.bzl", "main_py") def api_image( name, diff --git a/tools/build_rules/api/defs.bzl b/tools/build_rules/api/defs.bzl index e69de29b..995ae167 100644 --- a/tools/build_rules/api/defs.bzl +++ b/tools/build_rules/api/defs.bzl @@ -0,0 +1,11 @@ +""" +defs.bzl: public interfaces for API rules. + +You should import rules exposed here. +""" + +load("//tools/build_rules/api:api_image.bzl", _api_image = "api_image") +load("//tools/build_rules/api/migrations:defs.bzl", _api_migrations = "migrations") + +api_image = _api_image +api_migrations = _api_migrations diff --git a/tools/build_rules/main_py.bzl b/tools/build_rules/api/main_py.bzl similarity index 100% rename from tools/build_rules/main_py.bzl rename to tools/build_rules/api/main_py.bzl diff --git a/tools/build_rules/templates/__main__.py.tpl b/tools/build_rules/api/templates/__main__.py.tpl similarity index 100% rename from tools/build_rules/templates/__main__.py.tpl rename to tools/build_rules/api/templates/__main__.py.tpl