From 96f26d2a50f39f08da2bde9ff77554d56bde4eae Mon Sep 17 00:00:00 2001 From: Maksudul Haque Date: Sun, 25 Jul 2021 18:32:52 +0600 Subject: [PATCH 1/6] Move the test suite to GitHub Actions --- .github/workflows/ci.yml | 80 ++++++++++++++++++++++++++++++++++++++++ .travis.yml | 62 ------------------------------- CONTRIBUTING.rst | 2 +- README.rst | 10 ++--- tox.ini | 9 ++--- 5 files changed, 90 insertions(+), 73 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..523e6081 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,80 @@ +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"] + 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: Configure Sysctl Limits for Elasticsearch + run: | + sudo swapoff -a + sudo sysctl -w vm.swappiness=1 + sudo sysctl -w fs.file-max=262144 + sudo sysctl -w vm.max_map_count=262144 + + - name: Runs 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 codecov + 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/tox.ini b/tox.ini index 599dad26..a2e62c90 100644 --- a/tox.ini +++ b/tox.ini @@ -1,21 +1,20 @@ [tox] envlist = py27-django-111-es7 - {py36,py37,py38}-django-{111,2,21,22,30}-{es7} + {py36,py37,py38}-django-{111,20,21,22,30}-{es64,es7} [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 + es64: elasticsearch-dsl>=6.4.0,<7.0.0 es7: elasticsearch-dsl>=7,<8 -r{toxinidir}/requirements_test.txt From 984243b1f3e6319e1f3ce7696dd58a66df306290 Mon Sep 17 00:00:00 2001 From: Maksudul Haque Date: Sun, 25 Jul 2021 20:33:40 +0600 Subject: [PATCH 2/6] Fix brken test --- tests/test_fields.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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() ) From 60fb3a5e097d147183bf62256ef1598aedb1cfdf Mon Sep 17 00:00:00 2001 From: Maksudul Haque Date: Sun, 25 Jul 2021 20:35:57 +0600 Subject: [PATCH 3/6] Update ci step name --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 523e6081..2a26b58f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,7 +43,7 @@ jobs: sudo sysctl -w fs.file-max=262144 sudo sysctl -w vm.max_map_count=262144 - - name: Runs Elasticsearch + - name: Install and Run Elasticsearch uses: elastic/elastic-github-actions/elasticsearch@master with: stack-version: ${{ matrix.es-version }} From 46460a9b0ef357b257ecee787d7224fd3245dc42 Mon Sep 17 00:00:00 2001 From: Maksudul Haque Date: Sun, 25 Jul 2021 20:49:19 +0600 Subject: [PATCH 4/6] Change elasticsearch-dsl version --- .github/workflows/ci.yml | 2 +- tox.ini | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2a26b58f..9d0aea99 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: 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"] + es-dsl-version: ["6.4", "7.4"] es-version: ["7.13.4"] exclude: diff --git a/tox.ini b/tox.ini index a2e62c90..696893c4 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ [tox] envlist = - py27-django-111-es7 - {py36,py37,py38}-django-{111,20,21,22,30}-{es64,es7} + py27-django-111-es74 + {py36,py37,py38}-django-{111,20,21,22,30}-{es64,es74} [testenv] setenv = @@ -15,7 +15,7 @@ deps = django-22: Django>=2.2,<2.3 django-30: Django>=3.0,<3.1 es64: elasticsearch-dsl>=6.4.0,<7.0.0 - es7: elasticsearch-dsl>=7,<8 + es74: elasticsearch-dsl>=7.4.0,<8 -r{toxinidir}/requirements_test.txt basepython = From 3f893679ebe1658982f2b272d832dc981d1ed2e0 Mon Sep 17 00:00:00 2001 From: Maksudul Haque Date: Mon, 26 Jul 2021 13:17:45 +0600 Subject: [PATCH 5/6] Remove unused dependency --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9d0aea99..8e6f5b52 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,7 +66,6 @@ jobs: - name: Install Dependencies run: | python -m pip install --upgrade pip - python -m pip install codecov 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 From 3d0032b1101f8e12b9ce37a974d1bdabcacbd6b7 Mon Sep 17 00:00:00 2001 From: Maksudul Haque Date: Wed, 11 Aug 2021 15:25:13 +0600 Subject: [PATCH 6/6] Remove Configure Sysctl Limits block --- .github/workflows/ci.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8e6f5b52..a699a73d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,13 +36,6 @@ jobs: django-version: "2.1" steps: - - name: Configure Sysctl Limits for Elasticsearch - run: | - sudo swapoff -a - sudo sysctl -w vm.swappiness=1 - sudo sysctl -w fs.file-max=262144 - sudo sysctl -w vm.max_map_count=262144 - - name: Install and Run Elasticsearch uses: elastic/elastic-github-actions/elasticsearch@master with: