Skip to content

Commit

Permalink
refactor: target tests more specifically in Tiltfile (#3615)
Browse files Browse the repository at this point in the history
* refactor: target tests more specifically in Tiltfile

With auto_init, all other resources are brought up in addition to the
targeted tests. With 'enabled_resources' only the tests and their
dependency resources are brought up.

This is required to run the 'core' test suite for example, since that
suite finishes long before the rest of server resources come up.

* refactor: unroll python array composition
  • Loading branch information
vindard authored Nov 28, 2023
1 parent 5f084ea commit b1fd44c
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions dev/Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@ config.define_string_list("test")
config.define_bool("bats")
cfg = config.parse()

CORE_TEST_LABEL = "core"
CONSENT_TEST_LABEL = "consent"
DASHBOARD_TEST_LABEL = "dashboard"

TEST_RESOURCES = {
CORE_TEST_LABEL: "api-test",
CONSENT_TEST_LABEL: "consent-test",
DASHBOARD_TEST_LABEL: "dashboard-test",
}

is_ci=("ci" in sys.argv) or cfg.get("bats", False)

# From the Tilt docs:
Expand Down Expand Up @@ -75,7 +85,7 @@ consent_test_target = "//apps/consent:test-integration"
local_resource(
"consent-test",
labels = ["test"],
auto_init = is_ci and "consent" in cfg.get("test", []),
auto_init = is_ci and CONSENT_TEST_LABEL in cfg.get("test", []),
cmd = "buck2 test {}".format(consent_test_target),
allow_parallel = True,
resource_deps = [
Expand All @@ -89,7 +99,7 @@ dashboard_test_target = "//apps/dashboard:test-integration"
local_resource(
"dashboard-test",
labels = ["test"],
auto_init = is_ci and "dashboard" in cfg.get("test", []),
auto_init = is_ci and DASHBOARD_TEST_LABEL in cfg.get("test", []),
cmd = "buck2 test {}".format(dashboard_test_target),
resource_deps = [
"consent",
Expand Down Expand Up @@ -340,7 +350,16 @@ to_run = cfg.get("to-run", [])
if to_run != []:
enabled_resources = []
for svc in to_run:
enabled_resources.append(svc)
enabled_resources.append(svc)
config.set_enabled_resources(enabled_resources)

to_test = cfg.get("test", [])
if to_test != []:
enabled_resources = []
for label in to_test:
svc = TEST_RESOURCES.get(label)
if svc:
enabled_resources.append(svc)
config.set_enabled_resources(enabled_resources)

docker_compose("./docker-compose.deps.yml", project_name = "galoy-dev")
Expand All @@ -362,7 +381,7 @@ api_test_target = "//core/api:test-integration"
local_resource(
"api-test",
labels = ["test"],
auto_init = is_ci and "core" in cfg.get("test", []),
auto_init = is_ci and CORE_TEST_LABEL in cfg.get("test", []),
cmd = "buck2 test {}".format(api_test_target),
resource_deps = [res for sublist in docker_groups.values() for res in sublist],
)

0 comments on commit b1fd44c

Please sign in to comment.