diff --git a/src/loopzero/cli.py b/src/loopzero/cli.py index 4ddfa0a4..2cd4b661 100644 --- a/src/loopzero/cli.py +++ b/src/loopzero/cli.py @@ -649,7 +649,7 @@ def cmd_check(args: argparse.Namespace) -> int: raise config_mod.ConfigError("checks.commands must list at least one command to run checks") try: report = sandbox.run_checks(config, wt, progress=lambda command: print( - f"running: {command}", flush=True), + f"running: {github.redact_credentials(command)}", flush=True), status=lambda message: print(message, flush=True), checkpoint=lambda partial: _save_report(wt, partial), workflow=args.config or f"origin/{config.base_branch}:workflow.toml") @@ -659,7 +659,8 @@ def cmd_check(args: argparse.Namespace) -> int: shortened = False for result in report.results: if result.exit_code != 0: - print(f"--- {result.command} (exit {result.exit_code}) ---", file=sys.stderr) + heading = github.redact_credentials(result.command) + print(f"--- {heading} (exit {result.exit_code}) ---", file=sys.stderr) tail = _proc.tail(result.tail) preview = _check_failure_preview(tail) shortened |= preview != tail diff --git a/tests/test_cli.py b/tests/test_cli.py index 28a77a46..171fa118 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -688,7 +688,7 @@ def run_checks(cfg, path, *, progress, status, checkpoint, workflow): @pytest.mark.parametrize("command,exit_code,tail", [ - ("echo no; exit 3", 3, "no\n"), + ("echo no; exit 3 # https://fake-heading-secret@example.invalid", 3, "no\n"), ("seq 1 50; exit 1", 1, "".join(f"{i}\n" for i in range(11, 51)))]) def test_check_failure_reports_verdict_and_capped_tail(wt, capsys, command, exit_code, tail): (wt / "workflow.toml").write_text(WORKFLOW.replace( @@ -696,10 +696,10 @@ def test_check_failure_reports_verdict_and_capped_tail(wt, capsys, command, exit code, out, err = run(capsys, "--config", str(wt / "workflow.toml"), "check") assert code == 1 and out.endswith("FAIL\n") assert out.startswith("checks are unpinned because --config was provided\n") - assert sum(line.startswith(("stage 1/2: exit ", "exit ")) - for line in out.splitlines()) == 1 + heading = command.replace("fake-heading-secret", "[REDACTED]") + assert out.count(f"running: {heading}\n") == out.count("stage 1/2: exit ") == 1 assert f"stage 1/2: exit {exit_code} (" in out and "README.md" not in out - assert err == f"--- {command} (exit {exit_code}) ---\n{tail}" + assert err == f"--- {heading} (exit {exit_code}) ---\n{tail}" report = json.loads((wt / ".loopzero/checks.json").read_text()) assert [result["command"] for result in report["results"]] == [command]