ci: trigger review-gate on self-review comments; run heavy review on issue_comment when reason=='self-review'
CI / review-gate (pull_request) Failing after 1s
PR Ready Gate / clear-labels (pull_request) Successful in 1s
CI / review (anthropic--claude-4.6-sonnet, sonnet, SONNET_REVIEW_TOKEN) (pull_request) Has been skipped
CI / review (gpt-5, gpt, GPT_REVIEW_TOKEN) (pull_request) Has been skipped
CI / review (gpt-5, security, ., rodin/security-patterns, SECURITY_REVIEW.md, SECURITY_REVIEW_TOKEN) (pull_request) Has been skipped
CI / test (pull_request) Successful in 28s
CI / review-gate (pull_request) Failing after 1s
PR Ready Gate / clear-labels (pull_request) Successful in 1s
CI / review (anthropic--claude-4.6-sonnet, sonnet, SONNET_REVIEW_TOKEN) (pull_request) Has been skipped
CI / review (gpt-5, gpt, GPT_REVIEW_TOKEN) (pull_request) Has been skipped
CI / review (gpt-5, security, ., rodin/security-patterns, SECURITY_REVIEW.md, SECURITY_REVIEW_TOKEN) (pull_request) Has been skipped
CI / test (pull_request) Successful in 28s
This commit is contained in:
+23
-9
@@ -5,6 +5,8 @@ on:
|
|||||||
branches: [main]
|
branches: [main]
|
||||||
pull_request:
|
pull_request:
|
||||||
types: [opened, synchronize]
|
types: [opened, synchronize]
|
||||||
|
issue_comment:
|
||||||
|
types: [created, edited]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
SELF_REVIEW_TTL_MIN: '45'
|
SELF_REVIEW_TTL_MIN: '45'
|
||||||
@@ -12,6 +14,7 @@ env:
|
|||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
|
if: github.event_name == 'pull_request'
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-go@v5
|
- uses: actions/setup-go@v5
|
||||||
@@ -23,7 +26,7 @@ jobs:
|
|||||||
|
|
||||||
review-gate:
|
review-gate:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
if: github.event_name == 'pull_request'
|
if: github.event_name == 'pull_request' || (github.event_name == 'issue_comment' && github.event.issue.pull_request)
|
||||||
outputs:
|
outputs:
|
||||||
allow_review: ${{ steps.gate.outputs.allow_review }}
|
allow_review: ${{ steps.gate.outputs.allow_review }}
|
||||||
reason: ${{ steps.gate.outputs.reason }}
|
reason: ${{ steps.gate.outputs.reason }}
|
||||||
@@ -35,19 +38,23 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
REPO=${{ github.repository }}
|
REPO=${{ github.repository }}
|
||||||
PR=${{ github.event.pull_request.number }}
|
|
||||||
SHA=${{ github.event.pull_request.head.sha }}
|
|
||||||
TTL_MIN=${SELF_REVIEW_TTL_MIN}
|
|
||||||
API="${{ github.server_url }}/api/v1"
|
API="${{ github.server_url }}/api/v1"
|
||||||
|
if [ "${GITHUB_EVENT_NAME}" = "issue_comment" ]; then
|
||||||
|
PR=${{ github.event.issue.number }}
|
||||||
|
else
|
||||||
|
PR=${{ github.event.pull_request.number }}
|
||||||
|
fi
|
||||||
|
# Get head SHA from PR JSON (works for both events)
|
||||||
PR_JSON=$(curl -sS -H "Authorization: token $GITEA_TOKEN" "$API/repos/$REPO/pulls/$PR")
|
PR_JSON=$(curl -sS -H "Authorization: token $GITEA_TOKEN" "$API/repos/$REPO/pulls/$PR")
|
||||||
|
SHA=$(echo "$PR_JSON" | jq -r .head.sha)
|
||||||
UPDATED_AT=$(echo "$PR_JSON" | jq -r .updated_at)
|
UPDATED_AT=$(echo "$PR_JSON" | jq -r .updated_at)
|
||||||
NOW=$(date -u +%s)
|
NOW=$(date -u +%s)
|
||||||
PR_TS=$(date -u -d "$UPDATED_AT" +%s)
|
PR_TS=$(date -u -d "$UPDATED_AT" +%s)
|
||||||
AGE_MIN=$(( (NOW - PR_TS) / 60 ))
|
AGE_MIN=$(( (NOW - PR_TS) / 60 ))
|
||||||
|
TTL_MIN=${SELF_REVIEW_TTL_MIN}
|
||||||
|
|
||||||
COMMENTS=$(curl -sS -H "Authorization: token $GITEA_TOKEN" "$API/repos/$REPO/issues/$PR/comments?limit=200")
|
COMMENTS=$(curl -sS -H "Authorization: token $GITEA_TOKEN" "$API/repos/$REPO/issues/$PR/comments?limit=200")
|
||||||
HAS_SR=$(echo "$COMMENTS" | jq -r --arg sha "$SHA" '[.[] | select(.user.login=="rodin") | select(.body|contains("Self-review against "+$sha)) | select(.body|test("(?im)^###\\s+Doc consistency\\b"))] | length')
|
HAS_SR=$(echo "$COMMENTS" | jq -r --arg sha "$SHA" '[.[] | select(.user.login=="rodin") | select(.body|contains("Self-review against "+$sha)) | select(.body|test("(?im)^###\s+Doc consistency\b"))] | length')
|
||||||
|
|
||||||
if [ "$HAS_SR" -gt 0 ]; then
|
if [ "$HAS_SR" -gt 0 ]; then
|
||||||
ALLOW=true
|
ALLOW=true
|
||||||
@@ -65,8 +72,8 @@ jobs:
|
|||||||
|
|
||||||
review:
|
review:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
if: github.event_name == 'pull_request' && needs.review-gate.outputs.reason == 'self-review'
|
if: needs.review-gate.outputs.reason == 'self-review' && (github.event_name == 'pull_request' || github.event_name == 'issue_comment')
|
||||||
needs: [test, review-gate]
|
needs: [review-gate]
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
@@ -88,11 +95,18 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
go-version: '1.26'
|
go-version: '1.26'
|
||||||
- run: go build -o review-bot ./cmd/review-bot
|
- run: go build -o review-bot ./cmd/review-bot
|
||||||
|
- name: Set PR_NUMBER for event type
|
||||||
|
run: |
|
||||||
|
if [ "${GITHUB_EVENT_NAME}" = "issue_comment" ]; then
|
||||||
|
echo "PR_NUMBER=${{ github.event.issue.number }}" >> $GITHUB_ENV
|
||||||
|
else
|
||||||
|
echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV
|
||||||
|
fi
|
||||||
- name: Run ${{ matrix.name }} review
|
- name: Run ${{ matrix.name }} review
|
||||||
env:
|
env:
|
||||||
VCS_URL: ${{ github.server_url }}
|
VCS_URL: ${{ github.server_url }}
|
||||||
GITEA_REPO: ${{ github.repository }}
|
GITEA_REPO: ${{ github.repository }}
|
||||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
PR_NUMBER: ${{ env.PR_NUMBER }}
|
||||||
REVIEWER_TOKEN: ${{ secrets[matrix.token_secret] }}
|
REVIEWER_TOKEN: ${{ secrets[matrix.token_secret] }}
|
||||||
REVIEWER_NAME: ${{ matrix.name }}
|
REVIEWER_NAME: ${{ matrix.name }}
|
||||||
LLM_PROVIDER: aicore
|
LLM_PROVIDER: aicore
|
||||||
|
|||||||
Reference in New Issue
Block a user