Skip to content

Commit fed78a4

Browse files
committed
CI improvements
Flush print, etc more aggressively so log order makes sense. Use absolute paths in some places Always define ENABLE_ICE, which will be necessary to test P2P stuff.
1 parent 2e9fcd6 commit fed78a4

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

.github/run-single-config.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def shell_join(cmd: list[str]) -> str:
4949

5050

5151
def run_cmd(cmd: list[str], env: dict[str, str], cwd: Path, dry_run: bool) -> None:
52-
print(f"[cmd] {shell_join(cmd)}")
52+
print(f"[cmd] {shell_join(cmd)}", flush=True)
5353
if dry_run:
5454
return
5555
subprocess.run(cmd, env=env, cwd=str(cwd), check=True)
@@ -80,6 +80,10 @@ def parse_test_specs(specs: list[str] | None) -> list[list[str]]:
8080

8181

8282
def main() -> int:
83+
# In CI, stdout is usually not a TTY, so force line-buffering for timely logs.
84+
if hasattr(sys.stdout, "reconfigure"):
85+
sys.stdout.reconfigure(line_buffering=True)
86+
8387
args = parse_args()
8488

8589
repo_root = Path(__file__).resolve().parents[1]
@@ -97,6 +101,7 @@ def main() -> int:
97101
"-DCMAKE_C_COMPILER_LAUNCHER=ccache",
98102
"-DBUILD_TESTS=ON",
99103
"-DBUILD_EXAMPLES=ON",
104+
"-DENABLE_ICE=ON",
100105
"-DWERROR=ON",
101106
f"-DCMAKE_BUILD_TYPE={args.build_type}",
102107
]
@@ -124,10 +129,16 @@ def main() -> int:
124129
build_cmd.extend(args.targets)
125130

126131
test_cmds: list[list[str]] = []
132+
test_cwd = repo_root / args.build_dir / "bin"
127133
if args.run_tests:
128134
for test_parts in parse_test_specs(args.tests):
129-
exe = str(Path(args.build_dir) / "bin" / test_parts[0])
130-
test_cmds.append([exe, *test_parts[1:]])
135+
test_prog = test_parts[0]
136+
test_args = test_parts[1:]
137+
test_path = str((test_cwd / test_prog).resolve())
138+
if test_prog.endswith(".py"):
139+
test_cmds.append(["python3", test_path, *test_args])
140+
else:
141+
test_cmds.append([test_path, *test_args])
131142

132143
# If ccache isn't available in a local environment, remove launcher flags.
133144
if shutil.which("ccache") is None:
@@ -151,6 +162,7 @@ def main() -> int:
151162
print(f"crypto = {args.crypto}")
152163
print(f"crypto25519 = {args.crypto25519}")
153164
print(f"phase = {args.phase}")
165+
print(f"test_cwd = {test_cwd}")
154166
print(f"targets = {' '.join(args.targets) if args.targets else '(all default targets)'}")
155167
print(f"run_tests = {int(args.run_tests)}")
156168
if args.run_tests:
@@ -186,7 +198,7 @@ def main() -> int:
186198

187199
if args.phase in ("test", "all"):
188200
for cmd in test_cmds:
189-
run_cmd(cmd, env=env, cwd=repo_root, dry_run=args.dry_run)
201+
run_cmd(cmd, env=env, cwd=test_cwd, dry_run=args.dry_run)
190202
except subprocess.CalledProcessError as exc:
191203
print("\nBuild/test failed.")
192204
print("Re-run exactly:")

0 commit comments

Comments
 (0)