Skip to content

Enhance notes management and documentation structure #54

Enhance notes management and documentation structure

Enhance notes management and documentation structure #54

Workflow file for this run

name: Lint and Generate Assets
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install deps
run: npm install
- name: Run remark
run: npx remark . --frail
- name: Run markdownlint
run: npx markdownlint "**/*.md" --ignore node_modules
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install Python dependencies
run: pip install frontmatter
- name: Generate flashcards
run: python scripts/export_flashcards_json.py
- name: Generate quizzes
run: python scripts/export_quizzes_json.py
- name: Validate flashcards format
run: |
python -c "
import json
import re
# Load flashcards
with open('docs/artifacts/flashcards.json', 'r') as f:
cards = json.load(f)
print(f'Found {len(cards)} flashcards')
# Validate card format
for card in cards:
if 'q' not in card or 'a' not in card or 'category' not in card:
print(f'Invalid card format: {card}')
exit(1)
print('All flashcards have valid format')
# Extract categories from flashcards
flashcard_categories = set(card['category'] for card in cards)
print(f'Categories in flashcards: {sorted(flashcard_categories)}')
# Extract deck options from HTML
with open('docs/index.html', 'r') as f:
html_content = f.read()
deck_options = re.findall(r'<option value=\"([^\"]+)\">', html_content)
deck_categories = set(opt for opt in deck_options if opt != 'all')
print(f'Deck options in HTML: {sorted(deck_categories)}')
# Validate that all flashcard categories are in deck options
missing_in_html = flashcard_categories - deck_categories
if missing_in_html:
print(f'ERROR: Categories in flashcards but not in HTML: {missing_in_html}')
exit(1)
print('✅ All flashcard categories have corresponding deck options')
"
- name: Validate quizzes format
run: |
python -c "
import json
# Load quizzes
with open('docs/artifacts/quizzes.json', 'r') as f:
quizzes = json.load(f)
print(f'Found {len(quizzes)} quizzes')
# Validate quiz format
for quiz in quizzes:
if 'q' not in quiz or 'options' not in quiz or 'answers' not in quiz:
print(f'Invalid quiz format: {quiz}')
exit(1)
if not isinstance(quiz['answers'], list):
print(f'Answers must be a list: {quiz}')
exit(1)
if not all(isinstance(a, int) and 0 <= a < len(quiz['options']) for a in quiz['answers']):
print(f'Invalid answer indices: {quiz}')
exit(1)
print('All quizzes have valid format')
"
- name: Commit generated flashcards and quizzes
if: github.event_name == 'push'
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add -f docs/artifacts/flashcards.json
git add -f docs/artifacts/quizzes.json
if ! git diff --staged --quiet; then
TOTAL_CARDS=$(grep -c '"category"' docs/artifacts/flashcards.json)
TOTAL_QUIZZES=$(grep -c '"category"' docs/artifacts/quizzes.json || echo "0")
git commit -m "Auto-generate flashcards and quizzes from notes
- Updated ${TOTAL_CARDS} flashcards
- Updated ${TOTAL_QUIZZES} quizzes
- Generated from all note categories" || echo "No changes to commit"
else
echo "No flashcard or quiz changes to commit"
fi