diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..d6b14a0 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,4 @@ +[run] +branch = True +source = django_jsonform +omit = *tests*,__main__ diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..84cb7ab --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,58 @@ +name: django-jsonform tests + +on: + pull_request: + push: + branches: master + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] + django-version: ["2.2", "3.2", "4.1", "4.2", "main"] + exclude: + - django-version: 2.2 + python-version: 3.10 + - django-version: 2.2 + python-version: 3.11 + - django-version: 3.2 + python-version: 3.11 + - django-version: 4.1 + python-version: 3.7 + - django-version: 4.2 + python-version: 3.7 + - django-version: "main" + python-version: 3.7 + - django-version: "main" + python-version: 3.8 + - django-version: "main" + python-version: 3.9 + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Upgrade pip + run: python -m pip install --upgrade pip + - name: Install Django ${{ matrix.django-version }} + run: python -m pip install django~=${{ matrix.django-version }}.0 + if: matrix.django-version != 'main' + - name: Install Django main + run: python -m pip install https://github.com/django/django/archive/refs/heads/main.zip + if: matrix.django-version == 'main' + - name: Install library to run tests + run: python -m pip install -e . + - name: Verify versions + run: | + python --version + python -c "import django ; print(django.VERSION)" + - name: Run tests + run: | + python -m pip install coverage + coverage run tests/__main__.py + coverage report -m diff --git a/tests/__main__.py b/tests/__main__.py index 48710a8..edfcb33 100644 --- a/tests/__main__.py +++ b/tests/__main__.py @@ -2,7 +2,6 @@ import sys import unittest import django -import django_settings TEST_DIR = os.path.dirname(os.path.abspath(__file__)) diff --git a/tests/django_settings.py b/tests/django_settings.py index 37f9248..b5aa7d3 100644 --- a/tests/django_settings.py +++ b/tests/django_settings.py @@ -1,9 +1,18 @@ +SECRET_KEY = "secret for test" + ROOT_URLCONF='django_jsonform.urls' INSTALLED_APPS=[ 'django_jsonform', ] +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': ":memory:", + }, +} + TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates',