-
Notifications
You must be signed in to change notification settings - Fork 1
feat(ci): centralize easter-egg keywords single source of truth (closes #6) #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,26 @@ | ||
| name: easter-egg keywords | ||
|
|
||
| # Fails if any keyword in docs/easter-eggs.md's canonical keyword block is | ||
| # absent from every v1-modern/src/scripts/*.narrat file. Prevents the silent | ||
| # drift described in issue #6. | ||
| # | ||
| # This workflow does not use any untrusted input (no github.event.* in run: | ||
| # commands); it only runs a checked-in script. | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - 'docs/easter-eggs.md' | ||
| - 'v1-modern/src/scripts/**.narrat' | ||
| - 'scripts/check-easter-eggs.sh' | ||
| - '.github/workflows/easter-eggs.yml' | ||
| push: | ||
| branches: [main] | ||
|
|
||
| jobs: | ||
| check: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Verify every canonical keyword appears in some narrat script | ||
| run: bash scripts/check-easter-eggs.sh |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,46 @@ | ||
| #!/usr/bin/env bash | ||
| # check-easter-eggs.sh — fails if any keyword from docs/easter-eggs.md's | ||
| # canonical list is absent from every v1-modern/src/scripts/*.narrat file. | ||
| # | ||
| # Used by the easter-eggs CI workflow and can be run locally as a pre-commit | ||
| # check. Part of the single-source-of-truth contract established in issue #6. | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)" | ||
| KEYWORDS_FILE="$REPO_ROOT/docs/easter-eggs.md" | ||
| NARRAT_DIR="$REPO_ROOT/v1-modern/src/scripts" | ||
|
|
||
| if [[ ! -f "$KEYWORDS_FILE" ]]; then | ||
| echo "ERROR: $KEYWORDS_FILE not found" >&2 | ||
| exit 2 | ||
| fi | ||
|
|
||
| # Parse keywords from the fenced ```keywords ... ``` block. | ||
| keywords=$(awk ' | ||
| /^```keywords$/ { inblock=1; next } | ||
| /^```$/ && inblock { exit } | ||
| inblock && NF > 0 { print } | ||
| ' "$KEYWORDS_FILE") | ||
|
|
||
| if [[ -z "$keywords" ]]; then | ||
| echo "ERROR: no keywords parsed from $KEYWORDS_FILE (missing or malformed \`\`\`keywords block)" >&2 | ||
| exit 2 | ||
| fi | ||
|
|
||
| total=$(printf '%s\n' "$keywords" | grep -c .) | ||
| missing=() | ||
| while IFS= read -r kw; do | ||
| [[ -z "$kw" ]] && continue | ||
| if ! grep -l -- "$kw" "$NARRAT_DIR"/*.narrat >/dev/null 2>&1; then | ||
| missing+=("$kw") | ||
| fi | ||
| done <<<"$keywords" | ||
|
|
||
| if (( ${#missing[@]} > 0 )); then | ||
| echo "ERROR: these keywords from $KEYWORDS_FILE are absent from every $NARRAT_DIR/*.narrat:" >&2 | ||
| printf ' - %s\n' "${missing[@]}" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "OK: all $total easter-egg keywords present in at least one narrat script" | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new CI check uses
grep -l -- "$kw", which treats each keyword as a regex and matches substrings, so the guard can pass even when the canonical token is no longer present verbatim (for example,TEAmatching inside another word, or future keywords with regex metacharacters like./+). That weakens the single-source-of-truth contract because removing a real easter-egg token may not fail this workflow.Useful? React with 👍 / 👎.