-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# This workflow will check that each recipe has an "Instructions" and | ||
# "Ingredients" Markdown section (line starting with `#`). | ||
name: Basic recipe checks | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
check: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.x" | ||
- name: Test with pytest | ||
run: | | ||
python check_recipes.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import glob | ||
from pathlib import Path | ||
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())}:") | ||
|
||
errors = 0 | ||
for path in base.glob('*/*.md'): | ||
if not ingredients_re.search(path.read_text()): | ||
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"') | ||
errors += 1 | ||
print(f"{errors} errors") | ||
if errors: | ||
sys.exit(1) |