Auto-fix Test Failures #33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| name: Auto-fix Test Failures | |
| on: | |
| workflow_run: | |
| workflows: ["CI pipeline for pySDC"] | |
| types: ["completed"] | |
| jobs: | |
| analyze_and_fix_failures: | |
| runs-on: ubuntu-latest | |
| # Only run for scheduled (Monday) runs that failed | |
| if: github.event.workflow_run.conclusion == 'failure' && github.event.workflow_run.event == 'schedule' | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| issues: write | |
| actions: read | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| pip install PyGithub requests | |
| - name: Analyze test failures | |
| id: analyze | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| WORKFLOW_RUN_ID: ${{ github.event.workflow_run.id }} | |
| REPOSITORY: ${{ github.repository }} | |
| run: | | |
| python .github/scripts/analyze_failures.py | |
| - name: Create failure report branch | |
| id: create_branch | |
| run: | | |
| TIMESTAMP=$(date +%Y%m%d-%H%M%S) | |
| BRANCH_NAME="auto-fix/test-failure-${TIMESTAMP}" | |
| echo "branch_name=${BRANCH_NAME}" >> $GITHUB_OUTPUT | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git checkout -b ${BRANCH_NAME} | |
| - name: Commit failure analysis | |
| run: | | |
| if [ -f ".github/failure_analysis.md" ]; then | |
| git add .github/failure_analysis.md | |
| git commit -m "Add automated failure analysis for workflow run ${{ github.event.workflow_run.id }}" | |
| git push origin ${{ steps.create_branch.outputs.branch_name }} | |
| fi | |
| - name: Create Pull Request | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| python .github/scripts/create_failure_pr.py \ | |
| --branch "${{ steps.create_branch.outputs.branch_name }}" \ | |
| --workflow-run-id "${{ github.event.workflow_run.id }}" \ | |
| --workflow-run-url "${{ github.event.workflow_run.html_url }}" |