Skip to content

Commit

Permalink
Report the number of incomplete publish targets on failure (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb authored Jan 5, 2024
1 parent b715ec6 commit c448e24
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/packse/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import logging
import os
import subprocess
import sys
import textwrap
import time
from concurrent.futures import ThreadPoolExecutor
Expand Down Expand Up @@ -72,8 +73,21 @@ def publish(

wait_for_futures(futures)

results = [future.result() for future in futures]
for result in sorted(results):
# All the futures are done since the executor context has exited; check if any failed
incomplete = 0
for future in futures:
if (exc := future.exception()) is None:
continue
incomplete += 1
print(f"{exc}.", file=sys.stderr)

if incomplete:
s = "" if targets == 1 else "s"
raise PublishError(
f"Failed to publish {len(targets) - incomplete}/{len(targets)} target{s}"
)

for result in sorted(future.result() for future in futures):
print(result)


Expand Down
3 changes: 3 additions & 0 deletions tests/__snapshots__/test_publish.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
Publishing 1 target to https://test.pypi.org/legacy/...
Publishing 'example-97db95eb'...
Publish for 'example_97db95eb-0.0.0.tar.gz' already exists.
Failed to publish 0/1 targets.

''',
'stdout': '',
Expand All @@ -120,6 +121,7 @@
Publishing 1 target to https://test.pypi.org/legacy/...
Publishing 'example-97db95eb'...
Publish of 'example_97db95eb-0.0.0.tar.gz' failed due to rate limits.
Failed to publish 0/1 targets.

''',
'stdout': '',
Expand All @@ -134,6 +136,7 @@
Publishing example_97db95eb-0.0.0.tar.gz with twine failed:
<twine error message>
.
Failed to publish 0/1 targets.

''',
'stdout': '',
Expand Down

0 comments on commit c448e24

Please sign in to comment.