Skip to content

Commit

Permalink
more robust automatic test
Browse files Browse the repository at this point in the history
Co-authored-by: Richard Darst <[email protected]>
  • Loading branch information
bast and rkdarst committed Jul 10, 2024
1 parent 9c5559a commit a8b1aff
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions check_recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@
import re
import sys

ingredients_re = re.compile('^#.*ingredients', re.IGNORECASE|re.MULTILINE)
instructions_re = re.compile('^#.*instructions', re.IGNORECASE|re.MULTILINE)

base = Path('.')
print(f"Checking recipes in {str(base.absolute())}:")
ingredients_re = re.compile("^#+ +ingredients", re.IGNORECASE | re.MULTILINE)
instructions_re = re.compile("^#+ +instructions", re.IGNORECASE | re.MULTILINE)

paths = Path(__file__).parent.glob("*/*.md")
errors = 0
for path in base.glob('*/*.md'):
for path in paths:
if not ingredients_re.search(path.read_text()):
print(f'::error file={str(path)},title=Ingredients missing::File is missing an ingredients section: "# Ingredients"')
print(
f'::error file={str(path)},title=Ingredients missing::File is missing an ingredients section: "# Ingredients"'
)
errors += 1
if not instructions_re.search(path.read_text()):
print(f'::error file={str(path)},title=Instructions missing::File is missing an instructions section: "# Instructions"')
print(
f'::error file={str(path)},title=Instructions missing::File is missing an instructions section: "# Instructions"'
)
errors += 1
print(f"{errors} errors")

if errors:
sys.exit(1)

0 comments on commit a8b1aff

Please sign in to comment.