| 1 |
name: Test |
| 2 |
|
| 3 |
on: [push, pull_request] |
| 4 |
|
| 5 |
env: |
| 6 |
POSTGRES_USER: postgres |
| 7 |
POSTGRES_PASSWORD: postgres |
| 8 |
POSTGRES_DB: postgres |
| 9 |
FORCE_COLOR: 1 |
| 10 |
|
| 11 |
jobs: |
| 12 |
build: |
| 13 |
runs-on: ubuntu-latest |
| 14 |
strategy: |
| 15 |
fail-fast: false |
| 16 |
max-parallel: 5 |
| 17 |
matrix: |
| 18 |
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12-dev'] |
| 19 |
|
| 20 |
services: |
| 21 |
postgres: |
| 22 |
image: postgres:13-alpine |
| 23 |
env: |
| 24 |
POSTGRES_USER: ${{ env.POSTGRES_USER }} |
| 25 |
POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }} |
| 26 |
POSTGRES_DB: ${{ env.POSTGRES_DB }} |
| 27 |
ports: |
| 28 |
- 5432:5432 |
| 29 |
options: >- |
| 30 |
--health-cmd pg_isready |
| 31 |
--health-interval 10s |
| 32 |
--health-timeout 5s |
| 33 |
--health-retries 5 |
| 34 |
|
| 35 |
steps: |
| 36 |
- uses: actions/checkout@v3 |
| 37 |
|
| 38 |
- name: Set up Python ${{ matrix.python-version }} |
| 39 |
uses: actions/setup-python@v4 |
| 40 |
with: |
| 41 |
python-version: ${{ matrix.python-version }} |
| 42 |
|
| 43 |
- name: Get pip cache dir |
| 44 |
id: pip-cache |
| 45 |
run: | |
| 46 |
echo "::set-output name=dir::$(pip cache dir)" |
| 47 |
|
| 48 |
- name: Cache |
| 49 |
uses: actions/cache@v3 |
| 50 |
with: |
| 51 |
path: ${{ steps.pip-cache.outputs.dir }} |
| 52 |
key: |
| 53 |
${{ matrix.python-version }}-v1-${{ hashFiles('**/setup.py') }}-${{ hashFiles('**/tox.ini') }} |
| 54 |
restore-keys: | |
| 55 |
${{ matrix.python-version }}-v1- |
| 56 |
|
| 57 |
- name: Install dependencies |
| 58 |
run: | |
| 59 |
python -m pip install --upgrade pip |
| 60 |
python -m pip install --upgrade tox tox-gh-actions |
| 61 |
|
| 62 |
- name: Tox tests |
| 63 |
run: | |
| 64 |
tox -v -- --cov --cov-append --cov-report term-missing --cov-report xml |
| 65 |
env: |
| 66 |
POSTGRES_DB: ${{ env.POSTGRES_DB }} |
| 67 |
POSTGRES_USER: ${{ env.POSTGRES_USER }} |
| 68 |
POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }} |
| 69 |
|
| 70 |
- name: Upload coverage |
| 71 |
uses: codecov/codecov-action@v3 |
| 72 |
with: |
| 73 |
name: Python ${{ matrix.python-version }} |