Skip to content

Commit e80de69

Browse files
committed
Improve regression-tests workflow
1 parent 5d03710 commit e80de69

2 files changed

Lines changed: 91 additions & 138 deletions

File tree

.github/workflows/claude-regression-tests.yml

Lines changed: 0 additions & 137 deletions
This file was deleted.

.github/workflows/issue-bot.yml

Lines changed: 91 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,25 @@ jobs:
192192
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
193193
run: |
194194
set +e
195-
./console.php evaluate >> $GITHUB_STEP_SUMMARY
195+
./console.php evaluate > tmp/step-summary.md
196196
exit_code="$?"
197197
198+
cat tmp/step-summary.md >> $GITHUB_STEP_SUMMARY
199+
198200
if [[ "$exit_code" == "2" ]]; then
199201
echo "::notice file=.github/workflows/issue-bot.yml,line=3 ::Issue bot detected open issues which are affected by this pull request - see https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
200202
exit 0
201203
fi
202204
203205
exit $exit_code
204206
207+
- name: "Upload step summary"
208+
if: github.event_name == 'pull_request'
209+
uses: actions/upload-artifact@v4
210+
with:
211+
name: step-summary
212+
path: issue-bot/tmp/step-summary.md
213+
205214
- name: "Evaluate results - push"
206215
working-directory: "issue-bot"
207216
if: "github.repository_owner == 'phpstan' && github.ref == 'refs/heads/2.1.x'"
@@ -220,3 +229,84 @@ jobs:
220229
fi
221230
222231
exit $exit_code
232+
233+
regression-tests:
234+
name: "Generate regression tests"
235+
needs: evaluate
236+
if: github.event_name == 'pull_request' && github.event.pull_request.user.login == 'phpstan-bot'
237+
runs-on: blacksmith-4vcpu-ubuntu-2404
238+
timeout-minutes: 60
239+
240+
steps:
241+
- name: "Check for feedback loop"
242+
id: check
243+
env:
244+
GH_TOKEN: ${{ secrets.PHPSTAN_BOT_TOKEN }}
245+
run: |
246+
COMMIT_MSG=$(gh api "repos/${{ github.repository }}/commits/${{ github.event.pull_request.head.sha }}" --jq '.commit.message' 2>/dev/null || true)
247+
if [[ "$COMMIT_MSG" == "Add regression test for #"* ]]; then
248+
echo "Last commit was regression test addition, skipping"
249+
echo "skip=true" >> "$GITHUB_OUTPUT"
250+
else
251+
echo "skip=false" >> "$GITHUB_OUTPUT"
252+
fi
253+
254+
- name: "Checkout"
255+
if: steps.check.outputs.skip != 'true'
256+
uses: actions/checkout@v4
257+
with:
258+
ref: ${{ github.head_ref }}
259+
fetch-depth: 0
260+
token: ${{ secrets.PHPSTAN_BOT_TOKEN }}
261+
262+
- name: "Download step summary"
263+
if: steps.check.outputs.skip != 'true'
264+
uses: actions/download-artifact@v4
265+
with:
266+
name: step-summary
267+
path: ./tmp
268+
269+
- name: "Install PHP"
270+
if: steps.check.outputs.skip != 'true'
271+
uses: "shivammathur/setup-php@v2"
272+
with:
273+
coverage: "none"
274+
php-version: "8.4"
275+
ini-file: development
276+
extensions: mbstring
277+
278+
- name: "Install dependencies"
279+
if: steps.check.outputs.skip != 'true'
280+
uses: "ramsey/composer-install@v3"
281+
282+
- name: "Install Claude Code"
283+
if: steps.check.outputs.skip != 'true'
284+
run: npm install -g @anthropic-ai/claude-code
285+
286+
- name: "Generate regression tests"
287+
if: steps.check.outputs.skip != 'true'
288+
env:
289+
CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
290+
GH_TOKEN: ${{ secrets.PHPSTAN_BOT_TOKEN }}
291+
run: |
292+
git config user.name "phpstan-bot"
293+
git config user.email "ondrej+phpstanbot@mirtes.cz"
294+
295+
claude -p \
296+
--model claude-opus-4-6 \
297+
--output-format stream-json \
298+
--verbose \
299+
--dangerously-skip-permissions \
300+
"Read the file ./tmp/step-summary.md which contains the Issue Bot step summary from CI in Markdown format. Interpret this Markdown to figure out which GitHub issues need regression tests added. For each affected issue (where behavior changed), run /regression-test with the issue number.
301+
302+
Do not create a branch or push - this will be handled automatically."
303+
304+
- name: "Push"
305+
if: steps.check.outputs.skip != 'true'
306+
run: |
307+
if [ "$(git rev-parse HEAD)" = "$(git rev-parse @{u})" ]; then
308+
echo "No new commits to push"
309+
exit 0
310+
fi
311+
312+
git push

0 commit comments

Comments
 (0)