Skip to content

Commit 57bb9a0

Browse files
authored
Merge pull request #289 from blink1073/update-check-links-settings
2 parents e0224f9 + aa7a408 commit 57bb9a0

File tree

3 files changed

+29
-15
lines changed

3 files changed

+29
-15
lines changed

jupyter_releaser/lib.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def check_links(ignore_glob, ignore_links, cache_file, links_expire):
5555
cmd = f"{python} -m pytest --noconftest --check-links --check-links-cache "
5656
cmd += f"--check-links-cache-expire-after {links_expire} "
5757
cmd += "--disable-warnings --quiet "
58+
cmd += "-raXs "
5859
cmd += f"--check-links-cache-name {cache_dir}/check-release-links "
5960
# do not run doctests, since they might depend on other state.
6061
cmd += "-p no:doctest "
@@ -84,14 +85,27 @@ def check_links(ignore_glob, ignore_links, cache_file, links_expire):
8485
matched = glob(f"**/*{ext}", recursive=True)
8586
files.extend(m for m in matched if not m in ignored and "node_modules" not in m)
8687

88+
util.log("Checking files with options:")
89+
util.log(cmd)
90+
91+
fails = 0
8792
for f in files:
8893
file_cmd = cmd + f' "{f}"'
8994
try:
90-
util.run(file_cmd, shell=False)
95+
util.log(f"\nC{f}...")
96+
util.run(file_cmd, shell=False, echo=False)
9197
except Exception as e:
9298
# Return code 5 means no tests were run (no links found)
9399
if e.returncode != 5:
94-
util.run(file_cmd + " --lf", shell=False)
100+
try:
101+
util.log(f"{f} (second attempt)...")
102+
util.run(file_cmd + " --lf", shell=False, echo=False)
103+
except Exception:
104+
fails += 1
105+
if fails == 3:
106+
raise RuntimeError("Found three failed links, bailing")
107+
if fails:
108+
raise RuntimeError(f"Encountered failures in {fails} file(s)")
95109

96110

97111
def draft_changelog(

jupyter_releaser/tee.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,6 @@ def run(args: Union[str, List[str]], **kwargs: Any) -> CompletedProcess:
156156

157157
check = kwargs.get("check", False)
158158

159-
if kwargs.get("echo", False):
160-
# This is modified from the default implementation since
161-
# we want all output to be interleved on the same stream
162-
prefix = "COMMAND"
163-
if kwargs.pop("show_cwd", False):
164-
prefix += f" (in '{os.getcwd()}')"
165-
prefix += ":"
166-
print(f"{prefix} {cmd}", file=sys.stderr)
167-
168159
loop = asyncio.get_event_loop()
169160
result = loop.run_until_complete(_stream_subprocess(cmd, **kwargs))
170161

jupyter_releaser/util.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,23 @@
5454
def run(cmd, **kwargs):
5555
"""Run a command as a subprocess and get the output as a string"""
5656
quiet_error = kwargs.pop("quiet_error", False)
57+
show_cwd = kwargs.pop("show_cwd", False)
58+
quiet = kwargs.pop("quiet", False)
59+
echo = kwargs.pop("echo", False)
60+
61+
if echo:
62+
prefix = "COMMAND"
63+
if show_cwd:
64+
prefix += f" (in '{os.getcwd()}')"
65+
prefix += ":"
66+
print(f"{prefix} {cmd}", file=sys.stderr)
67+
5768
if sys.platform.startswith("win"):
5869
# Async subprocesses do not work well on Windows, use standard
5970
# subprocess methods
6071
return _run_win(cmd, **kwargs)
6172

6273
quiet = kwargs.get("quiet")
63-
kwargs.setdefault("echo", True)
6474
kwargs.setdefault("check", True)
6575

6676
try:
@@ -77,12 +87,11 @@ def run(cmd, **kwargs):
7787

7888
def _run_win(cmd, **kwargs):
7989
"""Run a command as a subprocess and get the output as a string"""
80-
kwargs.pop("show_cwd", False)
8190
quiet = kwargs.pop("quiet", False)
91+
8292
if not quiet:
83-
log(f"> {cmd}")
84-
else:
8593
kwargs.setdefault("stderr", PIPE)
94+
8695
kwargs.setdefault("shell", True)
8796

8897
parts = shlex.split(cmd)

0 commit comments

Comments
 (0)