diff --git a/.github/workflows/update-grammar.yml b/.github/workflows/update-grammar.yml new file mode 100644 index 0000000..d232b73 --- /dev/null +++ b/.github/workflows/update-grammar.yml @@ -0,0 +1,59 @@ +name: Update Grammar Railroad Diagram + +on: + schedule: + - cron: '47 * * * *' + workflow_dispatch: + +permissions: + contents: write + +jobs: + update-grammar: + name: Generate railroad diagram from EBNF grammar + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '17' + + - name: Download EBNF grammar + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + mkdir -p grammar + gh api repos/ChaiScript/ChaiScript/contents/grammar/chaiscript.ebnf \ + --jq '.content' | base64 -d > grammar/chaiscript.ebnf + + - name: Download rr-webapp + run: | + curl -sL \ + "https://repo1.maven.org/maven2/de/bottlecaps/rr/rr-webapp/2.6/rr-webapp-2.6.war" \ + -o /tmp/rr.war + + - name: Generate railroad diagram + run: | + java -jar /tmp/rr.war \ + -out:grammar/railroad.xhtml \ + grammar/chaiscript.ebnf + + - name: Check for changes + id: changes + run: | + git add grammar/ + if git diff --cached --quiet; then + echo "changed=false" >> "$GITHUB_OUTPUT" + else + echo "changed=true" >> "$GITHUB_OUTPUT" + fi + + - name: Commit and push + if: steps.changes.outputs.changed == 'true' + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git commit -m "Update grammar railroad diagram from ChaiScript/ChaiScript" + git push diff --git a/_includes/header.html b/_includes/header.html index f134859..31a70c5 100644 --- a/_includes/header.html +++ b/_includes/header.html @@ -32,6 +32,9 @@
  • Cheatsheet
  • +
  • + Grammar +
  • Docs
  • diff --git a/grammar.html b/grammar.html new file mode 100644 index 0000000..501820f --- /dev/null +++ b/grammar.html @@ -0,0 +1,50 @@ +--- +title: Grammar +--- + + + + + +ChaiScript - Grammar Railroad Diagram +{% include common.html %} + + + + + + + +{% include header.html %} + +
    +

    Grammar Railroad Diagram

    +

    Navigable railroad diagram of ChaiScript's syntax, generated from the + EBNF grammar + using RR.

    +
    + +
    + + + +
    + + diff --git a/test_playground.sh b/test_playground.sh index 524659a..69344df 100644 --- a/test_playground.sh +++ b/test_playground.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Regression test for issue #6: WASM playground +# Regression tests for the ChaiScript website build artifacts. # Validates that all required files exist and contain expected content. set -euo pipefail @@ -40,6 +40,22 @@ assert_file_contains "playground.html" "header.html" # 3. Navigation includes playground link assert_file_contains "_includes/header.html" "playground" +# 4. Grammar railroad diagram workflow exists and runs hourly +assert_file_exists ".github/workflows/update-grammar.yml" +assert_file_contains ".github/workflows/update-grammar.yml" "schedule" +assert_file_contains ".github/workflows/update-grammar.yml" "cron:" +assert_file_contains ".github/workflows/update-grammar.yml" "chaiscript.ebnf" +assert_file_contains ".github/workflows/update-grammar.yml" "ChaiScript/ChaiScript" +assert_file_contains ".github/workflows/update-grammar.yml" "rr-webapp" + +# 5. Grammar page exists with required elements +assert_file_exists "grammar.html" +assert_file_contains "grammar.html" "header.html" +assert_file_contains "grammar.html" "railroad" + +# 6. Navigation includes grammar link +assert_file_contains "_includes/header.html" "grammar" + if [ "$FAIL" -ne 0 ]; then echo "" echo "RESULT: SOME TESTS FAILED"