Skip to content

WIP: Async support

WIP: Async support #86

Workflow file for this run

# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Tests
on:
- push
- pull_request
- workflow_dispatch
jobs:
build:
runs-on: ubuntu-latest
services:
postgres: # we need a postgres docker image to be booted a side car service to run the tests that needs a db
image: postgres
env: # the environment variables must match with db_url as defined below
POSTGRES_USER: pg
POSTGRES_PASSWORD: pgpass
POSTGRES_DB: bdmodels
ports:
- 5432:5432 # exposing 5432 port for application to use
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
db-backend: ["sqlt", "pg2", "pg3"]
steps:
- name: Update Sqlite
run: |
sudo apt-add-repository -y --update 'deb http://archive.ubuntu.com/ubuntu hirsute main'
sudo apt install -y sqlite3
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox
# if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Tox me
run: |
TOXPY="py$( echo ${{ matrix.python-version }} | sed s/\\.// )"
TOXDB="${{ matrix.db-backend }}"
# Skip envs with the wrong Python and db-backend using TOX_SKIP_ENV var.
# The below constructs, e.g. for py310 and sqlt the string '(?!py310).*(?<!sqlt)'
# (?!...) is negative lookahead, and (?<!...) is negative lookbehind;
# the expr matches anything which does _not_ start with 'py310' and end with sqlt.
# All the matched envs are excluded, so this ensures
# we only run the envs defined for the given Python and db-backend.
export TOX_SKIP_ENV='(?!'"${TOXPY}).*"'(?<!'"${TOXDB}"')'
BDMODELS_DB=''
if (echo ${{ matrix.db-backend }} | grep pg > /dev/null); then
BDMODELS_DB='postgresql://pg:pgpass@localhost/bdmodels'
fi
export BDMODELS_DB
tox