Skip to content
Merged
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
3 changes: 1 addition & 2 deletions .github/pi-review.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
"exclude": []
},
"pi": {
"version": "1.5.2",
"packageRef": "1185c5abc5c241f5b5e6cd322c8495996fff7b7a"
"version": "1.5.2"
},
"timeoutMinutes": 20
}
191 changes: 12 additions & 179 deletions .github/workflows/pi-review.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
# Generated by pi-review from .github/pi-review.json
# Edit the settings file, not this workflow.
#
# The `user.type != 'Bot'` guards mirror triggers.skipBots in the settings file. They are
# hand-mirrored because the generator lives in AutumnsGrove/pi-extensions: a Dependabot pull
# request runs with no secrets, so the reviewer cannot mint its app token and fails before it
# reaches a single line of the diff. Regenerating from pi-review.json produces the same guard.

# Edit the settings file, not this workflow. The job lives once, in
# AutumnsGrove/pi-extensions/.github/workflows/pi-review-reusable.yml, and runs from @main,
# so a fix there reaches this repository without a commit here.
name: pi-review

on:
Expand All @@ -16,7 +12,7 @@ on:

concurrency:
group: >-
${{ (((github.event.pull_request.draft == false && github.event.pull_request.user.type != 'Bot' && github.event.pull_request.head.repo.full_name == github.repository) || (github.event_name == 'issue_comment' && github.event.issue.pull_request != null && contains(github.event.comment.body, '@pi') && contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association) && github.event.comment.user.type != 'Bot')))
${{ (((github.event.pull_request.draft == false && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.user.type != 'Bot') || (github.event_name == 'issue_comment' && github.event.issue.pull_request != null && contains(github.event.comment.body, '@pi') && contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association) && github.event.comment.user.type != 'Bot')))
&& format('pi-review-{0}', github.event.pull_request.number || github.event.issue.number)
|| format('pi-review-ignored-{0}', github.run_id) }}
cancel-in-progress: true
Expand All @@ -28,174 +24,11 @@ permissions:

