Skip to content

Commit 57454c3

Browse files
committed
Fix building mz-debug in the background
This reverts commit f53418b.
1 parent 8278ea1 commit 57454c3

File tree

2 files changed

+44
-4
lines changed

2 files changed

+44
-4
lines changed

ci/plugins/mzcompose/hooks/pre-exit

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,13 @@ ci_collapsed_heading ":docker: Purging all existing docker containers and volume
149149
docker ps --all --quiet | xargs --no-run-if-empty docker rm --force --volumes
150150

151151
if [ "$BUILDKITE_STEP_KEY" = "terraform-aws" ]; then
152-
run run aws-temporary --no-setup --no-test --no-mz-debug || true
152+
run run aws-temporary --no-setup --no-test --no-run-mz-debug || true
153153
elif [ "$BUILDKITE_STEP_KEY" = "terraform-aws-upgrade" ]; then
154-
run run aws-upgrade --no-setup --no-test --no-mz-debug || true
154+
run run aws-upgrade --no-setup --no-test --no-run-mz-debug || true
155155
elif [ "$BUILDKITE_STEP_KEY" = "terraform-gcp" ]; then
156-
run run gcp-temporary --no-setup --no-test --no-mz-debug || true
156+
run run gcp-temporary --no-setup --no-test --no-run-mz-debug || true
157157
elif [ "$BUILDKITE_STEP_KEY" = "terraform-azure" ]; then
158-
run run azure-temporary --no-setup --no-test --no-mz-debug || true
158+
run run azure-temporary --no-setup --no-test --no-run-mz-debug || true
159159
fi
160160
rm -rf ~/.kube # Remove potential state from E2E Terraform tests
161161

test/terraform/mzcompose.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import os
1616
import signal
1717
import subprocess
18+
import threading
1819
import time
1920
from collections.abc import Sequence
2021
from pathlib import Path
@@ -142,6 +143,25 @@ def get_tag(tag: str | None) -> str:
142143
return tag or f"v{ci_util.get_mz_version()}--pr.g{git.rev_parse('HEAD')}"
143144

144145

146+
def build_mz_debug_async(env: dict[str, str] | None = None) -> threading.Thread:
147+
def run():
148+
spawn.capture(
149+
[
150+
"cargo",
151+
"build",
152+
"--bin",
153+
"mz-debug",
154+
],
155+
cwd=MZ_ROOT,
156+
stderr=subprocess.STDOUT,
157+
env=env,
158+
)
159+
160+
thread = threading.Thread(target=run)
161+
thread.start()
162+
return thread
163+
164+
145165
def run_mz_debug(env: dict[str, str] | None = None) -> None:
146166
print("--- Running mz-debug")
147167
try:
@@ -686,7 +706,10 @@ def workflow_aws_temporary(c: Composition, parser: WorkflowArgumentParser) -> No
686706
tag = get_tag(args.tag)
687707
path = MZ_ROOT / "test" / "terraform" / "aws-temporary"
688708
aws = AWS(path)
709+
mz_debug_build_thread: threading.Thread | None = None
689710
try:
711+
if args.run_mz_debug:
712+
mz_debug_build_thread = build_mz_debug_async()
690713
aws.setup("aws-test", args.setup, tag)
691714
if args.test:
692715
print("--- Running tests")
@@ -718,6 +741,8 @@ def workflow_aws_temporary(c: Composition, parser: WorkflowArgumentParser) -> No
718741
aws.cleanup()
719742

720743
if args.run_mz_debug:
744+
assert mz_debug_build_thread
745+
mz_debug_build_thread.join()
721746
run_mz_debug()
722747

723748
if args.cleanup:
@@ -775,7 +800,10 @@ def workflow_aws_upgrade(c: Composition, parser: WorkflowArgumentParser) -> None
775800
tag = get_tag(args.tag)
776801
path = MZ_ROOT / "test" / "terraform" / "aws-upgrade"
777802
aws = AWS(path)
803+
mz_debug_build_thread: threading.Thread | None = None
778804
try:
805+
if args.run_mz_debug:
806+
mz_debug_build_thread = build_mz_debug_async()
779807
aws.setup("aws-upgrade", args.setup, previous_tag)
780808
aws.upgrade(tag)
781809
if args.test:
@@ -812,6 +840,8 @@ def workflow_aws_upgrade(c: Composition, parser: WorkflowArgumentParser) -> None
812840
aws.cleanup()
813841

814842
if args.run_mz_debug:
843+
assert mz_debug_build_thread
844+
mz_debug_build_thread.join()
815845
run_mz_debug()
816846

817847
if args.cleanup:
@@ -997,7 +1027,10 @@ def workflow_gcp_temporary(c: Composition, parser: WorkflowArgumentParser) -> No
9971027
f.write(gcp_service_account_json)
9981028
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = str(gcloud_creds_path)
9991029

1030+
mz_debug_build_thread: threading.Thread | None = None
10001031
try:
1032+
if args.run_mz_debug:
1033+
mz_debug_build_thread = build_mz_debug_async()
10011034
spawn.runv(["gcloud", "config", "set", "project", "materialize-ci"])
10021035

10031036
spawn.runv(
@@ -1398,6 +1431,8 @@ def workflow_gcp_temporary(c: Composition, parser: WorkflowArgumentParser) -> No
13981431
os.killpg(os.getpgid(balancerd_port_forward_process.pid), signal.SIGTERM)
13991432

14001433
if args.run_mz_debug:
1434+
assert mz_debug_build_thread
1435+
mz_debug_build_thread.join()
14011436
run_mz_debug()
14021437

14031438
if args.cleanup:
@@ -1485,7 +1520,10 @@ def workflow_azure_temporary(c: Composition, parser: WorkflowArgumentParser) ->
14851520
env=venv_env,
14861521
)
14871522

1523+
mz_debug_build_thread: threading.Thread | None = None
14881524
try:
1525+
if args.run_mz_debug:
1526+
mz_debug_build_thread = build_mz_debug_async()
14891527
if os.getenv("CI"):
14901528
username = os.getenv("AZURE_SERVICE_ACCOUNT_USERNAME")
14911529
password = os.getenv("AZURE_SERVICE_ACCOUNT_PASSWORD")
@@ -1914,6 +1952,8 @@ def workflow_azure_temporary(c: Composition, parser: WorkflowArgumentParser) ->
19141952
os.killpg(os.getpgid(balancerd_port_forward_process.pid), signal.SIGTERM)
19151953

19161954
if args.run_mz_debug:
1955+
assert mz_debug_build_thread
1956+
mz_debug_build_thread.join()
19171957
run_mz_debug(env=venv_env)
19181958

19191959
if args.cleanup:

0 commit comments

Comments
 (0)