docs(cleanup): wave-2a report & instructions #17
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: "CI Autofix - Self-Improvement Loop" | ||
| on: | ||
| push: | ||
| branches: [ main, develop ] | ||
| pull_request: | ||
| branches: [ main, develop ] | ||
| workflow_dispatch: | ||
| env: | ||
| PYTHON_VERSION: "3.12" | ||
| AUTOFIX_MAX_TRIES: "2" | ||
| jobs: | ||
| autofix-pipeline: | ||
| name: "Autofix Pipeline" | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: ${{ env.PYTHON_VERSION }} | ||
| cache: 'pip' | ||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -r requirements.txt | ||
| pip install -r requirements-test.txt | ||
| pip install pyright coverage pytest-html | ||
| - name: Run initial linting | ||
| run: | | ||
| echo "🔍 Running initial linting checks..." | ||
| ruff check . --force-exclude --output-format=json > ruff-report.json || true | ||
| pyright --stats --outputjson > pyright-report.json || true | ||
| - name: Run initial tests | ||
| run: | | ||
| echo "🧪 Running initial test suite..." | ||
| python -m pytest -q --maxfail=1 --tb=short --html=pytest-report.html --self-contained-html || true | ||
| - name: Run coverage analysis | ||
| run: | | ||
| echo "📊 Running coverage analysis..." | ||
| python -m coverage run -m pytest -q | ||
| python -m coverage report -m --skip-covered > coverage-report.txt | ||
| python -m coverage xml -o coverage.xml | ||
| - name: Check if autofix needed | ||
| id: check_autofix | ||
| run: | | ||
| echo "🔍 Checking if autofix is needed..." | ||
| if [ -f pytest-report.html ] && grep -q "failed" pytest-report.html; then | ||
| echo "needs_autofix=true" >> $GITHUB_OUTPUT | ||
| echo "❌ Tests failed - autofix needed" | ||
| else | ||
| echo "needs_autofix=false" >> $GITHUB_OUTPUT | ||
| echo "✅ All tests passed - no autofix needed" | ||
| fi | ||
| - name: Run Self-Improvement Loop | ||
| if: steps.check_autofix.outputs.needs_autofix == 'true' | ||
| run: | | ||
| echo "🤖 Running Self-Improvement Loop..." | ||
| python -m agent_dev.auto_fix --max-tries ${{ env.AUTOFIX_MAX_TRIES }} --db-path autofix.db | ||
| - name: Run tests after autofix | ||
| if: steps.check_autofix.outputs.needs_autofix == 'true' | ||
| run: | | ||
| echo "🧪 Running tests after autofix..." | ||
| python -m pytest -q --maxfail=1 --tb=short --html=pytest-report-after.html --self-contained-html || true | ||
| - name: Run coverage after autofix | ||
| if: steps.check_autofix.outputs.needs_autofix == 'true' | ||
| run: | | ||
| echo "📊 Running coverage after autofix..." | ||
| python -m coverage run -m pytest -q | ||
| python -m coverage report -m --skip-covered > coverage-report-after.txt | ||
| python -m coverage xml -o coverage-after.xml | ||
| - name: Check autofix success | ||
| id: autofix_success | ||
| if: steps.check_autofix.outputs.needs_autofix == 'true' | ||
| run: | | ||
| echo "🔍 Checking autofix success..." | ||
| if [ -f pytest-report-after.html ] && ! grep -q "failed" pytest-report-after.html; then | ||
| echo "autofix_success=true" >> $GITHUB_OUTPUT | ||
| echo "✅ Autofix successful - all tests now pass" | ||
| else | ||
| echo "autofix_success=false" >> $GITHUB_OUTPUT | ||
| echo "❌ Autofix failed - tests still failing" | ||
| fi | ||
| - name: Create autofix branch and commit | ||
| if: steps.autofix_success.outputs.autofix_success == 'true' | ||
| run: | | ||
| echo "🌿 Creating autofix branch and committing changes..." | ||
| git config --local user.email "action@github.com" | ||
| git config --local user.name "GitHub Action" | ||
| # Create autofix branch | ||
| BRANCH_NAME="autofix/$(date +%Y%m%d-%H%M%S)-${{ github.run_id }}" | ||
| git checkout -b "$BRANCH_NAME" | ||
| # Add all changes | ||
| git add . | ||
| # Commit changes | ||
| git commit -m "fix: Apply self-improvement loop fixes | ||
| - Applied automated fixes using AgentDev Self-Improvement Loop | ||
| - Fixed ${{ github.run_id }} issues | ||
| - All tests now passing | ||
| - Coverage maintained | ||
| Generated by CI Autofix Pipeline" || echo "No changes to commit" | ||
| # Push branch | ||
| git push origin "$BRANCH_NAME" | ||
| echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV | ||
| - name: Create Pull Request | ||
| if: steps.autofix_success.outputs.autofix_success == 'true' | ||
| uses: actions/github-script@v6 | ||
| with: | ||
| script: | | ||
| const branchName = process.env.BRANCH_NAME; | ||
| const { data: pr } = await github.rest.pulls.create({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| title: `🤖 Autofix: Self-Improvement Loop Applied`, | ||
| head: branchName, | ||
| base: context.payload.pull_request?.base?.ref || 'main', | ||
| body: `## 🤖 Automated Fixes Applied | ||
| This PR contains automated fixes applied by the AgentDev Self-Improvement Loop. | ||
| ### 📊 Results: | ||
| - **Pipeline Run**: ${{ github.run_id }} | ||
| - **Max Tries**: ${{ env.AUTOFIX_MAX_TRIES }} | ||
| - **Status**: ✅ All tests now passing | ||
| - **Coverage**: Maintained or improved | ||
| ### 🔧 Changes: | ||
| - Applied automated error detection and fixing | ||
| - Used rule-based pattern matching | ||
| - Maintained code quality standards | ||
| - No \`# type: ignore\` or comment-out used | ||
| ### 📋 Artifacts: | ||
| - Coverage reports: \`coverage.xml\`, \`coverage-report.txt\` | ||
| - Test reports: \`pytest-report.html\` | ||
| - Linting reports: \`ruff-report.json\`, \`pyright-report.json\` | ||
| ### ✅ Quality Assurance: | ||
| - All tests passing | ||
| - Coverage targets met | ||
| - No linting errors | ||
| - Type safety maintained | ||
| **Ready for review and merge.**`, | ||
| draft: false | ||
| }); | ||
| console.log(`Created PR #${pr.number}: ${pr.html_url}`); | ||
| - name: Upload artifacts | ||
| uses: actions/upload-artifact@v3 | ||
| if: always() | ||
| with: | ||
| name: autofix-artifacts-${{ github.run_id }} | ||
| path: | | ||
| coverage.xml | ||
| coverage-report.txt | ||
| coverage-after.xml | ||
| coverage-report-after.txt | ||
| pytest-report.html | ||
| pytest-report-after.html | ||
| ruff-report.json | ||
| pyright-report.json | ||
| autofix.db | ||
| retention-days: 30 | ||
| - name: Comment on original PR | ||
| if: github.event_name == 'pull_request' && steps.autofix_success.outputs.autofix_success == 'true' | ||
| uses: actions/github-script@v6 | ||
| with: | ||
| script: | | ||
| const { data: pr } = await github.rest.pulls.create({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| title: `🤖 Autofix: Self-Improvement Loop Applied`, | ||
| head: process.env.BRANCH_NAME, | ||
| base: context.payload.pull_request.base.ref, | ||
| body: `## 🤖 Automated Fixes Applied | ||
| This PR contains automated fixes applied by the AgentDev Self-Improvement Loop. | ||
| ### 📊 Results: | ||
| - **Pipeline Run**: ${{ github.run_id }} | ||
| - **Max Tries**: ${{ env.AUTOFIX_MAX_TRIES }} | ||
| - **Status**: ✅ All tests now passing | ||
| - **Coverage**: Maintained or improved | ||
| ### 🔧 Changes: | ||
| - Applied automated error detection and fixing | ||
| - Used rule-based pattern matching | ||
| - Maintained code quality standards | ||
| - No \`# type: ignore\` or comment-out used | ||
| **Ready for review and merge.**` | ||
| }); | ||
| // Comment on original PR | ||
| await github.rest.issues.createComment({ | ||
| issue_number: context.issue.number, | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| body: `🤖 **Autofix Applied Successfully!** | ||
| I've automatically applied fixes using the AgentDev Self-Improvement Loop: | ||
| - **Pipeline Run**: ${{ github.run_id }} | ||
| - **Status**: ✅ All tests now passing | ||
| - **Coverage**: Maintained or improved | ||
| - **Quality**: No \`# type: ignore\` or comment-out used | ||
| **Created PR**: #${pr.number} - ${pr.html_url} | ||
| The fixes are ready for review and merge.` | ||
| }); | ||
| - name: Report autofix failure | ||
| if: steps.check_autofix.outputs.needs_autofix == 'true' && steps.autofix_success.outputs.autofix_success == 'false' | ||
| run: | | ||
| echo "❌ Autofix failed - manual intervention required" | ||
| echo "Please review the test failures and apply manual fixes" | ||
| echo "Artifacts have been uploaded for analysis" | ||