Repository navigation
feat: Stamp pr-review and weekly-report with the pinned-SHA footer #125
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
Some comments aren't visible on the classic Files Changed page.
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
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
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,127 @@ | ||
| #!/usr/bin/env bash | ||
|
rubambiza marked this conversation as resolved.
Resolved
|
||
|
|
||
| # Pinned-SHA footer for pr-review (pr-review-fixer.sh footer) and | ||
| # weekly-report (appended to the posted report). | ||
| # The rules are: write _meta only after the SHA resolves, never overwrite a valid | ||
| # file, and fall back to blob/main when resolution fails. | ||
| set -uo pipefail | ||
| ROOT="$(cd "$(dirname "$0")/.." && pwd)" | ||
| SCRIPTS="$ROOT/scripts" | ||
| fail=0 | ||
| TMP=$(mktemp -d) | ||
| trap 'rm -rf "$TMP"' EXIT | ||
|
|
||
| FAKE_SHA="85449beabc1234567890abcdef1234567890abcd" | ||
| PINNED="deadbeefdeadbeefdeadbeefdeadbeefdeadbeef" | ||
|
|
||
| mkdir -p "$TMP/bin" | ||
| cat > "$TMP/bin/gh" << 'EOF' | ||
| #!/bin/sh | ||
| if [ -n "${GH_LOG:-}" ]; then | ||
| echo "$@" >> "$GH_LOG" | ||
| fi | ||
| if [ "${GH_FAIL:-}" = "1" ]; then | ||
| echo "rate limited" >&2 | ||
| exit 1 | ||
| fi | ||
| printf '%s\n' "$GH_SHA" | ||
| EOF | ||
| chmod +x "$TMP/bin/gh" | ||
| export PATH="$TMP/bin:$PATH" | ||
| export GH_SHA="$FAKE_SHA" | ||
| export GH_LOG="$TMP/gh.log" | ||
| export SKILL_SOURCE_REPO="rossoctl/agent-skills" | ||
| : > "$GH_LOG" | ||
|
|
||
| check() { | ||
| if eval "$1"; then | ||
| echo "PASS: $2" | ||
| else | ||
| echo "FAIL: $2" | ||
| fail=1 | ||
| fi | ||
| } | ||
|
|
||
| export REPOMAN_SKILL_DIR="$TMP/fixer" | ||
| mkdir -p "$REPOMAN_SKILL_DIR" | ||
| foot=$(bash "$SCRIPTS/pr-review-fixer.sh" footer) | ||
| case "$foot" in | ||
| *"Generated by RepoMan github-pr-review@${FAKE_SHA:0:7}"*"blob/$FAKE_SHA/skills/github-pr-review/SKILL.md"*) | ||
| echo "PASS: fixer footer line" ;; | ||
| *) echo "FAIL: fixer footer line: $foot"; fail=1 ;; | ||
| esac | ||
| check "[ -f \"$REPOMAN_SKILL_DIR/_meta.github-pr-review.json\" ]" "fixer writes _meta" | ||
| : > "$GH_LOG" | ||
| bash "$SCRIPTS/pr-review-fixer.sh" footer >/dev/null | ||
| check "[ ! -s \"$GH_LOG\" ]" "fixer does not refresh a valid _meta" | ||
|
|
||
| export GH_FAIL=1 | ||
| export REPOMAN_SKILL_DIR="$TMP/fixer-fail" | ||
| mkdir -p "$REPOMAN_SKILL_DIR" | ||
| footf=$(bash "$SCRIPTS/pr-review-fixer.sh" footer 2>/dev/null) | ||
| case "$footf" in | ||
| *"blob/main/skills/github-pr-review/SKILL.md"*) | ||
| echo "PASS: fixer failure uses blob/main" ;; | ||
| *) echo "FAIL: fixer failure uses blob/main: $footf"; fail=1 ;; | ||
| esac | ||
| case "$footf" in | ||
| *@*) echo "FAIL: fixer fallback has no @sha: $footf"; fail=1 ;; | ||
| *) echo "PASS: fixer fallback has no @sha" ;; | ||
| esac | ||
| check "[ ! -f \"$REPOMAN_SKILL_DIR/_meta.github-pr-review.json\" ]" "fixer failure writes no _meta" | ||
|
|
||
| export GH_FAIL= | ||
| export REPOMAN_REPOS_FILE="$TMP/repos.json" | ||
| printf '[{"owner":"acme","name":"widgets"}]\n' > "$REPOMAN_REPOS_FILE" | ||
| export REPORT_PY="$TMP/report.py" | ||
| cat > "$REPORT_PY" << 'PY' | ||
| import sys | ||
| args = sys.argv[1:] | ||
| if "--output" in args: | ||
| open(args[args.index("--output") + 1], "w").write("# Weekly\nbody\n") | ||
| else: | ||
| sys.stdout.write("# Weekly\nbody\n") | ||
| PY | ||
| export REPOMAN_SKILL_DIR="$TMP/weekly" | ||
| mkdir -p "$REPOMAN_SKILL_DIR" | ||
| : > "$GH_LOG" | ||
| out="$TMP/report.md" | ||
| bash "$SCRIPTS/weekly-report.sh" --output "$out" >/dev/null | ||
| last=$(tail -n 1 "$out") | ||
| check "grep -q '# Weekly' \"$out\"" "weekly report keeps its body" | ||
| case "$last" in | ||
| *"Generated by RepoMan github-weekly-report@${FAKE_SHA:0:7}"*"blob/$FAKE_SHA/skills/github-weekly-report/SKILL.md"*) | ||
| echo "PASS: weekly report ends with pinned footer" ;; | ||
| *) echo "FAIL: weekly report ends with pinned footer: $last"; fail=1 ;; | ||
| esac | ||
| check "[ -f \"$REPOMAN_SKILL_DIR/_meta.github-weekly-report.json\" ]" "weekly writes its own _meta" | ||
|
|
||
| # A pre-pinned file is kept, and a different gh answer is ignored. | ||
| printf '{"version":"%s","source":"rossoctl/agent-skills","installed_at":"2026-01-01"}\n' \ | ||
| "$PINNED" > "$REPOMAN_SKILL_DIR/_meta.github-weekly-report.json" | ||
| export GH_SHA="ffffffffffffffffffffffffffffffffffffffff" | ||
| : > "$GH_LOG" | ||
| out2="$TMP/report-kept.md" | ||
| bash "$SCRIPTS/weekly-report.sh" --output "$out2" >/dev/null | ||
| kept=$(tail -n 1 "$out2") | ||
| case "$kept" in | ||
| *"github-weekly-report@${PINNED:0:7}"*) | ||
| echo "PASS: weekly keeps an existing _meta sha" ;; | ||
| *) echo "FAIL: weekly keeps an existing _meta sha: $kept"; fail=1 ;; | ||
| esac | ||
| check "[ ! -s \"$GH_LOG\" ]" "weekly does not call gh when _meta is valid" | ||
|
|
||
| export GH_FAIL=1 | ||
| export REPOMAN_SKILL_DIR="$TMP/weekly-fail" | ||
| mkdir -p "$REPOMAN_SKILL_DIR" | ||
| outf="$TMP/report-fail.md" | ||
| bash "$SCRIPTS/weekly-report.sh" --output "$outf" >/dev/null 2>&1 | ||
| lastf=$(tail -n 1 "$outf") | ||
| case "$lastf" in | ||
| *"blob/main/skills/github-weekly-report/SKILL.md"*) | ||
| echo "PASS: weekly failure uses blob/main" ;; | ||
| *) echo "FAIL: weekly failure uses blob/main: $lastf"; fail=1 ;; | ||
| esac | ||
| check "[ ! -f \"$REPOMAN_SKILL_DIR/_meta.github-weekly-report.json\" ]" "weekly failure writes no _meta" | ||
|
|
||
| [ "$fail" -eq 0 ] && echo "PASS: pr-review and weekly-report attribution" || exit 1 | ||
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.