Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 108 additions & 0 deletions .github/workflows/preloop-triage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Surface Preloop PR review comments. Label + sticky checklist only. No secrets.
# Reviews themselves come from Preloop Cloud flow "DD - Pull Request Reviewer".

name: preloop triage

on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]

permissions:
contents: read
issues: write
pull-requests: write

jobs:
triage:
name: label + checklist
runs-on: ubuntu-latest
timeout-minutes: 5
if: >
github.event.sender.login == 'preloop[bot]' &&
(
(github.event_name == 'issue_comment' &&
github.event.issue.pull_request != null &&
contains(github.event.comment.body, 'preloop-review:flow-id:pr-reviewer')) ||
(github.event_name == 'pull_request_review_comment' &&
contains(github.event.comment.body, 'preloop-review:flow-id:pr-reviewer'))
)
steps:
- name: Resolve PR number
id: pr
env:
EVENT_NAME: ${{ github.event_name }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
set -euo pipefail
if [[ "$EVENT_NAME" == "issue_comment" ]]; then
echo "number=${ISSUE_NUMBER}" >> "$GITHUB_OUTPUT"
else
echo "number=${PR_NUMBER}" >> "$GITHUB_OUTPUT"
fi

- name: Ensure label preloop-triage
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
run: |
set -euo pipefail
if ! gh label list --repo "$REPO" --limit 200 --json name \
--jq '.[].name' | grep -qx 'preloop-triage'; then
gh label create preloop-triage --repo "$REPO" \
--color BFD4F2 --description "Preloop left PR review findings to triage"
fi

- name: Label PR
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
PR: ${{ steps.pr.outputs.number }}
run: |
set -euo pipefail
gh pr edit "$PR" --repo "$REPO" --add-label preloop-triage

- name: Upsert sticky triage checklist
if: github.event_name == 'issue_comment'
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
PR: ${{ steps.pr.outputs.number }}
COMMENT_URL: ${{ github.event.comment.html_url }}
run: |
set -euo pipefail
MARKER='<!-- preloop-triage-checklist -->'
BODY=$(cat <<EOF
${MARKER}
## Preloop triage checklist

Preloop posted a review on this PR ([comment](${COMMENT_URL})).
Label **\`preloop-triage\`** was applied so the finding is not lost after merge.

### Fetch (local / agent)

\`\`\`bash
./scripts/fetch-preloop-pr.sh ${PR}
\`\`\`

### Done when
- [ ] Findings read (summary + inline)
- [ ] Fixes landed or consciously deferred
- [ ] Label \`preloop-triage\` removed

Detail: [docs/CI.md](https://github.com/${REPO}/blob/main/docs/CI.md).
EOF
)
BODY="$(printf '%s\n' "$BODY" | sed 's/^ //')"

existing="$(gh api "repos/${REPO}/issues/${PR}/comments" --paginate \
--jq ".[] | select(.body | contains(\"${MARKER}\")) | .id" | head -n1 || true)"
if [[ -n "${existing}" ]]; then
gh api --method PATCH "repos/${REPO}/issues/comments/${existing}" \
-f body="$BODY" >/dev/null
else
gh api --method POST "repos/${REPO}/issues/${PR}/comments" \
-f body="$BODY" >/dev/null
fi
16 changes: 16 additions & 0 deletions docs/CI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# CI

**Godot:** workflow [`.github/workflows/godot-headless.yml`](../.github/workflows/godot-headless.yml) — self-hosted headless bake. Not a required merge check.

**Preloop:** Cloud flow **DD - Pull Request Reviewer** now includes this repo. It comments on PRs asynchronously. It does **not** block Godot CI.

| Piece | Detail |
|-------|--------|
| Findings | `preloop[bot]` summary + inline comments |
| Surface | [`.github/workflows/preloop-triage.yml`](../.github/workflows/preloop-triage.yml) labels `preloop-triage` |
| Fetch | [`scripts/fetch-preloop-pr.sh`](../scripts/fetch-preloop-pr.sh) |

```bash
./scripts/fetch-preloop-pr.sh 7
gh pr list --label preloop-triage
```
31 changes: 31 additions & 0 deletions scripts/fetch-preloop-pr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
# Fetch Preloop (preloop[bot]) summary + inline review comments for a PR.
set -euo pipefail

PR="${1:-}"
if [[ -z "$PR" || "$PR" == "-h" || "$PR" == "--help" ]]; then
echo "usage: $0 <pr-number>" >&2
exit 2
fi

REPO="${REPO:-}"
if [[ -z "$REPO" ]]; then
REPO="$(gh repo view --json nameWithOwner -q .nameWithOwner 2>/dev/null || true)"
fi
REPO="${REPO:-DynamicDevices/godot-cnc-toolpath}"

echo "=== Preloop on ${REPO}#${PR} ==="
echo
echo "--- summary / issue comments ---"
gh api "repos/${REPO}/issues/${PR}/comments" --paginate \
--jq '.[] | select(.user.login=="preloop[bot]") | "\(.created_at)\n\(.html_url)\n\(.body)\n---"'
echo
echo "--- inline review comments ---"
gh api "repos/${REPO}/pulls/${PR}/comments" --paginate \
--jq '.[] | select(.user.login=="preloop[bot]") | "\(.path):\(.line // .original_line)\n\(.html_url)\n\(.body)\n---"'
echo
echo "--- reviews ---"
gh api "repos/${REPO}/pulls/${PR}/reviews" --paginate \
--jq '.[] | select(.user.login=="preloop[bot]") | "\(.submitted_at) state=\(.state)\n\(.html_url)\n\(.body)\n---"'
echo
echo "Tip: gh pr list --label preloop-triage"