Skip to content

Commit eb03f4e

Browse files
committed
feat(lint): check for acceptablility in document subfields. Fixes #1369
Signed-off-by: Laura Santamaria <[email protected]>
1 parent adee87b commit eb03f4e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

scripts/check-yaml.py

+24
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33

44
# Standard
55
import argparse
6+
import glob
67
import os
78
import pathlib
9+
import re
810
import sys
911

1012
# Third Party
@@ -49,8 +51,30 @@ def check(self) -> int:
4951
"The \"%s\" file must be non-empty",
5052
taxonomy.path.with_name(attribution_path.name),
5153
)
54+
# NOTE: The following three warnings are intended for the beta only, at the moment, and only to flag
55+
# issues for maintainers to address rather than block on them. We will revisit when other content is
56+
# allowed.
57+
qna_file_contents = parser.parse(taxonomy.rel_path.with_name("qna.yaml")).contents
58+
for element in qna_file_contents["document"]["patterns"]:
59+
if not re.match('.*.md', element):
60+
taxonomy.warning(
61+
"The document \"%s\" should be a markdown file.",
62+
element
63+
)
64+
if not re.match('https://github\.com\/.*',qna_file_contents["document"]["repo"]):
65+
taxonomy.warning(
66+
"The document repo \"%s\" needs to be a GitHub-based repository.",
67+
qna_file_contents["document"]["repo"]
68+
)
69+
if not re.match('[0-9a-f]{40}', qna_file_contents["document"]["commit"]):
70+
taxonomy.warning(
71+
"The document commit \"%s\" needs to be an alphanumeric value that represents a commit. \Please check with the reviewers for help.",
72+
qna_file_contents["document"]["commit"]
73+
)
5274
if taxonomy.errors > 0:
5375
exit_code = 1
76+
if taxonomy.warnings > 0:
77+
exit_code = 0
5478
if not self.yaml_files:
5579
print("No yaml files specified.")
5680
return exit_code

0 commit comments

Comments
 (0)