| 1 |
name: Python Tests |
| 2 |
|
| 3 |
on: |
| 4 |
push: |
| 5 |
branches: |
| 6 |
- master |
| 7 |
pull_request_target: |
| 8 |
types: [opened, synchronize, reopened] |
| 9 |
|
| 10 |
permissions: |
| 11 |
contents: read |
| 12 |
|
| 13 |
jobs: |
| 14 |
flake8: |
| 15 |
runs-on: ubuntu-latest |
| 16 |
|
| 17 |
steps: |
| 18 |
- uses: actions/checkout@v6 |
| 19 |
- name: Setup pip cache |
| 20 |
uses: actions/cache@v5 |
| 21 |
id: pipcache |
| 22 |
with: |
| 23 |
path: ~/.cache/pip |
| 24 |
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }} |
| 25 |
restore-keys: | |
| 26 |
${{ runner.os }}-pip-flake8 |
| 27 |
- name: Set up Python |
| 28 |
uses: actions/setup-python@v6 |
| 29 |
with: |
| 30 |
python-version: '3.x' |
| 31 |
- name: Install dependencies |
| 32 |
run: | |
| 33 |
python -m pip install flake8 |
| 34 |
- name: Lint with flake8 |
| 35 |
uses: liskin/gh-problem-matcher-wrap@v3 |
| 36 |
with: |
| 37 |
linters: flake8 |
| 38 |
run: flake8 --extend-ignore=E203 faker tests |
| 39 |
|
| 40 |
checkmanifest: |
| 41 |
runs-on: ubuntu-latest |
| 42 |
steps: |
| 43 |
- uses: actions/checkout@v6 |
| 44 |
- name: Setup pip cache |
| 45 |
uses: actions/cache@v5 |
| 46 |
id: pipcache |
| 47 |
with: |
| 48 |
path: ~/.cache/pip |
| 49 |
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }} |
| 50 |
restore-keys: | |
| 51 |
${{ runner.os }}-pip-checkmanifest |
| 52 |
- name: Set up Python |
| 53 |
uses: actions/setup-python@v6 |
| 54 |
with: |
| 55 |
python-version: '3.x' |
| 56 |
- name: Install dependencies |
| 57 |
run: | |
| 58 |
python -m pip install tox |
| 59 |
- name: Check manifest |
| 60 |
run: tox |
| 61 |
env: |
| 62 |
TOXENV: checkmanifest |
| 63 |
|
| 64 |
isort: |
| 65 |
runs-on: ubuntu-latest |
| 66 |
steps: |
| 67 |
- uses: actions/checkout@v6 |
| 68 |
- name: Setup pip cache |
| 69 |
uses: actions/cache@v5 |
| 70 |
id: pipcache |
| 71 |
with: |
| 72 |
path: ~/.cache/pip |
| 73 |
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }} |
| 74 |
restore-keys: | |
| 75 |
${{ runner.os }}-pip-isort |
| 76 |
- name: Set up Python |
| 77 |
uses: actions/setup-python@v6 |
| 78 |
with: |
| 79 |
python-version: '3.x' |
| 80 |
- name: Install dependencies |
| 81 |
run: | |
| 82 |
python -m pip install isort |
| 83 |
- name: Import order checking with isort |
| 84 |
uses: liskin/gh-problem-matcher-wrap@v3 |
| 85 |
with: |
| 86 |
linters: isort |
| 87 |
run: isort --check --diff . |
| 88 |
|
| 89 |
black: |
| 90 |
runs-on: ubuntu-latest |
| 91 |
steps: |
| 92 |
- uses: actions/checkout@v6 |
| 93 |
- name: Setup pip cache |
| 94 |
uses: actions/cache@v5 |
| 95 |
id: pipcache |
| 96 |
with: |
| 97 |
path: ~/.cache/pip |
| 98 |
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }} |
| 99 |
restore-keys: | |
| 100 |
${{ runner.os }}-pip-black |
| 101 |
- name: Set up Python |
| 102 |
uses: actions/setup-python@v6 |
| 103 |
with: |
| 104 |
python-version: '3.x' |
| 105 |
- name: Install dependencies |
| 106 |
run: | |
| 107 |
python -m pip install tox |
| 108 |
- name: Formatting with black |
| 109 |
run: tox |
| 110 |
env: |
| 111 |
TOXENV: black |
| 112 |
|
| 113 |
doc8: |
| 114 |
runs-on: ubuntu-latest |
| 115 |
steps: |
| 116 |
- uses: actions/checkout@v6 |
| 117 |
- name: Setup pip cache |
| 118 |
uses: actions/cache@v5 |
| 119 |
id: pipcache |
| 120 |
with: |
| 121 |
path: ~/.cache/pip |
| 122 |
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }} |
| 123 |
restore-keys: | |
| 124 |
${{ runner.os }}-pip-pep8 |
| 125 |
- name: Set up Python |
| 126 |
uses: actions/setup-python@v6 |
| 127 |
with: |
| 128 |
python-version: '3.x' |
| 129 |
- name: Install dependencies |
| 130 |
run: | |
| 131 |
python -m pip install tox |
| 132 |
- name: Doc formatting |
| 133 |
run: tox |
| 134 |
env: |
| 135 |
TOXENV: doc8 |
| 136 |
|
| 137 |
typing: |
| 138 |
runs-on: ubuntu-latest |
| 139 |
strategy: |
| 140 |
matrix: |
| 141 |
python: |
| 142 |
- "3.10" |
| 143 |
- "3.11" |
| 144 |
- "3.12" |
| 145 |
- "3.13" |
| 146 |
- "3.14" |
| 147 |
|
| 148 |
steps: |
| 149 |
- uses: actions/checkout@v6 |
| 150 |
- name: Setup pip cache |
| 151 |
uses: actions/cache@v5 |
| 152 |
id: pipcache |
| 153 |
with: |
| 154 |
path: ~/.cache/pip |
| 155 |
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }} |
| 156 |
restore-keys: | |
| 157 |
${{ runner.os }}-pip-typing |
| 158 |
- name: Set up Python |
| 159 |
uses: actions/setup-python@v6 |
| 160 |
with: |
| 161 |
python-version: ${{ matrix.python }} |
| 162 |
- name: Install dependencies |
| 163 |
run: | |
| 164 |
python -m pip install mypy |
| 165 |
- name: Static type checking with mypy |
| 166 |
uses: liskin/gh-problem-matcher-wrap@v3 |
| 167 |
with: |
| 168 |
linters: mypy |
| 169 |
run: mypy --install-types --non-interactive --config mypy.ini faker |
| 170 |
|
| 171 |
test_ubuntu: |
| 172 |
runs-on: ubuntu-latest |
| 173 |
needs: [flake8, isort, black, doc8, checkmanifest, typing] |
| 174 |
strategy: |
| 175 |
matrix: |
| 176 |
python: |
| 177 |
- "3.10" |
| 178 |
- "3.11" |
| 179 |
- "3.12" |
| 180 |
- "3.13" |
| 181 |
- "3.14" |
| 182 |
- "pypy-3.11" |
| 183 |
|
| 184 |
steps: |
| 185 |
- uses: actions/checkout@v6 |
| 186 |
- name: Setup pip cache |
| 187 |
uses: actions/cache@v5 |
| 188 |
id: pipcache |
| 189 |
with: |
| 190 |
path: ~/.cache/pip |
| 191 |
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }} |
| 192 |
restore-keys: | |
| 193 |
${{ runner.os }}-pip-test_ubuntu |
| 194 |
- name: Setup Python |
| 195 |
uses: actions/setup-python@v6 |
| 196 |
with: |
| 197 |
python-version: ${{ matrix.python }} |
| 198 |
- name: Install system dependencies |
| 199 |
run: sudo apt-get update && sudo apt-get install -y libjpeg-dev |
| 200 |
- name: Install Tox and any other packages |
| 201 |
run: python -m pip install tox |
| 202 |
- name: pytest |
| 203 |
uses: liskin/gh-problem-matcher-wrap@v3 |
| 204 |
with: |
| 205 |
linters: pytest |
| 206 |
run: tox -e py |
| 207 |
env: |
| 208 |
COVERALLS_PARALLEL: true |
| 209 |
COVERALLS_FLAG_NAME: run-ubuntu-${{ matrix.python }} |
| 210 |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 211 |
COVERALLS_SERVICE_NAME: github |
| 212 |
|
| 213 |
test_windows: |
| 214 |
runs-on: windows-latest |
| 215 |
needs: [flake8, isort, black, doc8, checkmanifest, typing] |
| 216 |
strategy: |
| 217 |
matrix: |
| 218 |
python: |
| 219 |
- "3.10" |
| 220 |
- "3.11" |
| 221 |
- "3.12" |
| 222 |
- "3.13" |
| 223 |
- "3.14" |
| 224 |
arch: ["x86", "x64"] |
| 225 |
|
| 226 |
steps: |
| 227 |
- uses: actions/checkout@v6 |
| 228 |
- name: Setup pip cache |
| 229 |
uses: actions/cache@v5 |
| 230 |
id: pipcache |
| 231 |
with: |
| 232 |
path: ~/.cache/pip |
| 233 |
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }} |
| 234 |
restore-keys: | |
| 235 |
${{ runner.os }}-pip-test_windows |
| 236 |
- name: Setup Python |
| 237 |
uses: actions/setup-python@v6 |
| 238 |
with: |
| 239 |
python-version: ${{ matrix.python }} |
| 240 |
- name: Install Tox and any other packages |
| 241 |
run: python -m pip install tox |
| 242 |
- name: Run Tox |
| 243 |
# Run tox using the version of Python in `PATH` |
| 244 |
run: tox -e py |
| 245 |
|
| 246 |
test_alpine: |
| 247 |
runs-on: ubuntu-latest |
| 248 |
needs: [flake8, isort, black, doc8, checkmanifest, typing] |
| 249 |
|
| 250 |
steps: |
| 251 |
- uses: actions/checkout@v6 |
| 252 |
- name: Setup pip cache |
| 253 |
uses: actions/cache@v5 |
| 254 |
id: pipcache |
| 255 |
with: |
| 256 |
path: ~/.cache/pip |
| 257 |
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }} |
| 258 |
restore-keys: | |
| 259 |
${{ runner.os }}-pip-test_alpine |
| 260 |
- name: Set up Python |
| 261 |
uses: actions/setup-python@v6 |
| 262 |
with: |
| 263 |
python-version: '3.12' |
| 264 |
- name: Install dependencies |
| 265 |
run: | |
| 266 |
python -m pip install tox==3.27.1 setuptools |
| 267 |
- name: Run tests |
| 268 |
run: tox |
| 269 |
env: |
| 270 |
TOXENV: alpine |
| 271 |
TEST_ALPINE: 1 |