Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check that output file exists before opening #33

Merged
merged 4 commits into from Feb 16, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 9 additions & 7 deletions action.py
Expand Up @@ -135,15 +135,17 @@ def _fatal_help(msg):
else:
_summary("❌ pip-audit found one or more problems")

with open("/tmp/pip-audit-output.txt", "r") as io:
output = io.read()
p = Path("/tmp/pip-audit-output.txt")
if p.exists():
with p.open() as io:
output = io.read()

# This is really nasty: our output contains multiple lines,
# so we can't naively stuff it into an output.
print(f"output={b64encode(output.encode()).decode()}", file=_GITHUB_OUTPUT)
# This is really nasty: our output contains multiple lines,
# so we can't naively stuff it into an output.
print(f"output={b64encode(output.encode()).decode()}", file=_GITHUB_OUTPUT)

_log(output)
_summary(output)
_log(output)
_summary(output)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than check-and-skip, let's try-and-fail:

try:
    # open
except OSError as exc:
   # log an explicit error here, before the full stdout log



_log(status.stdout)
Expand Down