Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
allendowney
GitHub Repository: allendowney/cpython
Path: blob/main/Doc/tools/warnings-to-gh-actions.py
12 views
1
#!/usr/bin/env python3
2
3
"""
4
Convert Sphinx warning messages to GitHub Actions.
5
6
Converts lines like:
7
.../Doc/library/cgi.rst:98: WARNING: reference target not found
8
to:
9
::warning file=.../Doc/library/cgi.rst,line=98::reference target not found
10
11
Non-matching lines are echoed unchanged.
12
13
see: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-a-warning-message
14
"""
15
16
import re
17
import sys
18
19
pattern = re.compile(r'(?P<file>[^:]+):(?P<line>\d+): WARNING: (?P<msg>.+)')
20
21
for line in sys.stdin:
22
if match := pattern.fullmatch(line.strip()):
23
print('::warning file={file},line={line}::{msg}'.format_map(match))
24
else:
25
print(line)
26
27