|
31 | 31 | - uses: actions/checkout@v4 |
32 | 32 | with: |
33 | 33 | ref: ${{ github.event.workflow_run.head_branch }} |
| 34 | + token: ${{ secrets.GITHUB_TOKEN }} |
34 | 35 | fetch-depth: 0 |
35 | 36 |
|
36 | 37 | - name: Use Node.js 24 |
|
45 | 46 |
|
46 | 47 | - run: npm ci |
47 | 48 |
|
| 49 | + - name: Configure git identity |
| 50 | + run: | |
| 51 | + git config user.name "github-actions[bot]" |
| 52 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 53 | +
|
| 54 | + - name: Generate fix branch name |
| 55 | + id: branch |
| 56 | + run: echo "name=fix/claude-auto-$(date +%s)" >> $GITHUB_OUTPUT |
| 57 | + |
48 | 58 | - name: Fetch and filter failure logs from all shards |
49 | 59 | id: fetch-logs |
50 | 60 | env: |
@@ -112,10 +122,35 @@ jobs: |
112 | 122 |
|
113 | 123 | 4. **Iterate until all tests pass**: If tests still fail after a fix, re-read the output, deepen your understanding of the root cause, and refine the fix. Do not give up and do not apply increasingly speculative patches. Each iteration must be grounded in analysis. |
114 | 124 |
|
115 | | - 5. **Create a PR only after all failing tests pass**: |
116 | | - - Create a new branch from "${{ github.event.workflow_run.head_branch }}" (e.g. `fix/claude-auto-<short-description>`) |
117 | | - - Commit the changes with a descriptive message explaining the root cause and fix |
118 | | - - Open a pull request targeting "${{ github.event.workflow_run.head_branch }}" |
| 125 | + 5. **Stop once all tests pass** — do NOT run any git commands. The workflow will handle committing and opening the PR. |
119 | 126 |
|
120 | 127 | additional_permissions: | |
121 | 128 | actions: read |
| 129 | +
|
| 130 | + - name: Restore git remote auth |
| 131 | + env: |
| 132 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 133 | + run: git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git |
| 134 | + |
| 135 | + - name: Commit fixes |
| 136 | + id: auto-commit |
| 137 | + uses: stefanzweifel/git-auto-commit-action@v5 |
| 138 | + with: |
| 139 | + commit_message: "fix: auto-fix test failures from ${{ github.event.workflow_run.name }}" |
| 140 | + branch: ${{ steps.branch.outputs.name }} |
| 141 | + create_branch: true |
| 142 | + |
| 143 | + - name: Open pull request |
| 144 | + if: steps.auto-commit.outputs.changes_detected == 'true' |
| 145 | + env: |
| 146 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 147 | + run: | |
| 148 | + gh pr create \ |
| 149 | + --title "fix: auto-fix test failures from ${{ github.event.workflow_run.name }}" \ |
| 150 | + --body "Failures detected in \`${{ github.event.workflow_run.name }}\` on branch \`${{ github.event.workflow_run.head_branch }}\`. |
| 151 | +
|
| 152 | + This PR was automatically generated by the Claude Test Fixer workflow. |
| 153 | +
|
| 154 | + > ⚠️ AI-generated fix. Please review carefully before merging." \ |
| 155 | + --base ${{ github.event.workflow_run.head_branch }} \ |
| 156 | + --head ${{ steps.branch.outputs.name }} |
0 commit comments