mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
feat(tools): report progress changes on pull requests
progress.py stores the names of implemented and pending items, can measure another source tree with --root and prints a Markdown diff of two runs with --compare. The Progress report workflow compares every pull request with its base, and Progress comment posts the result as a single comment, updated on every push and removed when progress no longer changes. Commenting runs as a separate workflow_run so pull requests from forks never run with write permissions. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
name: Progress comment
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: [Progress report]
|
||||
types: [completed]
|
||||
|
||||
permissions:
|
||||
actions: read
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
comment:
|
||||
if: github.event.workflow_run.conclusion == 'success'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: progress-report
|
||||
run-id: ${{ github.event.workflow_run.id }}
|
||||
github-token: ${{ github.token }}
|
||||
- env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
GH_REPO: ${{ github.repository }}
|
||||
RUN_SHA: ${{ github.event.workflow_run.head_sha }}
|
||||
run: |
|
||||
pr=$(cat pr)
|
||||
[[ $pr =~ ^[0-9]+$ ]] || exit 1
|
||||
[ "$(gh pr view "$pr" --json headRefOid --jq .headRefOid)" = "$RUN_SHA" ] || exit 0
|
||||
marker='<!-- progress-report -->'
|
||||
id=$(gh api "repos/$GH_REPO/issues/$pr/comments" --paginate \
|
||||
--jq ".[] | select(.user.login == \"github-actions[bot]\" and (.body | startswith(\"$marker\"))) | .id" | head -n1)
|
||||
if [ -f report.md ]; then
|
||||
printf '%s\n%s' "$marker" "$(cat report.md)" > body.md
|
||||
if [ -n "$id" ]; then
|
||||
gh api -X PATCH "repos/$GH_REPO/issues/comments/$id" -F body=@body.md > /dev/null
|
||||
else
|
||||
gh pr comment "$pr" --body-file body.md
|
||||
fi
|
||||
elif [ -n "$id" ]; then
|
||||
gh api -X DELETE "repos/$GH_REPO/issues/comments/$id"
|
||||
fi
|
||||
@@ -0,0 +1,34 @@
|
||||
name: Progress report
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
report:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
with:
|
||||
fetch-depth: 2
|
||||
- env:
|
||||
PR: ${{ github.event.pull_request.number }}
|
||||
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
||||
run: |
|
||||
out=$RUNNER_TEMP/out report=$RUNNER_TEMP/report
|
||||
git worktree add --detach "$RUNNER_TEMP/base" HEAD^1
|
||||
python3 tools/progress.py --root "$RUNNER_TEMP/base" "$out/base"
|
||||
python3 tools/progress.py "$out/head"
|
||||
mkdir "$report"
|
||||
echo "$PR" > "$report/pr"
|
||||
body=$(python3 tools/progress.py --compare "$out/base/progress.json" "$out/head/progress.json")
|
||||
if [ -n "$body" ]; then
|
||||
printf '### Progress report (%s → %s)\n\n%s\n' "$(git rev-parse --short HEAD^1)" "${HEAD_SHA::7}" "$body" > "$report/report.md"
|
||||
cat "$report/report.md" >> "$GITHUB_STEP_SUMMARY"
|
||||
fi
|
||||
- uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: progress-report
|
||||
path: ${{ runner.temp }}/report
|
||||
Reference in New Issue
Block a user