Tests #4
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: "Tests" | |
on: | |
push: | |
branches: [ develop ] | |
pull_request: | |
# The branches below must be a subset of the branches above | |
branches: [ develop ] | |
schedule: | |
- cron: '30 22 15 * *' | |
jobs: | |
pytest: | |
name: pytest | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python: ['3.8', '3.9', '3.10', '3.11', '3.12'] | |
django: ['2.2', '3.0', '3.1', '3.2', '4.0', '4.1', '4.2', '5.0'] | |
database: ['postgres', 'sqlite'] | |
exclude: | |
- python: '3.8' | |
django: '5.0' | |
- python: '3.9' | |
django: '5.0' | |
- python: '3.10' | |
django: '2.2' | |
- python: '3.10' | |
django: '3.0' | |
- python: '3.10' | |
django: '3.1' | |
- python: '3.11' | |
django: '2.0' | |
- python: '3.11' | |
django: '2.1' | |
- python: '3.11' | |
django: '2.2' | |
- python: '3.11' | |
django: '3.0' | |
- python: '3.11' | |
django: '3.1' | |
- python: '3.11' | |
django: '3.2' | |
- python: '3.11' | |
django: '4.0' | |
- python: '3.12' | |
django: '2.2' | |
- python: '3.12' | |
django: '3.0' | |
- python: '3.12' | |
django: '3.1' | |
- python: '3.12' | |
django: '3.2' | |
- python: '3.12' | |
django: '4.0' | |
- python: '3.12' | |
django: '4.1' | |
services: | |
# as far as I can see, no way to make this conditional on the matrix database | |
postgres: | |
image: postgres:12 | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: dirtyfields_test | |
ports: | |
- 5432:5432 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python }} | |
- name: Install test requirements | |
run: | | |
python -m pip install --upgrade pip wheel | |
pip install django~=${{ matrix.django }}.0 coverage[toml]~=7.0 -r tests-requirements.txt | |
python --version | |
pip list | |
- name: Run unit tests | |
run: coverage run -m pytest -v | |
env: | |
TEST_DATABASE: ${{ matrix.database }} | |
# Run tests on original source code, rather than installing the package into the python environment. | |
# This ensures coverage report has files listed with paths relative to the repository root. | |
PYTHONPATH: './src' | |
- name: Report coverage to console | |
run: coverage report | |
- name: Create XML coverage report for coveralls.io | |
if: ${{ matrix.django == '4.2' && matrix.python == '3.10' && matrix.database == 'postgres' }} | |
run: coverage xml | |
- name: Upload coverage report to coveralls.io | |
if: ${{ matrix.django == '4.2' && matrix.python == '3.10' && matrix.database == 'postgres' }} | |
uses: coverallsapp/github-action@v2 | |
with: | |
file: coverage.xml |