|
15 | 15 | import os |
16 | 16 | import signal |
17 | 17 | import subprocess |
| 18 | +import threading |
18 | 19 | import time |
19 | 20 | from collections.abc import Sequence |
20 | 21 | from pathlib import Path |
@@ -142,6 +143,25 @@ def get_tag(tag: str | None) -> str: |
142 | 143 | return tag or f"v{ci_util.get_mz_version()}--pr.g{git.rev_parse('HEAD')}" |
143 | 144 |
|
144 | 145 |
|
| 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 | + |
145 | 165 | def run_mz_debug(env: dict[str, str] | None = None) -> None: |
146 | 166 | print("--- Running mz-debug") |
147 | 167 | try: |
@@ -686,7 +706,10 @@ def workflow_aws_temporary(c: Composition, parser: WorkflowArgumentParser) -> No |
686 | 706 | tag = get_tag(args.tag) |
687 | 707 | path = MZ_ROOT / "test" / "terraform" / "aws-temporary" |
688 | 708 | aws = AWS(path) |
| 709 | + mz_debug_build_thread: threading.Thread | None = None |
689 | 710 | try: |
| 711 | + if args.run_mz_debug: |
| 712 | + mz_debug_build_thread = build_mz_debug_async() |
690 | 713 | aws.setup("aws-test", args.setup, tag) |
691 | 714 | if args.test: |
692 | 715 | print("--- Running tests") |
@@ -718,6 +741,8 @@ def workflow_aws_temporary(c: Composition, parser: WorkflowArgumentParser) -> No |
718 | 741 | aws.cleanup() |
719 | 742 |
|
720 | 743 | if args.run_mz_debug: |
| 744 | + assert mz_debug_build_thread |
| 745 | + mz_debug_build_thread.join() |
721 | 746 | run_mz_debug() |
722 | 747 |
|
723 | 748 | if args.cleanup: |
@@ -775,7 +800,10 @@ def workflow_aws_upgrade(c: Composition, parser: WorkflowArgumentParser) -> None |
775 | 800 | tag = get_tag(args.tag) |
776 | 801 | path = MZ_ROOT / "test" / "terraform" / "aws-upgrade" |
777 | 802 | aws = AWS(path) |
| 803 | + mz_debug_build_thread: threading.Thread | None = None |
778 | 804 | try: |
| 805 | + if args.run_mz_debug: |
| 806 | + mz_debug_build_thread = build_mz_debug_async() |
779 | 807 | aws.setup("aws-upgrade", args.setup, previous_tag) |
780 | 808 | aws.upgrade(tag) |
781 | 809 | if args.test: |
@@ -812,6 +840,8 @@ def workflow_aws_upgrade(c: Composition, parser: WorkflowArgumentParser) -> None |
812 | 840 | aws.cleanup() |
813 | 841 |
|
814 | 842 | if args.run_mz_debug: |
| 843 | + assert mz_debug_build_thread |
| 844 | + mz_debug_build_thread.join() |
815 | 845 | run_mz_debug() |
816 | 846 |
|
817 | 847 | if args.cleanup: |
@@ -997,7 +1027,10 @@ def workflow_gcp_temporary(c: Composition, parser: WorkflowArgumentParser) -> No |
997 | 1027 | f.write(gcp_service_account_json) |
998 | 1028 | os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = str(gcloud_creds_path) |
999 | 1029 |
|
| 1030 | + mz_debug_build_thread: threading.Thread | None = None |
1000 | 1031 | try: |
| 1032 | + if args.run_mz_debug: |
| 1033 | + mz_debug_build_thread = build_mz_debug_async() |
1001 | 1034 | spawn.runv(["gcloud", "config", "set", "project", "materialize-ci"]) |
1002 | 1035 |
|
1003 | 1036 | spawn.runv( |
@@ -1398,6 +1431,8 @@ def workflow_gcp_temporary(c: Composition, parser: WorkflowArgumentParser) -> No |
1398 | 1431 | os.killpg(os.getpgid(balancerd_port_forward_process.pid), signal.SIGTERM) |
1399 | 1432 |
|
1400 | 1433 | if args.run_mz_debug: |
| 1434 | + assert mz_debug_build_thread |
| 1435 | + mz_debug_build_thread.join() |
1401 | 1436 | run_mz_debug() |
1402 | 1437 |
|
1403 | 1438 | if args.cleanup: |
@@ -1485,7 +1520,10 @@ def workflow_azure_temporary(c: Composition, parser: WorkflowArgumentParser) -> |
1485 | 1520 | env=venv_env, |
1486 | 1521 | ) |
1487 | 1522 |
|
| 1523 | + mz_debug_build_thread: threading.Thread | None = None |
1488 | 1524 | try: |
| 1525 | + if args.run_mz_debug: |
| 1526 | + mz_debug_build_thread = build_mz_debug_async() |
1489 | 1527 | if os.getenv("CI"): |
1490 | 1528 | username = os.getenv("AZURE_SERVICE_ACCOUNT_USERNAME") |
1491 | 1529 | password = os.getenv("AZURE_SERVICE_ACCOUNT_PASSWORD") |
@@ -1914,6 +1952,8 @@ def workflow_azure_temporary(c: Composition, parser: WorkflowArgumentParser) -> |
1914 | 1952 | os.killpg(os.getpgid(balancerd_port_forward_process.pid), signal.SIGTERM) |
1915 | 1953 |
|
1916 | 1954 | if args.run_mz_debug: |
| 1955 | + assert mz_debug_build_thread |
| 1956 | + mz_debug_build_thread.join() |
1917 | 1957 | run_mz_debug(env=venv_env) |
1918 | 1958 |
|
1919 | 1959 | if args.cleanup: |
|
0 commit comments