Skip to content

Commit d3ee397

Browse files
claudeondrejmirtes
authored andcommitted
Fix workflow crash: use Claude Code CLI instead of claude-code-action
The claude-code-action is designed for PR/issue event contexts and crashes with workflow_dispatch. Replace with direct Claude Code CLI invocation. https://claude.ai/code/session_01V3YEJggEoR64vLxaJeBFpa
1 parent fa873f9 commit d3ee397

File tree

1 file changed

+85
-64
lines changed

1 file changed

+85
-64
lines changed

.github/workflows/claude-easy-fixes.yml

Lines changed: 85 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
- name: "Checkout"
1919
uses: actions/checkout@v4
2020
with:
21+
ref: "2.1.x"
2122
fetch-depth: 0
2223

2324
- name: "Install PHP"
@@ -55,102 +56,122 @@ jobs:
5556
ISSUE_NUMBER=$(echo "$ISSUE" | jq -r '.number')
5657
ISSUE_TITLE=$(echo "$ISSUE" | jq -r '.title')
5758
ISSUE_URL=$(echo "$ISSUE" | jq -r '.url')
58-
ISSUE_BODY=$(echo "$ISSUE" | jq -r '.body')
59-
6059
echo "issue_number=$ISSUE_NUMBER" >> "$GITHUB_OUTPUT"
6160
echo "issue_title=$ISSUE_TITLE" >> "$GITHUB_OUTPUT"
6261
echo "issue_url=$ISSUE_URL" >> "$GITHUB_OUTPUT"
6362
64-
EOF_MARKER=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
65-
echo "issue_body<<$EOF_MARKER" >> "$GITHUB_OUTPUT"
66-
echo "$ISSUE_BODY" >> "$GITHUB_OUTPUT"
67-
echo "$EOF_MARKER" >> "$GITHUB_OUTPUT"
68-
69-
# Also fetch the first comment (issue body is the first comment)
7063
FIRST_COMMENT_BODY=$(gh issue view "$ISSUE_NUMBER" \
7164
--repo phpstan/phpstan \
7265
--json body \
7366
--jq '.body')
7467
68+
EOF_MARKER=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
7569
echo "first_comment<<$EOF_MARKER" >> "$GITHUB_OUTPUT"
7670
echo "$FIRST_COMMENT_BODY" >> "$GITHUB_OUTPUT"
7771
echo "$EOF_MARKER" >> "$GITHUB_OUTPUT"
7872
7973
echo "### Selected issue: #$ISSUE_NUMBER - $ISSUE_TITLE" >> "$GITHUB_STEP_SUMMARY"
8074
echo "$ISSUE_URL" >> "$GITHUB_STEP_SUMMARY"
8175
82-
- name: "Run Claude Code"
83-
uses: anthropics/claude-code-action@v1
84-
with:
85-
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
86-
github_token: ${{ secrets.GITHUB_TOKEN }}
87-
prompt: |
88-
You are working on phpstan/phpstan-src, the source code of PHPStan - a PHP static analysis tool.
76+
- name: "Install Claude Code"
77+
run: npm install -g @anthropic-ai/claude-code
78+
79+
- name: "Build prompt"
80+
env:
81+
ISSUE_NUMBER: ${{ steps.pick-issue.outputs.issue_number }}
82+
ISSUE_TITLE: ${{ steps.pick-issue.outputs.issue_title }}
83+
ISSUE_URL: ${{ steps.pick-issue.outputs.issue_url }}
84+
ISSUE_BODY: ${{ steps.pick-issue.outputs.first_comment }}
85+
run: |
86+
python3 << 'PYEOF'
87+
import os
8988
90-
Your task is to fix the following GitHub issue from the phpstan/phpstan repository:
91-
Issue #${{ steps.pick-issue.outputs.issue_number }}: ${{ steps.pick-issue.outputs.issue_title }}
92-
URL: ${{ steps.pick-issue.outputs.issue_url }}
89+
n = os.environ["ISSUE_NUMBER"]
90+
title = os.environ["ISSUE_TITLE"]
91+
url = os.environ["ISSUE_URL"]
92+
body = os.environ["ISSUE_BODY"]
9393
94-
Issue body:
95-
${{ steps.pick-issue.outputs.first_comment }}
94+
prompt = f"""You are working on phpstan/phpstan-src, the source code of PHPStan - a PHP static analysis tool.
9695
97-
## Step 1: Retrieve playground code
96+
Your task is to fix the following GitHub issue from the phpstan/phpstan repository:
97+
Issue #{n}: {title}
98+
URL: {url}
9899
99-
From the issue body above, find any referenced PHPStan playground links (URLs matching https://phpstan.org/r/<UUID>).
100+
Issue body:
101+
{body}
100102
101-
For each playground link, extract the UUID and fetch the code and analysis results using the API:
102-
```
103-
curl https://api.phpstan.org/sample?id=<UUID>
104-
```
103+
## Step 1: Retrieve playground code
105104
106-
The API returns JSON with:
107-
- `code`: The PHP code that was analyzed
108-
- `level`: The PHPStan rule level
109-
- `config.strictRules`: Whether strict rules are enabled
110-
- `config.bleedingEdge`: Whether bleeding edge is enabled
111-
- `config.treatPhpDocTypesAsCertain`: PHPDoc type certainty setting
112-
- `versionedErrors`: Array of `{phpVersion, errors: [{line, message, identifier}]}`
105+
From the issue body above, find any referenced PHPStan playground links (URLs matching https://phpstan.org/r/<UUID>).
113106
114-
## Step 2: Write a regression test
107+
For each playground link, extract the UUID and fetch the code and analysis results using the API:
108+
curl https://api.phpstan.org/sample?id=<UUID>
115109
116-
Based on the issue and the playground code:
110+
The API returns JSON with:
111+
- code: The PHP code that was analyzed
112+
- level: The PHPStan rule level
113+
- config.strictRules: Whether strict rules are enabled
114+
- config.bleedingEdge: Whether bleeding edge is enabled
115+
- config.treatPhpDocTypesAsCertain: PHPDoc type certainty setting
116+
- versionedErrors: Array of {{phpVersion, errors: [{{line, message, identifier}}]}}
117117
118-
- If the problem is **only about type inference** (wrong type reported, missing type narrowing, etc.), add a test file in `tests/PHPStan/Analyser/nsrt/` using `assertType()` and `assertNativeType()` calls. Name it `bug-<issue_number>.php`. Look at existing files in that directory for examples.
118+
## Step 2: Write a regression test
119119
120-
- If the problem is about a **rule false positive/negative** (wrong error reported or missing error), add a rule-specific test. Find the relevant rule test case in `tests/PHPStan/Rules/` and add a test data file. Look at existing bug test files in those directories for the pattern.
120+
Based on the issue and the playground code:
121121
122-
The regression test **should fail** without the fix - verify this by running it before implementing the fix.
122+
- If the problem is only about type inference (wrong type reported, missing type narrowing, etc.), add a test file in tests/PHPStan/Analyser/nsrt/ using assertType() and assertNativeType() calls. Name it bug-{n}.php. Look at existing files in that directory for examples.
123123
124-
Run individual test files with: `php vendor/bin/phpunit <test-file>`
125-
Run all tests with: `make tests`
126-
Run PHPStan with: `make phpstan`
124+
- If the problem is about a rule false positive/negative (wrong error reported or missing error), add a rule-specific test. Find the relevant rule test case in tests/PHPStan/Rules/ and add a test data file. Look at existing bug test files in those directories for the pattern.
127125
128-
## Step 3: Fix the bug
126+
The regression test should fail without the fix - verify this by running it before implementing the fix.
129127
130-
Implement the fix in the source code under `src/`. Common areas to look:
131-
- `src/Analyser/NodeScopeResolver.php` - AST traversal and scope management
132-
- `src/Analyser/MutatingScope.php` - Type tracking
133-
- `src/Analyser/TypeSpecifier.php` - Type narrowing from conditions
134-
- `src/Type/` - Type system implementations
135-
- `src/Rules/` - Rule implementations
136-
- `src/Reflection/` - Reflection layer
128+
Run individual test files with: php vendor/bin/phpunit <test-file>
129+
Run all tests with: make tests
130+
Run PHPStan with: make phpstan
137131
138-
Read CLAUDE.md for important guidelines about the codebase architecture and common patterns.
132+
## Step 3: Fix the bug
139133
140-
## Step 4: Verify the fix
134+
Implement the fix in the source code under src/. Common areas to look:
135+
- src/Analyser/NodeScopeResolver.php - AST traversal and scope management
136+
- src/Analyser/MutatingScope.php - Type tracking
137+
- src/Analyser/TypeSpecifier.php - Type narrowing from conditions
138+
- src/Type/ - Type system implementations
139+
- src/Rules/ - Rule implementations
140+
- src/Reflection/ - Reflection layer
141141
142-
1. Run the regression test to confirm it passes now
143-
2. Run the full test suite: `make tests`
144-
3. Run PHPStan self-analysis: `make phpstan`
145-
4. Fix any failures that come up
142+
Read CLAUDE.md for important guidelines about the codebase architecture and common patterns.
146143
147-
## Step 5: Create a branch and PR
144+
## Step 4: Verify the fix
145+
146+
1. Run the regression test to confirm it passes now
147+
2. Run the full test suite: make tests
148+
3. Run PHPStan self-analysis: make phpstan
149+
4. Fix any failures that come up
150+
151+
## Step 5: Create a branch and PR
152+
153+
1. Create a branch named fix/bug-{n}
154+
2. Commit all changes with message: "Fix #{n}"
155+
3. Push the branch
156+
4. Create a PR targeting the 2.1.x branch with:
157+
- Title: "Fix #{n}: {title}"
158+
- Body referencing the issue: "Fixes phpstan/phpstan#{n}"
159+
- Include a description of the fix and what was wrong
160+
"""
161+
162+
with open("/tmp/claude-prompt.txt", "w") as f:
163+
f.write(prompt)
164+
PYEOF
165+
166+
- name: "Run Claude Code"
167+
env:
168+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
169+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
170+
run: |
171+
git config user.name "github-actions[bot]"
172+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
148173
149-
1. Create a branch named `fix/bug-${{ steps.pick-issue.outputs.issue_number }}`
150-
2. Commit all changes with message: "Fix #${{ steps.pick-issue.outputs.issue_number }}"
151-
3. Push the branch
152-
4. Create a PR targeting the `2.1.x` branch with:
153-
- Title: "Fix #${{ steps.pick-issue.outputs.issue_number }}: ${{ steps.pick-issue.outputs.issue_title }}"
154-
- Body referencing the issue: "Fixes phpstan/phpstan#${{ steps.pick-issue.outputs.issue_number }}"
155-
- Include a description of the fix and what was wrong
156-
claude_args: "--model claude-opus-4-6 --max-turns 50"
174+
claude -p \
175+
--model claude-opus-4-6 \
176+
--max-turns 50 \
177+
"$(cat /tmp/claude-prompt.txt)"

0 commit comments

Comments
 (0)