| 1 |
name: Test |
| 2 |
on: |
| 3 |
pull_request: |
| 4 |
branches: |
| 5 |
- main |
| 6 |
push: |
| 7 |
branches: |
| 8 |
- main |
| 9 |
|
| 10 |
jobs: |
| 11 |
pytest: |
| 12 |
runs-on: ubuntu-latest |
| 13 |
strategy: |
| 14 |
matrix: |
| 15 |
python-version: ["3.7", "3.x"] |
| 16 |
flask-version: ["2.0.3", "latest"] |
| 17 |
database-uri: |
| 18 |
- "postgresql://testuser:testpw@localhost/testdb" |
| 19 |
- "sqlite://" |
| 20 |
name: "pytest: Python ${{ matrix.python-version }}, Flask ${{ matrix.flask-version }}, postgres=${{ contains(matrix.database-uri, 'postgres') }}" |
| 21 |
services: |
| 22 |
postgres: |
| 23 |
image: postgres:latest |
| 24 |
env: |
| 25 |
POSTGRES_USER: testuser |
| 26 |
POSTGRES_PASSWORD: testpw |
| 27 |
POSTGRES_DB: testdb |
| 28 |
ports: |
| 29 |
- 5432:5432 |
| 30 |
options: >- |
| 31 |
--health-cmd pg_isready |
| 32 |
--health-interval 10s |
| 33 |
--health-timeout 5s |
| 34 |
--health-retries 5 |
| 35 |
env: |
| 36 |
DATABASE_URI: ${{ matrix.database-uri }} |
| 37 |
|
| 38 |
steps: |
| 39 |
- uses: actions/checkout@v3 |
| 40 |
- uses: actions/setup-python@v4 |
| 41 |
with: |
| 42 |
python-version: ${{ matrix.python-version }} |
| 43 |
|
| 44 |
- name: Install specific Flask version |
| 45 |
if: ${{ matrix.flask-version != 'latest' }} |
| 46 |
run: pip install Flask==${{ matrix.flask-version }} |
| 47 |
|
| 48 |
- name: Install dependencies |
| 49 |
run: pip install -e .[test] |
| 50 |
|
| 51 |
- name: Install psycopg2 |
| 52 |
if: ${{ contains(matrix.database-uri, 'postgres') }} |
| 53 |
run: pip install psycopg2 |
| 54 |
|
| 55 |
- name: Run pytest |
| 56 |
run: coverage run -m pytest |
| 57 |
|
| 58 |
- name: Upload coverage to Codecov |
| 59 |
if: ${{ always() }} |
| 60 |
uses: codecov/codecov-action@v3 |
| 61 |
with: |
| 62 |
fail_ci_if_error: false |