jobs:
review:
if: (github.event.pull_request.draft == false && github.event.pull_request.user.type != 'Bot' && github.event.pull_request.head.repo.full_name == github.repository) || (github.event_name == 'issue_comment' && github.event.issue.pull_request != null && contains(github.event.comment.body, '@pi') && contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association) && github.event.comment.user.type != 'Bot')
runs-on: ubuntu-latest
timeout-minutes: 33
steps:
- uses: actions/checkout@v7
with:
ref: refs/pull/${{ github.event.pull_request.number || github.event.issue.number }}/merge
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-node@v7
with:
node-version: "22"
- name: Restore the dependency cache
uses: actions/cache@v6
with:
path: |
~/.npm
~/.local/share/pnpm/store
~/.cache/pip
~/.cache/uv
~/go/pkg/mod
~/.cargo/registry
~/.cargo/git
~/.bundle
~/.nuget/packages
~/.composer/cache
key: pi-review-deps-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml', 'package-lock.json', 'yarn.lock', 'bun.lock', 'bun.lockb', 'uv.lock', 'poetry.lock', 'Pipfile.lock', 'requirements.txt', 'go.sum', 'Cargo.lock', 'Gemfile.lock', 'composer.lock') }}
restore-keys: |
pi-review-deps-${{ runner.os }}-
- name: Install dependencies
id: deps
continue-on-error: true
timeout-minutes: 8
run: |
set -uo pipefail
echo "PI_REVIEW_DEPS=unavailable" >> "$GITHUB_ENV"
failed=0
found=0
run() { if ! "$@"; then failed=1; fi; }
if [ -f pnpm-lock.yaml ]; then
found=1; run corepack pnpm install --frozen-lockfile --prefer-offline
elif [ -f package-lock.json ]; then
found=1; run npm ci --prefer-offline --no-audit --no-fund
elif [ -f yarn.lock ]; then
found=1
if corepack yarn --version | grep -q '^1\.'; then
run corepack yarn install --frozen-lockfile
else
run corepack yarn install --immutable
fi
elif [ -f bun.lock ] || [ -f bun.lockb ]; then
found=1; run npm install -g bun; run bun install --frozen-lockfile
fi
if [ -f uv.lock ]; then
found=1
if ! command -v uv >/dev/null 2>&1; then curl -LsSf https://astral.sh/uv/install.sh | sh; export PATH="$HOME/.local/bin:$PATH"; fi
run uv sync --frozen
fi
if [ -f poetry.lock ]; then found=1; run python3 -m pip install --user --quiet poetry; run poetry install --no-interaction; fi
if [ -f Pipfile.lock ]; then found=1; run python3 -m pip install --user --quiet pipenv; run pipenv sync; fi
if [ -f requirements.txt ]; then found=1; run python3 -m pip install -r requirements.txt; fi
if [ -f pyproject.toml ] && [ ! -f uv.lock ] && [ ! -f poetry.lock ]; then found=1; run python3 -m pip install -e .; fi
if [ -f go.mod ]; then found=1; run go mod download; fi
if [ -f Cargo.toml ]; then found=1; run cargo fetch; fi
if [ -f Gemfile.lock ]; then found=1; run bundle install; fi
if [ -f composer.lock ]; then found=1; run composer install --no-interaction; fi
if ls *.sln >/dev/null 2>&1; then found=1; run dotnet restore; fi
if [ "$failed" -ne 0 ]; then
echo "::warning::Some dependency installs failed; the reviewer will be told tests may not run."
exit 1
fi
if [ "$found" -eq 0 ]; then
echo "PI_REVIEW_DEPS=none" >> "$GITHUB_ENV"
exit 0
fi
echo "PI_REVIEW_DEPS=installed" >> "$GITHUB_ENV"
- name: Install pi
run: npm install -g @earendil-works/pi-coding-agent@1.5.2
- name: Check out pi-review
run: |
set -euo pipefail
git init "$RUNNER_TEMP/pi-review-src"
git -C "$RUNNER_TEMP/pi-review-src" remote add origin https://github.com/AutumnsGrove/pi-extensions.git
git -C "$RUNNER_TEMP/pi-review-src" fetch --depth 1 origin '1185c5abc5c241f5b5e6cd322c8495996fff7b7a'
git -C "$RUNNER_TEMP/pi-review-src" checkout --detach FETCH_HEAD
- name: Require a same-repo pull request
if: github.event_name == 'issue_comment'
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.issue.number }}
run: |
set -euo pipefail
head=$(gh pr view "$PR_NUMBER" --json headRepository --jq '.headRepository.nameWithOwner')
if [ "$head" != "${{ github.repository }}" ]; then
echo "::error::pi-review only reviews pull requests from this repository"
exit 1
fi
- name: Mint the App token
id: app-token
uses: actions/create-github-app-token@v3
with:
app-id: ${{ secrets.PI_REVIEW_APP_ID }}
private-key: ${{ secrets.PI_REVIEW_APP_PRIVATE_KEY }}
- name: Review
timeout-minutes: 20
env:
PI_REVIEW: "1"
PR_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }}
GH_TOKEN: ${{ steps.app-token.outputs.token || github.token }}
OPENCODE_API_KEY: ${{ secrets.PI_REVIEW_API_KEY }}
PI_REVIEW_REQUEST: ${{ github.event.comment.body }}
PI_REVIEW_OUTPUT: ${{ runner.temp }}/pi-review/review.json
PI_REVIEW_MAX_COMMENTS: "25"
PI_REVIEW_REQUEST_CHANGES: "0"
PI_REVIEW_STRICTNESS: "significant"
PI_REVIEW_RESOLVE_THREADS: "0"
run: |
set -euo pipefail
mkdir -p "$(dirname "$PI_REVIEW_OUTPUT")"
pi \
-p \
--mode json \
--no-session \
-na \
-nc \
--offline \
-ne \
-e "$RUNNER_TEMP/pi-review-src/extensions/pi-review/index.ts" \
-ns \
-np \
--no-themes \
--no-mcp \
--tools read,grep,find,ls,bash,submit_review \
--provider opencode-go \
--model deepseek-v4.1-flash \
--thinking high \
"Review pull request #$PR_NUMBER." \
| tee "$RUNNER_TEMP/pi-review/events.jsonl"
if [ ! -f "$PI_REVIEW_OUTPUT" ]; then
echo "::error::pi-review wrote no review artifact"
exit 1
fi
if grep -q '"incomplete": true' "$PI_REVIEW_OUTPUT"; then
echo "::error::pi-review finished without submitting a review"
exit 1
fi
- name: Step summary
if: always()
env:
PI_REVIEW_OUTPUT: ${{ runner.temp }}/pi-review/review.json
run: |
{
echo "## pi-review"
echo
if [ -f "$PI_REVIEW_OUTPUT" ]; then
jq -r '"**" + (.review.event // "incomplete") + "** · inline comments: " + (((.review.comments // []) | length) | tostring) + (if .url then " · " + .url else "" end) + (if .error then " · error: " + .error else "" end)' "$PI_REVIEW_OUTPUT" || echo "Unreadable artifact."
else
echo "No review artifact: the review did not complete."
fi
} >> "$GITHUB_STEP_SUMMARY"
- name: Report an incomplete review
if: failure()
env:
GH_TOKEN: ${{ steps.app-token.outputs.token || github.token }}
PR_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }}
PI_REVIEW_OUTPUT: ${{ runner.temp }}/pi-review/review.json
run: |
if [ -f "$PI_REVIEW_OUTPUT" ] && ! grep -q '"incomplete": true' "$PI_REVIEW_OUTPUT"; then
exit 0
fi
gh pr comment "$PR_NUMBER" --body "pi-review could not complete this review: the job failed or timed out. Fix the cause and re-run the workflow." || true
if: (github.event.pull_request.draft == false && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.user.type != 'Bot') || (github.event_name == 'issue_comment' && github.event.issue.pull_request != null && contains(github.event.comment.body, '@pi') && contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association) && github.event.comment.user.type != 'Bot')
uses: AutumnsGrove/pi-extensions/.github/workflows/pi-review-reusable.yml@main
with:
settings-path: '.github/pi-review.json'
review-timeout-minutes: 20
job-timeout-minutes: 33
install-dependencies: true
secrets: inherit
Loading