Skip to content

Commit

Permalink
🧪 Gracefully handle no-report pytest runs @ tox
Browse files Browse the repository at this point in the history
Otherwise, it was trying to access argument values that weren't there.
  • Loading branch information
webknjaz committed Aug 28, 2024
1 parent fd245c3 commit e6445cd
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,23 @@ commands_post =
os.getenv("GITHUB_ACTIONS") == "true" or sys.exit(); \
cov_report_arg_prefix = "--cov-report=xml:"; \
test_report_arg_prefix = "--junitxml="; \
cov_report_file = [\
cov_reports = [\
arg[len(cov_report_arg_prefix):] for arg in sys.argv \
if arg.startswith(cov_report_arg_prefix)\
][-1]; \
test_report_file = [\
]; \
test_reports = [\
arg[len(test_report_arg_prefix):] for arg in sys.argv \
if arg.startswith(test_report_arg_prefix)\
][-1]; \
]; \
cov_report_file = cov_reports[-1] if cov_reports else None; \
test_report_file = test_reports[-1] if test_reports else None; \
gh_output_fd = open(\
os.environ["GITHUB_OUTPUT"], encoding="utf-8", mode="a",\
); \
print(f"cov-report-files={cov_report_file !s}", file=gh_output_fd); \
print(f"test-result-files={test_report_file !s}", file=gh_output_fd); \
cov_report_file and \
print(f"cov-report-files={cov_report_file !s}", file=gh_output_fd); \
test_report_file and \
print(f"test-result-files={test_report_file !s}", file=gh_output_fd); \
print("codecov-flags=pytest", file=gh_output_fd); \
gh_output_fd.close()' \
{posargs}
Expand Down

0 comments on commit e6445cd

Please sign in to comment.