-
Notifications
You must be signed in to change notification settings - Fork 42
134 lines (124 loc) · 6.08 KB
/
Copy pathpr-review.yml
File metadata and controls
134 lines (124 loc) · 6.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: PR Review
# Installs @ag-grid/dev-prompts from GitHub Packages and delegates to the
# composite actions shipped inside the package. This is the consumer
# counterpart to ag-grid/ag-dev-prompts's own dogfood workflow.
#
# Why npm instead of a reusable workflow: ag-dev-prompts is a private repo,
# and GitHub Actions does not permit public-repo callers to consume
# reusable workflows from private-repo hosts. The npm package route works
# because GitHub Packages honours `GITHUB_TOKEN` + `packages: read` from any
# repo in the same org, regardless of visibility.
#
# Channel: ag-charts tracks `canary` during the in-flight AG-17085
# rollout. ag-grid and ag-studio track `latest`.
on:
pull_request:
types: [opened, ready_for_review]
issue_comment:
types: [created]
workflow_dispatch:
inputs:
pr_number:
description: 'PR number to review'
type: string
required: true
driver:
description: 'Review engine. explore is the default; claude and codex are deprecated. See ag-dev-prompts docs/installation.md.'
type: choice
options: [explore, claude, codex]
default: explore
required: false
quiet:
description: 'Quiet/soak mode: post nothing to the PR; upload the review as an artifact (pr-review-<driver>-<pr#>) instead. Use to compare drivers without touching the PR.'
type: boolean
default: false
required: false
permissions:
contents: read
env:
# Disable git's post-fetch background gc/maintenance for every git invocation
# (injected via git's GIT_CONFIG_* protocol). Otherwise it rewrites .git/shallow
# concurrently with the next chained `git fetch --depth 1`, intermittently failing
# job setup with "fatal: shallow file has changed since we read it".
GIT_CONFIG_COUNT: 2
GIT_CONFIG_KEY_0: gc.auto
GIT_CONFIG_VALUE_0: '0'
GIT_CONFIG_KEY_1: maintenance.auto
GIT_CONFIG_VALUE_1: 'false'
DEV_PROMPTS_CHANNEL: canary
jobs:
review:
runs-on: ubuntu-latest
# Top-level gating — keeps the runner from spinning up at all for
# events that would only short-circuit at a step-level `if:`:
# - pull_request: same-repo, non-draft (forks also blocked inside
# pr-resolve-metadata as a second line of defence).
# - issue_comment: must be on a PR AND start with /pr-review.
# - workflow_dispatch: always eligible (caller has actions:write).
if: |
(github.event_name == 'pull_request' &&
github.event.pull_request.draft == false &&
github.event.pull_request.head.repo.full_name == github.repository) ||
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'issue_comment' &&
github.event.issue.pull_request != null &&
startsWith(github.event.comment.body, '/pr-review'))
permissions:
contents: read
pull-requests: write
issues: write
actions: write
packages: read
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 1
- name: Setup Node (GitHub Packages for @ag-grid scope)
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version-file: package.json
registry-url: https://npm.pkg.github.com
scope: '@ag-grid'
- name: Install @ag-grid/dev-prompts
env:
NODE_AUTH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
mkdir -p "$GITHUB_WORKSPACE/.ag-dev-prompts"
cd "$GITHUB_WORKSPACE/.ag-dev-prompts"
echo '{"name":"ag-dev-prompts-install","private":true}' > package.json
npm install --no-save --silent "@ag-grid/dev-prompts@${DEV_PROMPTS_CHANNEL}"
# --- Comment trigger path (/pr-review) -----------------------------
- name: Handle /pr-review comment
if: github.event_name == 'issue_comment' && github.event.issue.pull_request
uses: ./.ag-dev-prompts/node_modules/@ag-grid/dev-prompts/.github/actions/pr-review-comment-trigger
with:
github-token: ${{ github.token }}
# --- Review path (pull_request + workflow_dispatch) ---------------
- name: Resolve PR metadata
id: pr-meta
if: |
(github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository) ||
github.event_name == 'workflow_dispatch'
uses: ./.ag-dev-prompts/node_modules/@ag-grid/dev-prompts/.github/actions/pr-resolve-metadata
with:
github-token: ${{ github.token }}
pr-number: ${{ github.event.pull_request.number || inputs.pr_number }}
- name: Run Codex PR Review
if: steps.pr-meta.outputs.pr-number != ''
uses: ./.ag-dev-prompts/node_modules/@ag-grid/dev-prompts/.github/actions/codex-pr-review
with:
codex-api-key: ${{ secrets.CODEX_API_KEY }}
pr-number: ${{ steps.pr-meta.outputs.pr-number }}
base-ref: ${{ steps.pr-meta.outputs.base-ref }}
head-ref: ${{ steps.pr-meta.outputs.head-ref }}
pr-title: ${{ steps.pr-meta.outputs.pr-title }}
pr-author: ${{ steps.pr-meta.outputs.pr-author }}
github-token: ${{ github.token }}
inline-comments: 'true'
dev-prompts-version: ${{ env.DEV_PROMPTS_CHANNEL }}
# See ag-dev-prompts docs/installation.md.
driver: ${{ inputs.driver || 'explore' }}
quiet: ${{ inputs.quiet || 'false' }}