Skip to content

feat(examples): configuration management system #15

feat(examples): configuration management system

feat(examples): configuration management system #15

Workflow file for this run

name: CI/CD with Auto Bug-Fix Loop
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
env:
PYTHON_VERSION: "3.11"
jobs:
ci-loop:
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for better analysis
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install strategy-pm[github] pytest pytest-cov
pip install llx # Install llx for AI analysis
- name: Install Ollama (for local LLM)
if: env.AUTO_FIX == 'true'
run: |
curl -fsSL https://ollama.ai/install.sh | sh
ollama serve &
sleep 5
ollama pull qwen2.5:3b
- name: Run CI Auto-Loop
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPO: ${{ github.repository }}
AUTO_FIX: ${{ vars.AUTO_FIX || 'false' }}
run: |
strategy-pm auto loop \
--strategy ./strategy.yaml \
--project . \
--backend github \
--max-iterations 5 \
--auto-fix ${{ env.AUTO_FIX }} \
--output ci-results.json
- name: Comment PR with results
if: github.event_name == 'pull_request'
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
if (fs.existsSync('ci-results.json')) {
const results = JSON.parse(fs.readFileSync('ci-results.json', 'utf8'));
const comment = `
## 🤖 CI/CD Auto-Loop Results
**Status**: ${results.success ? '✅ Success' : '❌ Failed'}
**Iterations**: ${results.total_iterations}
**Tickets Created**: ${results.tickets_created.length}
${results.tickets_created.length > 0 ? `
### 📫 Created Tickets
${results.tickets_created.map(url => `- [Ticket](${url})`).join('\n')}
` : ''}
${!results.success ? `
### ❌ Issues
Final status: ${results.final_status}
` : ''}
---
*Generated by SprintStrat CI/CD*
`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
}
- name: Update strategy if needed
if: failure() && env.UPDATE_STRATEGY == 'true'
run: |
# Generate updated strategy based on failures
llx chat --model balanced \
--prompt "Update strategy.yaml based on recent test failures and CI results" \
--output strategy-updated.yaml
# Create PR for strategy update
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git checkout -b strategy-update-${{ github.run_number }}
git add strategy-updated.yaml
git commit -m "ci: Update strategy based on CI results"
git push origin strategy-update-${{ github.run_number }}
gh pr create --title "Auto-update strategy" --body "Strategy updated based on CI results"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload artifacts
uses: actions/upload-artifact@v3
if: always()
with:
name: ci-results
path: |
ci-results.json
test-results.xml
coverage.json
htmlcov/
- name: Coverage badge
uses: tj-actions/coverage-badge-py@v2
if: github.ref == 'refs/heads/main'
with:
output: coverage.svg
- name: Deploy coverage reports
if: github.ref == 'refs/heads/main'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./htmlcov
destination_dir: coverage
notify:
runs-on: ubuntu-latest
needs: ci-loop
if: always()
steps:
- name: Notify Slack
if: env.SLACK_WEBHOOK_URL != ''
run: |
curl -X POST -H 'Content-type: application/json' \
--data '{"text":"CI/CD ${{ needs.ci-loop.result }}: ${{ github.repository }} - ${{ github.sha }}"}' \
${{ env.SLACK_WEBHOOK_URL }}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}