|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ master, develop ] |
| 6 | + pull_request: |
| 7 | + branches: [ master ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + test: |
| 11 | + name: Test Python 3.12 |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - name: Install uv |
| 18 | + uses: astral-sh/setup-uv@v4 |
| 19 | + with: |
| 20 | + version: "latest" |
| 21 | + |
| 22 | + - name: Set up Python 3.12 |
| 23 | + uses: actions/setup-python@v5 |
| 24 | + with: |
| 25 | + python-version: "3.12" |
| 26 | + |
| 27 | + - name: Install dependencies |
| 28 | + run: | |
| 29 | + uv pip install --system -e ".[dev]" |
| 30 | + |
| 31 | + - name: Run ruff (lint) |
| 32 | + run: | |
| 33 | + ruff check . |
| 34 | + continue-on-error: true |
| 35 | + |
| 36 | + - name: Run black (format check) |
| 37 | + run: | |
| 38 | + black --check . |
| 39 | + continue-on-error: true |
| 40 | + |
| 41 | + - name: Run tests with coverage |
| 42 | + run: | |
| 43 | + pytest -v --cov=pingping --cov-report=xml --cov-report=json --cov-report=term |
| 44 | + |
| 45 | + - name: Generate coverage badge |
| 46 | + uses: tj-actions/coverage-badge-py@v2 |
| 47 | + with: |
| 48 | + output: coverage.svg |
| 49 | + |
| 50 | + - name: Upload coverage badge |
| 51 | + if: github.ref == 'refs/heads/master' |
| 52 | + uses: actions/upload-artifact@v4 |
| 53 | + with: |
| 54 | + name: coverage-badge |
| 55 | + path: coverage.svg |
| 56 | + |
| 57 | + - name: Commit coverage badge |
| 58 | + if: github.ref == 'refs/heads/master' |
| 59 | + run: | |
| 60 | + git config --local user.email "github-actions[bot]@users.noreply.github.com" |
| 61 | + git config --local user.name "github-actions[bot]" |
| 62 | + mkdir -p .github/badges |
| 63 | + mv coverage.svg .github/badges/ |
| 64 | + git add .github/badges/coverage.svg || true |
| 65 | + git diff --quiet && git diff --staged --quiet || git commit -m "Update coverage badge [skip ci]" |
| 66 | + git push || true |
| 67 | +
|
| 68 | + quality-gate: |
| 69 | + name: TestIQ Quality Gate |
| 70 | + runs-on: ubuntu-latest |
| 71 | + needs: test |
| 72 | + |
| 73 | + steps: |
| 74 | + - uses: actions/checkout@v4 |
| 75 | + |
| 76 | + - name: Install uv |
| 77 | + uses: astral-sh/setup-uv@v4 |
| 78 | + with: |
| 79 | + version: "latest" |
| 80 | + |
| 81 | + - name: Set up Python 3.12 |
| 82 | + uses: actions/setup-python@v5 |
| 83 | + with: |
| 84 | + python-version: "3.12" |
| 85 | + |
| 86 | + - name: Install dependencies |
| 87 | + run: | |
| 88 | + uv pip install --system -e ".[dev]" |
| 89 | + |
| 90 | + - name: Run tests with TestIQ coverage |
| 91 | + run: | |
| 92 | + pytest --testiq-output=testiq_coverage.json -q |
| 93 | + |
| 94 | + - name: Analyze test quality with TestIQ |
| 95 | + run: | |
| 96 | + testiq analyze testiq_coverage.json --threshold 1.0 |
| 97 | + continue-on-error: true |
| 98 | + |
| 99 | + - name: Generate HTML report |
| 100 | + if: always() |
| 101 | + run: | |
| 102 | + mkdir -p reports |
| 103 | + testiq analyze testiq_coverage.json --format html --output reports/testiq-report.html |
| 104 | + |
| 105 | + - name: Upload TestIQ report |
| 106 | + if: always() |
| 107 | + uses: actions/upload-artifact@v4 |
| 108 | + with: |
| 109 | + name: testiq-quality-report |
| 110 | + path: reports/testiq-report.html |
| 111 | + retention-days: 30 |
| 112 | + |
0 commit comments