Skip to content

Commit

Permalink
add test GHA workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuadavidthomas committed Feb 6, 2024
1 parent e8a913e commit 41b3679
Showing 1 changed file with 100 additions and 0 deletions.
100 changes: 100 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: test

on:
push:
branches: [main]
pull_request:

concurrency:
group: test-${{ github.head_ref }}
cancel-in-progress: true

env:
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"

jobs:
test:
name: Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }}
runs-on: "ubuntu-latest"
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
django-version: ["4.2", "5.0", "main"]
exclude:
# https://docs.djangoproject.com/en/dev/faq/install/#what-python-version-can-i-use-with-django
# main requires python 3.10+
- django-version: "main"
python-version: "3.8"
- django-version: "main"
python-version: "3.9"
# 5.0 requires python 3.10+
- django-version: "5.0"
python-version: "3.8"
- django-version: "5.0"
python-version: "3.9"
steps:
- uses: actions/checkout@v4

- uses: extractions/setup-just@v1

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
allow-prereleases: true

- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [[ "${{ matrix.django-version }}" == "main" ]]; then
python -m pip install https://github.com/django/django/archive/refs/heads/main.zip
else
python -m pip install django==${{ matrix.django-version }}
fi
python -m pip install '.[tests]'
- name: Run tests
run: |
just test
tests:
runs-on: ubuntu-latest
needs: test
if: always()
steps:
- name: OK
if: ${{ !(contains(needs.*.result, 'failure')) }}
run: exit 0
- name: Fail
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1

coverage:
runs-on: ubuntu-latest
env:
PYTHON_MIN_VERSION: "3.8"
DJANGO_MIN_VERSION: "4.2"
steps:
- uses: actions/checkout@v4

- uses: extractions/setup-just@v1

- name: Set up Python ${{ env.PYTHON_MIN_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_MIN_VERSION }}
cache: "pip"
allow-prereleases: true

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install django==${{ env.DJANGO_MIN_VERSION }}
python -m pip install '.[tests]'
- name: Run coverage
run: |
just coverage

0 comments on commit 41b3679

Please sign in to comment.