forked from dbfixtures/pytest-postgresql
-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (85 loc) · 3.46 KB
/
tests.yml
File metadata and controls
88 lines (85 loc) · 3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Run tests
on:
push:
branches: [ main ]
paths:
- '**.py'
- .github/workflows/tests.yml
- requirements-test.txt
- requirements-test-withpsycopg.txt
pull_request:
branches: [ main ]
jobs:
tests:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
python-version: [3.7, 3.8, 3.9, "3.10", pypy-3.7-v7.3.3]
postgres-version: [10, 11, 12, 13, 14]
env:
OS: ubuntu-latest
PYTHON: ${{ matrix.python-version }}
POSTGRES: ${{ matrix.postgres-version }}
# Service containers to run with `container-job`
services:
# Label used to access the service container
postgres:
# Docker Hub image:
image: postgres:${{ matrix.postgres-version }}
# Provide the password for postgres
env:
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5433:5432
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install postgresql
run: |
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg ${{ matrix.postgres-version }}" > /etc/apt/sources.list.d/pgdg.list'
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "Package: *" > /etc/apt/preferences.d/psql'
sudo sh -c 'echo "Pin: release c=${{ matrix.poxtgresql-version }}" >> /etc/apt/preferences.d/psql'
sudo sh -c 'echo "Pin-Priority: 1000" >> /etc/apt/preferences.d/psql'
sudo apt-get update -o Dir::Etc::sourcelist="/etc/apt/sources.list.d/pgdg.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"
sudo apt install -y postgresql-${{ matrix.postgres-version }} postgresql-client-${{ matrix.postgres-version }}
- name: Check installed locales
run: |
locale -a
sudo locale-gen de_DE.UTF-8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-test-withpsycopg.txt
- name: Run test
run: |
py.test -n 0 --postgresql-exec="/usr/lib/postgresql/${{ matrix.postgres-version }}/bin/pg_ctl" -k "not docker" --cov-report=xml
- name: Run xdist test
run: |
py.test -n 1 --postgresql-exec="/usr/lib/postgresql/${{ matrix.postgres-version }}/bin/pg_ctl" -k "not docker" --cov-report=xml:coverage-xdist.xml
- uses: actions/upload-artifact@v3
if: failure()
with:
name: postgresql-${{ matrix.python-version }}-${{ matrix.postgres-version }}
path: /tmp/pytest-of-runner/**
- name: Run test noproc fixture on docker
run: |
pytest -n 0 -k docker --postgresql-host=localhost --postgresql-port 5433 --postgresql-password=postgres --cov-report=xml:coverage-docker.xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2.1.0
with:
flags: linux
env_vars: OS, PYTHON, POSTGRES
fail_ci_if_error: true