Skip to content

Commit 3a51a14

Browse files
craig[bot]ajstorm
andcommitted
Merge #155233
155233: dev-inf: Fix stage chaining in Claude Code GH action r=rickystewart a=ajstorm The claude-code-action doesn't export a 'result' output variable. Added extraction steps between each stage to: 1. Read the execution_file output from each stage 2. Parse the JSON to extract the result field 3. Set it as an output for the next stage's conditional This fixes the issue where Stage 2 and Stage 3 were being skipped even when bugs were detected in earlier stages. Epic: none Release note: none Co-authored-by: Adam Storm <storm@cockroachlabs.com>
2 parents ae63fac + 546e58c commit 3a51a14

File tree

1 file changed

+57
-9
lines changed

1 file changed

+57
-9
lines changed

.github/workflows/pr-analyzer-threestage.yml

Lines changed: 57 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,21 @@ jobs:
6262
- `STAGE1_RESULT - POTENTIAL_BUG_DETECTED` or
6363
- `STAGE1_RESULT - NO_BUG_FOUND`
6464
65+
- name: Extract Stage 1 Result
66+
id: stage1_result
67+
if: steps.stage1.conclusion == 'success'
68+
run: |
69+
RESULT=$(jq -r 'select(.type == "result") | .result' "${{ steps.stage1.outputs.execution_file }}")
70+
{
71+
echo 'result<<EOF'
72+
echo "$RESULT"
73+
echo 'EOF'
74+
} >> "$GITHUB_OUTPUT"
75+
echo "Stage 1 result extracted (${#RESULT} characters)"
76+
6577
- name: Stage 2 - Database Expert Review
6678
id: stage2
67-
if: contains(steps.stage1.outputs.result, 'STAGE1_RESULT - POTENTIAL_BUG_DETECTED')
79+
if: contains(steps.stage1_result.outputs.result, 'STAGE1_RESULT - POTENTIAL_BUG_DETECTED')
6880
uses: cockroachdb/claude-code-action@v1
6981
env:
7082
ANTHROPIC_VERTEX_PROJECT_ID: vertex-model-runners
@@ -83,7 +95,7 @@ jobs:
8395
found potential issues. Your job is to confirm or reject those findings.
8496
8597
**Stage 1 Results**:
86-
${{ steps.stage1.outputs.result }}
98+
${{ steps.stage1_result.outputs.result }}
8799
88100
Review the Stage 1 findings and perform your own analysis. Do not identify
89101
new bugs unless they're glaringly obvious.
@@ -100,9 +112,21 @@ jobs:
100112
- `STAGE2_RESULT - POTENTIAL_BUG_DETECTED [detailed description of confirmed bugs]` or
101113
- `STAGE2_RESULT - NO_BUG_FOUND`
102114
115+
- name: Extract Stage 2 Result
116+
id: stage2_result
117+
if: steps.stage2.conclusion == 'success'
118+
run: |
119+
RESULT=$(jq -r 'select(.type == "result") | .result' "${{ steps.stage2.outputs.execution_file }}")
120+
{
121+
echo 'result<<EOF'
122+
echo "$RESULT"
123+
echo 'EOF'
124+
} >> "$GITHUB_OUTPUT"
125+
echo "Stage 2 result extracted (${#RESULT} characters)"
126+
103127
- name: Stage 3 - Principal Engineer Final Review
104128
id: stage3
105-
if: contains(steps.stage2.outputs.result, 'STAGE2_RESULT - POTENTIAL_BUG_DETECTED')
129+
if: contains(steps.stage2_result.outputs.result, 'STAGE2_RESULT - POTENTIAL_BUG_DETECTED')
106130
uses: cockroachdb/claude-code-action@v1
107131
env:
108132
ANTHROPIC_VERTEX_PROJECT_ID: vertex-model-runners
@@ -121,10 +145,10 @@ jobs:
121145
Two previous stages have found potential issues that need final validation.
122146
123147
**Stage 1 Results**:
124-
${{ steps.stage1.outputs.result }}
148+
${{ steps.stage1_result.outputs.result }}
125149
126150
**Stage 2 Results**:
127-
${{ steps.stage2.outputs.result }}
151+
${{ steps.stage2_result.outputs.result }}
128152
129153
This is the final gate before flagging this PR as having critical bugs.
130154
Only confirm bugs that could cause:
@@ -153,6 +177,18 @@ jobs:
153177
- `STAGE3_RESULT: POTENTIAL_BUG_CONFIRMED` or
154178
- `STAGE3_RESULT: NO_BUG_FOUND`
155179
180+
- name: Extract Stage 3 Result
181+
id: stage3_result
182+
if: steps.stage3.conclusion == 'success'
183+
run: |
184+
RESULT=$(jq -r 'select(.type == "result") | .result' "${{ steps.stage3.outputs.execution_file }}")
185+
{
186+
echo 'result<<EOF'
187+
echo "$RESULT"
188+
echo 'EOF'
189+
} >> "$GITHUB_OUTPUT"
190+
echo "Stage 3 result extracted (${#RESULT} characters)"
191+
156192
- name: Final Analysis Report
157193
if: always()
158194
uses: cockroachdb/claude-code-action@v1
@@ -173,9 +209,9 @@ jobs:
173209
174210
Generate a final summary report based on the completed analysis stages:
175211
176-
**Stage 1 Result**: ${{ steps.stage1.outputs.result || 'Not completed' }}
177-
**Stage 2 Result**: ${{ steps.stage2.outputs.result || 'Skipped - Stage 1 found no bugs' }}
178-
**Stage 3 Result**: ${{ steps.stage3.outputs.result || 'Skipped - Stage 2 did not confirm bugs' }}
212+
**Stage 1 Result**: ${{ steps.stage1_result.outputs.result || 'Not completed' }}
213+
**Stage 2 Result**: ${{ steps.stage2_result.outputs.result || 'Skipped - Stage 1 found no bugs' }}
214+
**Stage 3 Result**: ${{ steps.stage3_result.outputs.result || 'Skipped - Stage 2 did not confirm bugs' }}
179215
180216
**Analysis Process**:
181217
- Stage 1 (Initial Screening): ${{ steps.stage1.conclusion }}
@@ -187,4 +223,16 @@ jobs:
187223
2. The final determination (critical bug found or no critical bugs)
188224
3. If bugs were found, what actions are recommended
189225
190-
**If all three stages detected bugs**, this indicates a potential issue that warrants investigation.
226+
**If all three stages detected bugs**, this indicates a potential issue that warrants investigation.
227+
228+
- name: Comment on PR if bugs confirmed
229+
if: contains(steps.stage3_result.outputs.result, 'STAGE3_RESULT: POTENTIAL_BUG_CONFIRMED')
230+
env:
231+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
232+
run: |
233+
gh pr comment ${{ github.event.pull_request.number }} --body "## Potential Bug(s) Detected
234+
235+
The three-stage Claude Code analysis has identified potential bug(s) in this PR that may warrant investigation.
236+
237+
**Next Steps:**
238+
Please review the detailed findings in the [workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})."

0 commit comments

Comments
 (0)