|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +concurrency: |
| 11 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 12 | + cancel-in-progress: true |
| 13 | + |
| 14 | +env: |
| 15 | + PYTHON_VERSION: "3.10" |
| 16 | + FORCE_COLOR: "1" |
| 17 | + |
| 18 | +jobs: |
| 19 | + # =========================================================================== |
| 20 | + # Linting & Formatting |
| 21 | + # =========================================================================== |
| 22 | + lint: |
| 23 | + name: Lint & Format |
| 24 | + runs-on: ubuntu-latest |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v4 |
| 27 | + |
| 28 | + - name: Set up Python |
| 29 | + uses: actions/setup-python@v5 |
| 30 | + with: |
| 31 | + python-version: ${{ env.PYTHON_VERSION }} |
| 32 | + |
| 33 | + - name: Install ruff |
| 34 | + run: pip install ruff |
| 35 | + |
| 36 | + - name: Run ruff linter |
| 37 | + run: ruff check . |
| 38 | + |
| 39 | + - name: Run ruff formatter |
| 40 | + run: ruff format --check . |
| 41 | + |
| 42 | + # =========================================================================== |
| 43 | + # Type Checking |
| 44 | + # =========================================================================== |
| 45 | + typecheck: |
| 46 | + name: Type Check |
| 47 | + runs-on: ubuntu-latest |
| 48 | + steps: |
| 49 | + - uses: actions/checkout@v4 |
| 50 | + |
| 51 | + - name: Set up Python |
| 52 | + uses: actions/setup-python@v5 |
| 53 | + with: |
| 54 | + python-version: ${{ env.PYTHON_VERSION }} |
| 55 | + |
| 56 | + - name: Install dependencies |
| 57 | + run: | |
| 58 | + pip install -e ".[dev,cli]" |
| 59 | +
|
| 60 | + - name: Run mypy |
| 61 | + run: mypy src/ |
| 62 | + |
| 63 | + # =========================================================================== |
| 64 | + # Tests |
| 65 | + # =========================================================================== |
| 66 | + test: |
| 67 | + name: Test (Python ${{ matrix.python-version }}, ${{ matrix.os }}) |
| 68 | + runs-on: ${{ matrix.os }} |
| 69 | + strategy: |
| 70 | + fail-fast: false |
| 71 | + matrix: |
| 72 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 73 | + python-version: ["3.10", "3.11", "3.12", "3.13"] |
| 74 | + exclude: |
| 75 | + # Reduce matrix size - test oldest and newest on all platforms |
| 76 | + - os: macos-latest |
| 77 | + python-version: "3.11" |
| 78 | + - os: macos-latest |
| 79 | + python-version: "3.12" |
| 80 | + - os: windows-latest |
| 81 | + python-version: "3.11" |
| 82 | + - os: windows-latest |
| 83 | + python-version: "3.12" |
| 84 | + |
| 85 | + steps: |
| 86 | + - uses: actions/checkout@v4 |
| 87 | + |
| 88 | + - name: Set up Python ${{ matrix.python-version }} |
| 89 | + uses: actions/setup-python@v5 |
| 90 | + with: |
| 91 | + python-version: ${{ matrix.python-version }} |
| 92 | + |
| 93 | + - name: Install dependencies |
| 94 | + run: | |
| 95 | + pip install -e ".[dev,cli]" |
| 96 | +
|
| 97 | + - name: Run tests with coverage |
| 98 | + run: | |
| 99 | + pytest --cov=har_capture --cov-report=xml --cov-report=term-missing |
| 100 | +
|
| 101 | + - name: Upload coverage to Codecov |
| 102 | + if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10' |
| 103 | + uses: codecov/codecov-action@v4 |
| 104 | + with: |
| 105 | + files: ./coverage.xml |
| 106 | + fail_ci_if_error: false |
| 107 | + verbose: true |
| 108 | + |
| 109 | + # =========================================================================== |
| 110 | + # Security |
| 111 | + # =========================================================================== |
| 112 | + security: |
| 113 | + name: Security Scan |
| 114 | + runs-on: ubuntu-latest |
| 115 | + steps: |
| 116 | + - uses: actions/checkout@v4 |
| 117 | + |
| 118 | + - name: Set up Python |
| 119 | + uses: actions/setup-python@v5 |
| 120 | + with: |
| 121 | + python-version: ${{ env.PYTHON_VERSION }} |
| 122 | + |
| 123 | + - name: Install dependencies |
| 124 | + run: | |
| 125 | + pip install pip-audit |
| 126 | +
|
| 127 | + - name: Run pip-audit |
| 128 | + run: | |
| 129 | + pip install -e ".[full]" |
| 130 | + pip-audit |
| 131 | +
|
| 132 | + # =========================================================================== |
| 133 | + # Build |
| 134 | + # =========================================================================== |
| 135 | + build: |
| 136 | + name: Build Package |
| 137 | + runs-on: ubuntu-latest |
| 138 | + steps: |
| 139 | + - uses: actions/checkout@v4 |
| 140 | + |
| 141 | + - name: Set up Python |
| 142 | + uses: actions/setup-python@v5 |
| 143 | + with: |
| 144 | + python-version: ${{ env.PYTHON_VERSION }} |
| 145 | + |
| 146 | + - name: Install build tools |
| 147 | + run: pip install build twine |
| 148 | + |
| 149 | + - name: Build package |
| 150 | + run: python -m build |
| 151 | + |
| 152 | + - name: Check package |
| 153 | + run: twine check dist/* |
| 154 | + |
| 155 | + - name: Upload artifacts |
| 156 | + uses: actions/upload-artifact@v4 |
| 157 | + with: |
| 158 | + name: dist |
| 159 | + path: dist/ |
| 160 | + |
| 161 | + # =========================================================================== |
| 162 | + # Docs |
| 163 | + # =========================================================================== |
| 164 | + docs: |
| 165 | + name: Documentation |
| 166 | + runs-on: ubuntu-latest |
| 167 | + steps: |
| 168 | + - uses: actions/checkout@v4 |
| 169 | + |
| 170 | + - name: Check README renders |
| 171 | + run: | |
| 172 | + pip install "readme-renderer[md]" |
| 173 | + python -m readme_renderer README.md -o /dev/null |
| 174 | +
|
| 175 | + # =========================================================================== |
| 176 | + # All Checks Pass |
| 177 | + # =========================================================================== |
| 178 | + all-checks: |
| 179 | + name: All Checks Pass |
| 180 | + if: always() |
| 181 | + needs: [lint, typecheck, test, security, build, docs] |
| 182 | + runs-on: ubuntu-latest |
| 183 | + steps: |
| 184 | + - name: Check all jobs passed |
| 185 | + uses: re-actors/alls-green@release/v1 |
| 186 | + with: |
| 187 | + jobs: ${{ toJSON(needs) }} |
0 commit comments