diff --git a/.github/workflows/validate-idea.yml b/.github/workflows/validate-idea.yml new file mode 100644 index 00000000..78f929c8 --- /dev/null +++ b/.github/workflows/validate-idea.yml @@ -0,0 +1,74 @@ +name: Validate Adventure Idea + +# Runs on PRs that touch ideas/*.md. +# The * glob excludes dot-folders, so ideas/.implemented/ is already filtered +# by the path pattern. We also filter it explicitly in step 4. +on: + pull_request: + paths: + - 'ideas/*.md' + +jobs: + validate: + name: Validate idea file format + runs-on: ubuntu-latest # A fresh Ubuntu VM is spun up for each run. + + steps: + + # fetch-depth: 0 is required so git diff can compare against the base branch. + - name: Checkout repository + uses: actions/checkout@v6 + with: + fetch-depth: 0 + + # The checkout action does not restore executable bits from git. + - name: Make validation script executable + run: chmod +x scripts/validate-idea.sh + + # Validates files added or modified by this PR. + # Excludes the template and .implemented/ as a belt-and-suspenders + # on top of the workflow path filter. + # || true prevents grep from failing the step when no files match. + - name: Find idea files to validate + env: + BASE_REF: ${{ github.base_ref }} + run: | + IDEA_FILES=$( + git diff --name-only --diff-filter=AM "origin/$BASE_REF" HEAD \ + | grep "^ideas/" \ + | grep "\.md$" \ + | grep -v "adventure-idea-template.md" \ + | grep -v "\.implemented/" \ + || true + ) + + if [[ -z "$IDEA_FILES" ]]; then + echo "No idea files to validate in this PR." + else + echo "Idea files to validate:" + echo "$IDEA_FILES" + fi + + { + echo "IDEA_FILES<> "$GITHUB_ENV" + + - name: Validate idea files + run: | + set -euo pipefail + + if [[ -z "$IDEA_FILES" ]]; then + echo "No idea files to validate. Skipping." + exit 0 + fi + + while IFS= read -r file; do + # Skip blank lines that can appear from the heredoc. + [[ -z "$file" ]] && continue + ./scripts/validate-idea.sh "$file" + done <<< "$IDEA_FILES" + + echo "" + echo "✅ All idea files passed validation." diff --git a/ideas/adventure-idea-template.md b/ideas/adventure-idea-template.md index 9ee4da79..36b1c83f 100644 --- a/ideas/adventure-idea-template.md +++ b/ideas/adventure-idea-template.md @@ -41,7 +41,7 @@