|
| 1 | +name: Python Projects CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + paths: |
| 7 | + - 'ArroyoSketch/**' |
| 8 | + - 'PrometheusClient/**' |
| 9 | + - 'Controller/**' |
| 10 | + - 'Utilities/**' |
| 11 | + - 'PrometheusExporters/**' |
| 12 | + - 'ExecutionUtilities/**' |
| 13 | + - 'CommonDependencies/dependencies/py/**' |
| 14 | + - '.github/workflows/python.yml' |
| 15 | + pull_request: |
| 16 | + branches: [ main ] |
| 17 | + paths: |
| 18 | + - 'ArroyoSketch/**' |
| 19 | + - 'PrometheusClient/**' |
| 20 | + - 'Controller/**' |
| 21 | + - 'Utilities/**' |
| 22 | + - 'PrometheusExporters/**' |
| 23 | + - 'ExecutionUtilities/**' |
| 24 | + - 'CommonDependencies/dependencies/py/**' |
| 25 | + - '.github/workflows/python.yml' |
| 26 | + workflow_dispatch: |
| 27 | + |
| 28 | +permissions: |
| 29 | + contents: read |
| 30 | + pull-requests: read |
| 31 | + |
| 32 | +jobs: |
| 33 | + detect-changes: |
| 34 | + runs-on: ubuntu-latest |
| 35 | + outputs: |
| 36 | + arroyo_sketch: ${{ steps.filter.outputs.arroyo_sketch }} |
| 37 | + prometheus_client: ${{ steps.filter.outputs.prometheus_client }} |
| 38 | + controller: ${{ steps.filter.outputs.controller }} |
| 39 | + utilities: ${{ steps.filter.outputs.utilities }} |
| 40 | + prometheus_exporters: ${{ steps.filter.outputs.prometheus_exporters }} |
| 41 | + execution_utilities: ${{ steps.filter.outputs.execution_utilities }} |
| 42 | + steps: |
| 43 | + - uses: actions/checkout@v4 |
| 44 | + - uses: dorny/paths-filter@v2 |
| 45 | + id: filter |
| 46 | + with: |
| 47 | + filters: | |
| 48 | + arroyo_sketch: |
| 49 | + - 'ArroyoSketch/**' |
| 50 | + - 'CommonDependencies/dependencies/py/**' |
| 51 | + prometheus_client: |
| 52 | + - 'PrometheusClient/**' |
| 53 | + - 'CommonDependencies/dependencies/py/**' |
| 54 | + controller: |
| 55 | + - 'Controller/**' |
| 56 | + - 'CommonDependencies/dependencies/py/**' |
| 57 | + utilities: |
| 58 | + - 'Utilities/**' |
| 59 | + - 'CommonDependencies/dependencies/py/**' |
| 60 | + prometheus_exporters: |
| 61 | + - 'PrometheusExporters/**' |
| 62 | + - 'CommonDependencies/dependencies/py/**' |
| 63 | + execution_utilities: |
| 64 | + - 'ExecutionUtilities/**' |
| 65 | + - 'CommonDependencies/dependencies/py/**' |
| 66 | +
|
| 67 | + test-arroyo-sketch: |
| 68 | + needs: detect-changes |
| 69 | + if: needs.detect-changes.outputs.arroyo_sketch == 'true' |
| 70 | + runs-on: ubuntu-latest |
| 71 | + strategy: |
| 72 | + matrix: |
| 73 | + python-version: ["3.8", "3.9", "3.10", "3.11"] |
| 74 | + steps: |
| 75 | + - uses: actions/checkout@v4 |
| 76 | + - name: Set up Python ${{ matrix.python-version }} |
| 77 | + uses: actions/setup-python@v4 |
| 78 | + with: |
| 79 | + python-version: ${{ matrix.python-version }} |
| 80 | + - name: Install dependencies |
| 81 | + run: | |
| 82 | + python -m pip install --upgrade pip |
| 83 | + pip install black==24.8.0 flake8==6.1.0 |
| 84 | + if [ -f ArroyoSketch/requirements.txt ]; then pip install -r ArroyoSketch/requirements.txt; fi |
| 85 | + - name: Check formatting with Black |
| 86 | + working-directory: ArroyoSketch |
| 87 | + run: black --check --diff . |
| 88 | + - name: Lint with flake8 |
| 89 | + working-directory: ArroyoSketch |
| 90 | + run: | |
| 91 | + # Stop the build if there are Python syntax errors or undefined names |
| 92 | + flake8 . --config=../.flake8 --count --select=E9,F63,F7,F82 --show-source --statistics |
| 93 | + # Exit-zero treats all errors as warnings |
| 94 | + flake8 . --config=../.flake8 --count --exit-zero --max-complexity=10 --statistics |
| 95 | +
|
| 96 | + test-prometheus-client: |
| 97 | + needs: detect-changes |
| 98 | + if: needs.detect-changes.outputs.prometheus_client == 'true' |
| 99 | + runs-on: ubuntu-latest |
| 100 | + strategy: |
| 101 | + matrix: |
| 102 | + python-version: ["3.8", "3.9", "3.10", "3.11"] |
| 103 | + steps: |
| 104 | + - uses: actions/checkout@v4 |
| 105 | + - name: Set up Python ${{ matrix.python-version }} |
| 106 | + uses: actions/setup-python@v4 |
| 107 | + with: |
| 108 | + python-version: ${{ matrix.python-version }} |
| 109 | + - name: Install dependencies |
| 110 | + run: | |
| 111 | + python -m pip install --upgrade pip |
| 112 | + pip install black==24.8.0 flake8==6.1.0 mypy types-requests types-PyYAML typing-extensions numpy prometheus-client urllib3 |
| 113 | + if [ -f PrometheusClient/requirements.txt ]; then pip install -r PrometheusClient/requirements.txt; fi |
| 114 | + - name: Check formatting with Black |
| 115 | + working-directory: PrometheusClient |
| 116 | + run: black --check --diff . |
| 117 | + - name: Lint with flake8 |
| 118 | + working-directory: PrometheusClient |
| 119 | + run: | |
| 120 | + # Stop the build if there are Python syntax errors or undefined names |
| 121 | + flake8 . --config=../.flake8 --count --select=E9,F63,F7,F82 --show-source --statistics |
| 122 | + # Exit-zero treats all errors as warnings |
| 123 | + flake8 . --config=../.flake8 --count --exit-zero --max-complexity=10 --statistics |
| 124 | + - name: Type check with mypy |
| 125 | + working-directory: PrometheusClient |
| 126 | + run: mypy . |
| 127 | + |
| 128 | + test-controller: |
| 129 | + needs: detect-changes |
| 130 | + if: needs.detect-changes.outputs.controller == 'true' |
| 131 | + runs-on: ubuntu-latest |
| 132 | + strategy: |
| 133 | + matrix: |
| 134 | + python-version: ["3.8", "3.9", "3.10", "3.11"] |
| 135 | + steps: |
| 136 | + - uses: actions/checkout@v4 |
| 137 | + - name: Set up Python ${{ matrix.python-version }} |
| 138 | + uses: actions/setup-python@v4 |
| 139 | + with: |
| 140 | + python-version: ${{ matrix.python-version }} |
| 141 | + - name: Install dependencies |
| 142 | + run: | |
| 143 | + python -m pip install --upgrade pip |
| 144 | + pip install black==24.8.0 flake8==6.1.0 |
| 145 | + if [ -f Controller/requirements.txt ]; then pip install -r Controller/requirements.txt; fi |
| 146 | + - name: Check formatting with Black |
| 147 | + working-directory: Controller |
| 148 | + run: black --check --diff . |
| 149 | + - name: Lint with flake8 |
| 150 | + working-directory: Controller |
| 151 | + run: | |
| 152 | + # Stop the build if there are Python syntax errors or undefined names |
| 153 | + flake8 . --config=../.flake8 --count --select=E9,F63,F7,F82 --show-source --statistics |
| 154 | + # Exit-zero treats all errors as warnings |
| 155 | + flake8 . --config=../.flake8 --count --exit-zero --max-complexity=10 --statistics |
| 156 | +
|
| 157 | + test-utilities: |
| 158 | + needs: detect-changes |
| 159 | + if: needs.detect-changes.outputs.utilities == 'true' |
| 160 | + runs-on: ubuntu-latest |
| 161 | + strategy: |
| 162 | + matrix: |
| 163 | + python-version: ["3.8", "3.9", "3.10", "3.11"] |
| 164 | + steps: |
| 165 | + - uses: actions/checkout@v4 |
| 166 | + - name: Set up Python ${{ matrix.python-version }} |
| 167 | + uses: actions/setup-python@v4 |
| 168 | + with: |
| 169 | + python-version: ${{ matrix.python-version }} |
| 170 | + - name: Install dependencies |
| 171 | + run: | |
| 172 | + python -m pip install --upgrade pip |
| 173 | + pip install black==24.8.0 flake8==6.1.0 |
| 174 | + if [ -f Utilities/requirements.txt ]; then pip install -r Utilities/requirements.txt; fi |
| 175 | + - name: Check formatting with Black |
| 176 | + working-directory: Utilities |
| 177 | + run: black --check --diff . |
| 178 | + - name: Lint with flake8 |
| 179 | + working-directory: Utilities |
| 180 | + run: | |
| 181 | + # Stop the build if there are Python syntax errors or undefined names |
| 182 | + flake8 . --config=../.flake8 --count --select=E9,F63,F7,F82 --show-source --statistics |
| 183 | + # Exit-zero treats all errors as warnings |
| 184 | + flake8 . --config=../.flake8 --count --exit-zero --max-complexity=10 --statistics |
| 185 | +
|
| 186 | + test-prometheus-exporters: |
| 187 | + needs: detect-changes |
| 188 | + if: needs.detect-changes.outputs.prometheus_exporters == 'true' |
| 189 | + runs-on: ubuntu-latest |
| 190 | + strategy: |
| 191 | + matrix: |
| 192 | + python-version: ["3.8", "3.9", "3.10", "3.11"] |
| 193 | + steps: |
| 194 | + - uses: actions/checkout@v4 |
| 195 | + - name: Set up Python ${{ matrix.python-version }} |
| 196 | + uses: actions/setup-python@v4 |
| 197 | + with: |
| 198 | + python-version: ${{ matrix.python-version }} |
| 199 | + - name: Install dependencies |
| 200 | + run: | |
| 201 | + python -m pip install --upgrade pip |
| 202 | + pip install black==24.8.0 flake8==6.1.0 mypy isort |
| 203 | + if [ -f PrometheusExporters/requirements.txt ]; then pip install -r PrometheusExporters/requirements.txt; fi |
| 204 | + - name: Check formatting with Black |
| 205 | + working-directory: PrometheusExporters |
| 206 | + run: black --check --diff . |
| 207 | + - name: Check import sorting with isort |
| 208 | + working-directory: PrometheusExporters |
| 209 | + run: isort --check-only --diff --settings-file .isort.cfg . |
| 210 | + - name: Lint with flake8 |
| 211 | + working-directory: PrometheusExporters |
| 212 | + run: | |
| 213 | + # Stop the build if there are Python syntax errors or undefined names |
| 214 | + flake8 . --config=../.flake8 --count --select=E9,F63,F7,F82 --show-source --statistics |
| 215 | + # Exit-zero treats all errors as warnings |
| 216 | + flake8 . --config=../.flake8 --count --exit-zero --max-complexity=10 --statistics |
| 217 | + - name: Type check with mypy |
| 218 | + working-directory: PrometheusExporters |
| 219 | + run: mypy . --config-file=.mypy.ini |
| 220 | + |
| 221 | + test-execution-utilities: |
| 222 | + needs: detect-changes |
| 223 | + if: needs.detect-changes.outputs.execution_utilities == 'true' |
| 224 | + runs-on: ubuntu-latest |
| 225 | + strategy: |
| 226 | + matrix: |
| 227 | + python-version: ["3.8", "3.9", "3.10", "3.11"] |
| 228 | + steps: |
| 229 | + - uses: actions/checkout@v4 |
| 230 | + - name: Set up Python ${{ matrix.python-version }} |
| 231 | + uses: actions/setup-python@v4 |
| 232 | + with: |
| 233 | + python-version: ${{ matrix.python-version }} |
| 234 | + - name: Install dependencies |
| 235 | + run: | |
| 236 | + python -m pip install --upgrade pip |
| 237 | + pip install black==24.8.0 flake8==6.1.0 |
| 238 | + if [ -f ExecutionUtilities/requirements.txt ]; then pip install -r ExecutionUtilities/requirements.txt; fi |
| 239 | + - name: Check formatting with Black |
| 240 | + working-directory: ExecutionUtilities |
| 241 | + run: black --check --diff . |
| 242 | + - name: Lint with flake8 |
| 243 | + working-directory: ExecutionUtilities |
| 244 | + run: | |
| 245 | + # Stop the build if there are Python syntax errors or undefined names |
| 246 | + flake8 . --config=../.flake8 --count --select=E9,F63,F7,F82 --show-source --statistics |
| 247 | + # Exit-zero treats all errors as warnings |
| 248 | + flake8 . --config=../.flake8 --count --exit-zero --max-complexity=10 --statistics |
0 commit comments