-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.py
41 lines (33 loc) · 1.19 KB
/
entrypoint.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from doc8 import doc8
import os
try:
result = doc8(
paths=os.environ.get("INPUT_SCANPATHS").split(','),
ignore_path=os.environ.get("INPUT_IGNOREPATHS").split(',')
)
print("::group::doc8-check")
with open(os.environ["GITHUB_OUTPUT"], 'at') as f:
print("files_selected=%d" % result.files_selected, file=f)
print("files_ignored=%d" % result.files_ignored, file=f)
print("total_errors=%d" % result.total_errors, file=f)
if os.environ.get("INPUT_ADDANNOTATIONS") == 'true':
for error in result.errors:
print("::error file=%s,line=%d,endLine=%d,title=%s::%s" % (
error[1],
error[2],
error[2],
error[3],
error[4]
))
print("Found error %s (%s) in %s on line %d" % (
error[4],
error[3],
error[1],
error[2]
))
print(result.report())
print("::endgroup::")
if result.total_errors > 0:
exit(1)
except UnicodeDecodeError as error:
print("A document contains invalid unicode characters. We can't find the specific document, though: %s" % error)