forked from eclipse-theia/theia-cloud-helm
-
Notifications
You must be signed in to change notification settings - Fork 0
chore: tag-format check, and the two-directional AGENTS.md guard #26
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
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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,19 @@ | ||
| # Enforce one spelling for release tags. The grammar lives in | ||
| # EduIDE/.github so the repos cannot drift apart on it. | ||
| # | ||
| # git tag vX.Y.Z | ||
| # image tag X.Y.Z | ||
| # chart version X.Y.Z | ||
|
|
||
| name: Tag format | ||
|
|
||
| on: | ||
| push: | ||
| tags: ["**"] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| check: | ||
| uses: EduIDE/.github/.github/workflows/check-tag-format.yml@main |
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 |
|---|---|---|
| @@ -1,35 +1,75 @@ | ||
| #!/usr/bin/env bash | ||
| # Flag paths referenced by AGENTS.md that no longer exist. | ||
| # Check AGENTS.md's factual claims about paths, in both directions. | ||
| # | ||
| # Both pre-existing AGENTS.md files in this org had rotted into fiction. One | ||
| # named a CI job that had been deleted and a package.json path that does not | ||
| # exist; the other described a landing page removed months earlier. Nothing | ||
| # checked them, so nothing noticed. | ||
| # Every AGENTS.md in this org had rotted into fiction. One named a CI job that | ||
| # had been deleted and a package.json path that does not exist; another | ||
| # described a landing page removed months earlier. Nothing checked them, so | ||
| # nothing noticed. | ||
| # | ||
| # A path in backticks must exist - unless the sentence containing it says it | ||
| # does not, in which case it must NOT exist. That second direction matters: | ||
| # these docs deliberately name dead paths so nobody mistakes them for live code, | ||
| # and if someone later creates one the doc has quietly become wrong again. | ||
| # | ||
| # Checking is per REFERENCE, not per path: a doc that says a file is gone in one | ||
| # sentence and tells you to edit it in another is wrong, and evaluating the path | ||
| # once would let the negated sentence excuse the live one. | ||
| # | ||
| # Only repo-relative, extension-bearing paths in backticks are checked. Prose is | ||
| # not validated, and this is a lint rather than a proof. | ||
| # not validated; this is a lint, not a proof. | ||
|
|
||
| set -uo pipefail | ||
|
|
||
| ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" | ||
| DOC="$ROOT/AGENTS.md" | ||
| [[ -f "$DOC" ]] || { echo "no AGENTS.md here"; exit 0; } | ||
|
|
||
| missing=0 | ||
| while read -r p; do | ||
| [[ "$p" == */* ]] || continue # must look like a path | ||
| [[ "$p" == *.* ]] || continue # and carry an extension | ||
| # A sentence asserting absence. Deliberately narrow: "is dead" and "retired" | ||
| # describe something that exists and does not work, which is a different claim. | ||
| NEGATED='does not exist|do not exist|no longer exists|no longer exist|was removed|were removed|has no root' | ||
|
|
||
| interesting() { | ||
| local p="$1" | ||
| [[ "$p" == */* ]] || return 1 # must look like a path | ||
| [[ "$p" == *.* ]] || return 1 # and carry an extension | ||
| case "$p" in | ||
| http*|*ghcr.io*|*github.com*|oci://*|*.tum.de*) continue ;; | ||
| http*|*ghcr.io*|*github.com*|oci://*|*.tum.de*|*.io/*|*@*) return 1 ;; | ||
| esac | ||
| if [[ ! -e "$ROOT/$p" ]]; then | ||
| echo " missing: $p" | ||
| missing=1 | ||
| fi | ||
| done < <(grep -oE '`[A-Za-z0-9_./-]+`' "$DOC" | tr -d '`' | sort -u) | ||
|
|
||
| if [[ $missing -ne 0 ]]; then | ||
| echo "AGENTS.md references paths that do not exist. Fix the doc or the path." | ||
| return 0 | ||
| } | ||
|
|
||
| failed=0; checked=0 | ||
| # One line at a time, so each reference is judged in its own sentence. | ||
| while IFS=: read -r lineno line; do | ||
| while IFS= read -r p; do | ||
| interesting "$p" || continue | ||
|
|
||
| # A parent-directory reference resolves against whatever happens to sit | ||
| # beside the checkout, so it passes locally and fails in CI - or worse, the | ||
| # reverse. Cross-repo paths belong in prose, not in backticks. | ||
| case "$p" in | ||
| ../*|*/../*) | ||
| echo " line $lineno: leaves the repository: $p" | ||
| echo " cross-repo paths cannot be checked; name the file without a path" | ||
| failed=1 | ||
| continue ;; | ||
| esac | ||
|
|
||
| checked=$((checked + 1)) | ||
| if grep -qiE "$NEGATED" <<<"$line"; then | ||
| if [[ -e "$ROOT/$p" ]]; then | ||
| echo " line $lineno: says this does not exist, but it does: $p" | ||
| failed=1 | ||
| fi | ||
| elif [[ ! -e "$ROOT/$p" ]]; then | ||
| echo " line $lineno: missing: $p" | ||
| failed=1 | ||
| fi | ||
| done < <(grep -oE '`[A-Za-z0-9_./-]+`' <<<"$line" | tr -d '`') | ||
| done < <(grep -n '`' "$DOC") | ||
|
|
||
| if [[ $failed -ne 0 ]]; then | ||
| echo "AGENTS.md disagrees with the repository. Fix the doc or the path." | ||
| exit 1 | ||
| fi | ||
| echo "AGENTS.md: every referenced path exists" | ||
| echo "AGENTS.md: $checked path references all check out" | ||
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.
Uh oh!
There was an error while loading. Please reload this page.