diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..a699a73d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,72 @@ +name: CI + +on: + push: + pull_request: + workflow_dispatch: + +jobs: + test: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + + matrix: + python-version: ["2.7", "3.6", "3.7", "3.8"] + django-version: ["1.11", "2.0", "2.2", "2.1", "3.0"] + es-dsl-version: ["6.4", "7.4"] + es-version: ["7.13.4"] + + exclude: + - python-version: "2.7" + django-version: "2.0" + - python-version: "2.7" + django-version: "2.1" + - python-version: "2.7" + django-version: "2.2" + - python-version: "2.7" + django-version: "3.0" + + - python-version: "3.8" + django-version: "1.11" + - python-version: "3.8" + django-version: "2.0" + - python-version: "3.8" + django-version: "2.1" + + steps: + - name: Install and Run Elasticsearch + uses: elastic/elastic-github-actions/elasticsearch@master + with: + stack-version: ${{ matrix.es-version }} + + - uses: actions/checkout@v2 + + - name: Install Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Cache Pip Dependencies + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('requirements_test.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + python -m pip install "Django==${{ matrix.django-version }}" + python -m pip install "elasticsearch-dsl==${{ matrix.es-dsl-version }}" + python -m pip install -r requirements_test.txt + + - name: Run tests with Python ${{ matrix.python-version }} and Django ${{ matrix.django-version }} and elasticsearch-dsl-py ${{ matrix.es-dsl-version }} + run: | + TOX_ENV=$(echo "py${{ matrix.python-version }}-django-${{ matrix.django-version }}-es${{ matrix.es-dsl-version }}" | tr -d .) + python -m tox -e $TOX_ENV -- --elasticsearch + + - name: Publish Coverage Report + uses: codecov/codecov-action@v1 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2f289e65..00000000 --- a/.travis.yml +++ /dev/null @@ -1,62 +0,0 @@ -# Config file for automatic testing at travis-ci.org - -language: python -python: 3.8 - -dist: xenial # default "precise" distro doesn't include Java 8 for Elasticsearch 5 - -matrix: - include: - - env: TOX_ENV=py36-django-111-es6 - python: 3.6 - - env: TOX_ENV=py37-django-111-es6 - python: 3.7 - - env: TOX_ENV=py38-django-111-es6 - python: 3.8 - - env: TOX_ENV=py27-django-111-es6 - python: 2.7 - - env: TOX_ENV=py36-django-2-es6 - python: 3.6 - - env: TOX_ENV=py37-django-2-es6 - python: 3.7 - - env: TOX_ENV=py37-django-21-es6 - python: 3.7 - - env: TOX_ENV=py37-django-22-es6 - python: 3.7 - - env: TOX_ENV=py37-django-30-es6 - python: 3.7 - - env: TOX_ENV=py38-django-2-es6 - python: 3.8 - - env: TOX_ENV=py38-django-21-es6 - python: 3.8 - - env: TOX_ENV=py38-django-22-es6 - python: 3.8 - - env: TOX_ENV=py38-django-30-es6 - python: 3.8 - -cache: pip -env: - global: - - ES_APT_URL=https://artifacts.elastic.co/packages/7.x/apt - -before_install: - # work around https://github.com/travis-ci/travis-ci/issues/8363 - - pip install codecov - - wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - - - echo "deb $ES_APT_URL stable main" | sudo tee -a /etc/apt/sources.list.d/elk.list - - sudo apt-get remove --purge elasticsearch -y - - sudo apt-get update && sudo apt-get install elasticsearch -y - - sudo -i service elasticsearch restart - -# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors -install: pip install -r requirements_test.txt - -# sleep for elasticsearch -before_script: - - wget -q --waitretry=1 --retry-connrefused -T 100 -O - http://127.0.0.1:9200 - -# command to run tests using coverage, e.g. python setup.py test -script: tox -e $TOX_ENV -- --elasticsearch - -after_success: - - codecov -e $TOX_ENV diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index eb7b66ec..062c98dd 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -101,6 +101,6 @@ Before you submit a pull request, check that it meets these guidelines: your new functionality into a function with a docstring, and add the feature to the list in README.rst. 3. The pull request should work for Python 2.7, and 3.4, and for PyPy. Check - https://travis-ci.org/sabricot/django-elasticsearch-dsl/pull_requests + https://github.com/django-es/django-elasticsearch-dsl/actions and make sure that the tests pass for all supported Python versions. diff --git a/README.rst b/README.rst index 3c6f1b05..81c46f90 100644 --- a/README.rst +++ b/README.rst @@ -2,13 +2,13 @@ Django Elasticsearch DSL ======================== -.. image:: https://travis-ci.org/sabricot/django-elasticsearch-dsl.png?branch=master - :target: https://travis-ci.org/sabricot/django-elasticsearch-dsl -.. image:: https://codecov.io/gh/sabricot/django-elasticsearch-dsl/coverage.svg?branch=master - :target: https://codecov.io/gh/sabricot/django-elasticsearch-dsl +.. image:: https://github.com/django-es/django-elasticsearch-dsl/actions/workflows/ci.yml/badge.svg + :target: https://github.com/django-es/django-elasticsearch-dsl/actions/workflows/ci.yml +.. image:: https://codecov.io/gh/django-es/django-elasticsearch-dsl/coverage.svg?branch=master + :target: https://codecov.io/gh/django-es/django-elasticsearch-dsl .. image:: https://badge.fury.io/py/django-elasticsearch-dsl.svg :target: https://pypi.python.org/pypi/django-elasticsearch-dsl -.. image:: https://readthedocs.org/projects/pip/badge/?version=latest&style=flat +.. image:: https://readthedocs.org/projects/django-elasticsearch-dsl/badge/?version=latest&style=flat :target: https://django-elasticsearch-dsl.readthedocs.io/en/latest/ Django Elasticsearch DSL is a package that allows indexing of django models in elasticsearch. diff --git a/tests/test_fields.py b/tests/test_fields.py index 72a3fcf3..47c862d7 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -50,7 +50,7 @@ def test_get_value_from_instance_with_unknown_attr(self): class Dummy: attr1 = "foo" - field = DEDField(attr='attr2') + field = DEDField(attr='attr2', required=True) self.assertRaises( VariableLookupError, field.get_value_from_instance, Dummy() ) diff --git a/tox.ini b/tox.ini index 599dad26..696893c4 100644 --- a/tox.ini +++ b/tox.ini @@ -1,22 +1,21 @@ [tox] envlist = - py27-django-111-es7 - {py36,py37,py38}-django-{111,2,21,22,30}-{es7} + py27-django-111-es74 + {py36,py37,py38}-django-{111,20,21,22,30}-{es64,es74} [testenv] setenv = PYTHONPATH = {toxinidir}:{toxinidir}/django_elasticsearch_dsl -commands = python runtests.py {posargs} - +commands = coverage run --source django_elasticsearch_dsl runtests.py {posargs} deps = django-111: Django>=1.11,<2.0 - django-2: Django>=2.0,<2.1 + django-20: Django>=2.0,<2.1 django-21: Django>=2.1,<2.2 django-22: Django>=2.2,<2.3 django-30: Django>=3.0,<3.1 - es6: elasticsearch-dsl>=6.4.0,<7.0.0 - es7: elasticsearch-dsl>=7,<8 + es64: elasticsearch-dsl>=6.4.0,<7.0.0 + es74: elasticsearch-dsl>=7.4.0,<8 -r{toxinidir}/requirements_test.txt basepython =