Merge pull request #82 from mts-ai/fix-update-relationship #432
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Python testing | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- ".github/workflows/testing.yml" | |
- "fastapi_jsonapi/**" | |
- "tests/**" | |
- "codecov.yaml" | |
- "pyproject.toml" | |
pull_request: | |
branches: | |
- main | |
- dev-3.x | |
paths: | |
- ".github/workflows/testing.yml" | |
- "fastapi_jsonapi/**" | |
- "tests/**" | |
- "pyproject.toml" | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: | |
- "3.9" | |
- "3.10" | |
- "3.11" | |
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 poetry | |
run: | | |
python -m pip install --upgrade pip poetry pre-commit | |
poetry config virtualenvs.create false --local | |
- name: Install dependencies | |
run: poetry install --all-extras | |
- name: Lint code | |
run: pre-commit run --all-files | |
run-tests: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: | |
- "3.9" | |
- "3.10" | |
- "3.11" | |
db-url: | |
- "sqlite+aiosqlite:///./db.sqlite3" | |
- "postgresql+asyncpg://user:passwd@localhost:5432/app" | |
# Service containers to run with `container-job` | |
services: | |
# Label used to access the service container | |
postgres: | |
# Docker Hub image | |
image: postgres | |
# Provide the password for postgres | |
env: | |
POSTGRES_USER: user | |
POSTGRES_PASSWORD: passwd | |
POSTGRES_DB: app | |
# 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 | |
- 5432: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 poetry | |
run: | | |
python -m pip install --upgrade pip poetry pre-commit | |
poetry config virtualenvs.create false --local | |
- name: Install dependencies | |
run: poetry install --all-extras | |
- name: Test with pytest | |
run: | | |
flags="-s -vv --cov=fastapi_jsonapi --cov-config .coveragerc --cov-report=xml" | |
pytest $flags tests/ | |
env: | |
TESTING_DB_URL: ${{ matrix.db-url }} | |
- name: Upload coverage data to Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: coverage.xml | |
flags: unittests | |
name: py-${{ matrix.python-version }}-db-${{ startsWith(matrix.db-url, 'sqlite') && 'sqlite' || startsWith(matrix.db-url, 'postgres') && 'postgres' || 'unknown' }} | |
fail_ci_if_error: true |