Skip to content

Refactor: Remove legacy files and update documentation for Cloud SRE … #5

Refactor: Remove legacy files and update documentation for Cloud SRE …

Refactor: Remove legacy files and update documentation for Cloud SRE … #5

Workflow file for this run

name: Quality Gates
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
quality-gates:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.12]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip dependencies
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 -r requirements.txt
pip install ruff pyright bandit safety pytest-cov
- name: Run Static Analysis (Pyright)
run: |
pyright --strict
- name: Run Linting (Ruff)
run: |
ruff check --output-format=github
ruff format --check
- name: Run Security Scan (Bandit)
run: |
bandit -r gemini_sre_agent -f json -o bandit-report.json || true
bandit -r gemini_sre_agent
- name: Run Tests with Coverage
run: |
pytest --cov=gemini_sre_agent --cov-report=xml --cov-report=html --cov-fail-under=80
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
- name: Run Quality Gates
run: |
python -m gemini_sre_agent.core.quality.cli run \
--output=quality-report.json \
--format=json \
--fail-on-warning
- name: Upload Quality Report
uses: actions/upload-artifact@v3
if: always()
with:
name: quality-report
path: |
quality-report.json
bandit-report.json
coverage.xml
htmlcov/
- name: Comment PR with Quality Report
if: github.event_name == 'pull_request'
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
try {
const report = JSON.parse(fs.readFileSync('quality-report.json', 'utf8'));
const summary = report.summary;
let comment = `## 🔍 Quality Gate Report\n\n`;
comment += `**Overall Status:** ${summary.success ? '✅ PASSED' : '❌ FAILED'}\n`;
comment += `**Pass Rate:** ${summary.pass_rate.toFixed(1)}%\n`;
comment += `**Duration:** ${summary.duration.toFixed(2)}s\n\n`;
comment += `| Gate | Status | Message |\n`;
comment += `|------|--------|----------|\n`;
for (const result of report.results) {
const status = result.status === 'passed' ? '✅' : '❌';
comment += `| ${result.gate_name} | ${status} | ${result.message} |\n`;
}
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
} catch (error) {
console.log('Could not generate quality report comment:', error);
}
performance-gates:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install psutil
- name: Run Performance Gates
run: |
python -m gemini_sre_agent.core.quality.cli run \
--gates=performance \
--output=performance-report.json \
--format=json
- name: Upload Performance Report
uses: actions/upload-artifact@v3
with:
name: performance-report
path: performance-report.json