Skip to content

Commit

Permalink
feat(lint): check for acceptablility in document subfields. Fixes #1369
Browse files Browse the repository at this point in the history
Signed-off-by: Laura Santamaria <[email protected]>
  • Loading branch information
nimbinatus committed Jan 2, 2025
1 parent adee87b commit eb03f4e
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions scripts/check-yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

# Standard
import argparse
import glob
import os
import pathlib
import re
import sys

# Third Party
Expand Down Expand Up @@ -49,8 +51,30 @@ def check(self) -> int:
"The \"%s\" file must be non-empty",
taxonomy.path.with_name(attribution_path.name),
)
# NOTE: The following three warnings are intended for the beta only, at the moment, and only to flag
# issues for maintainers to address rather than block on them. We will revisit when other content is
# allowed.
qna_file_contents = parser.parse(taxonomy.rel_path.with_name("qna.yaml")).contents
for element in qna_file_contents["document"]["patterns"]:
if not re.match('.*.md', element):
taxonomy.warning(
"The document \"%s\" should be a markdown file.",
element
)
if not re.match('https://github\.com\/.*',qna_file_contents["document"]["repo"]):
taxonomy.warning(
"The document repo \"%s\" needs to be a GitHub-based repository.",
qna_file_contents["document"]["repo"]
)
if not re.match('[0-9a-f]{40}', qna_file_contents["document"]["commit"]):
taxonomy.warning(
"The document commit \"%s\" needs to be an alphanumeric value that represents a commit. \Please check with the reviewers for help.",
qna_file_contents["document"]["commit"]
)
if taxonomy.errors > 0:
exit_code = 1
if taxonomy.warnings > 0:
exit_code = 0
if not self.yaml_files:
print("No yaml files specified.")
return exit_code
Expand Down

0 comments on commit eb03f4e

Please sign in to comment.