Repository: barseghyanartur/django-elasticsearch-dsl-drf (language: python)

Issue:
Migrate to GitHub actions



Discussion / hints:
Hi,
I would like to work on this,
Thanks
@tanvimoharir:

Please, do. I like [this structure](https://github.com/barseghyanartur/valuta/blob/master/.github/workflows/test.yml) (matches the needs of most of the projects I worked on). Although, better ideas are welcome. A couple of TODOs (not yet clear to me): how to make it nicely integrate with coveralls.io. Please, work in a branch. Contact me for a key to coveralls.io (when needed), but I consider that a "part 2". What's most important, is to test against both ES6 and ES7 as long as they are supported by this package (latest releases from both branches).
P.S.

For this project, retry feature is important (used to happen with travis sometimes that once in a while, some test would fail and re-running it would fix the problem). If no alternative feature exists on the GitHub actions side, there's a [pytest plugin](https://github.com/pytest-dev/pytest-rerunfailures) doing the same thing.
> @tanvimoharir:
> 
> Please, do. I like [this structure](https://github.com/barseghyanartur/valuta/blob/master/.github/workflows/test.yml) (matches the needs of most of the projects I worked on). Although, better ideas are welcome. A couple of TODOs (not yet clear to me): how to make it nicely integrate with coveralls.io. Please, work in a branch. Contact me for a key to coveralls.io (when needed), but I consider that a "part 2". What's most important, is to test against both ES6 and ES7 as long as they are supported by this package (latest releases from both branches).

Sure, I will start following this structure from a different branch. You should be adding the keys directly as secrets (Refer https://docs.github.com/en/actions/reference/encrypted-secrets) and I can include the variable name itself.
@barseghyanartur  I could not create a branch on the repo so I forked it.
I have added a workflow but I might need to make some changes.
Also, could you please take a look at 
https://github.com/tanvimoharir/django-elasticsearch-dsl-drf/runs/2878200609?check_suite_focus=true#step:3:15
@tanvimoharir:

Yep, that's a very valid question. Is it possible to run Elasticsearch on GitHub actions?
A tiny update. I figured out how to make Coveralls work with GitHub actions.

Fix patch:
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index fd00ac00..00000000
--- a/.travis.yml
+++ /dev/null
@@ -1,94 +0,0 @@
-dist: xenial
-
-services:
-  - elasticsearch
-
-language: python
-
-# Almost full matrix is presented here, except for Django 3.0 in combination
-# with Elasticsearch 6.x. This limitation is due to limitation of the
-# django-elasticsearch-dsl library to support multiple versions of
-# Elasticsearch (and as a result, Django 3.0 support which is added in
-# recent versions is only available for Elasticsearch 7.x).
-
-matrix:
-  fast_finish: true
-  include:
-  - env: TOX_ENV=py36-django22-elasticsearch7
-    python: 3.6
-  - env: TOX_ENV=py36-django30-elasticsearch7
-    python: 3.6
-  - env: TOX_ENV=py36-django31-elasticsearch7
-    python: 3.6
-
-  - env: TOX_ENV=py36-django22-elasticsearch6 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
-    python: 3.6
-  - env: TOX_ENV=py36-django30-elasticsearch6 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
-    python: 3.6
-  - env: TOX_ENV=py36-django31-elasticsearch6 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
-    python: 3.6
-
-  - env: TOX_ENV=py37-django22-elasticsearch7
-    python: 3.7
-  - env: TOX_ENV=py37-django30-elasticsearch7
-    python: 3.7
-  - env: TOX_ENV=py37-django31-elasticsearch7
-    python: 3.7
-
-  - env: TOX_ENV=py37-django22-elasticsearch6 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
-    python: 3.7
-  - env: TOX_ENV=py37-django30-elasticsearch6 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
-    python: 3.7
-  - env: TOX_ENV=py37-django31-elasticsearch6 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
-    python: 3.7
-
-  - env: TOX_ENV=py38-django22-elasticsearch7
-    python: 3.8
-  - env: TOX_ENV=py38-django30-elasticsearch7
-    python: 3.8
-  - env: TOX_ENV=py38-django31-elasticsearch7
-    python: 3.8
-
-  - env: TOX_ENV=py38-django22-elasticsearch6 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
-    python: 3.8
-  - env: TOX_ENV=py38-django30-elasticsearch6 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
-    python: 3.8
-  - env: TOX_ENV=py38-django31-elasticsearch6 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
-    python: 3.8
-
-  - env: TOX_ENV=py39-django22-elasticsearch7
-    python: 3.9
-  - env: TOX_ENV=py39-django30-elasticsearch7
-    python: 3.9
-  - env: TOX_ENV=py39-django31-elasticsearch7
-    python: 3.9
-
-  - env: TOX_ENV=py39-django22-elasticsearch6 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
-    python: 3.9
-  - env: TOX_ENV=py39-django30-elasticsearch6 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
-    python: 3.9
-  - env: TOX_ENV=py39-django31-elasticsearch6 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
-    python: 3.9
-
-env:
-  global:
-    - ES_APT_URL=https://artifacts.elastic.co/packages/7.x/apt
-
-before_install:
-#  - curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.5.4.deb && sudo dpkg -i --force-confnew elasticsearch-6.5.4.deb && sudo service elasticsearch restart
-  - 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
-
-install: pip install -r examples/requirements/test.txt
-
-before_script:
-  - sleep 10
-
-script: travis_retry tox -e $TOX_ENV
-
-after_success:
-  - pip install coveralls
-  - coveralls
diff --git a/examples/requirements/django_3_0.txt b/examples/requirements/django_3_0.txt
deleted file mode 100755
index 585b0d7f..00000000
--- a/examples/requirements/django_3_0.txt
+++ /dev/null
@@ -1,10 +0,0 @@
--r common.txt
--r test.txt
-
-Django>=3.0,<3.1
-django-cors-headers==3.2.0
-django-debug-toolbar>=2.1
-django-debug-toolbar-force>=0.1.7
-django-elasticsearch-debug-toolbar>=2.0
-django-ormex>=0.2.1
-djangorestframework>=3.11.0,<3.12
diff --git a/examples/requirements/django_3_2.txt b/examples/requirements/django_3_2.txt
new file mode 100644
index 00000000..5856a981
--- /dev/null
+++ b/examples/requirements/django_3_2.txt
@@ -0,0 +1,8 @@
+Django>=3.2,<3.3
+django-cors-headers==3.7.0
+django-debug-toolbar>=3.2
+django-debug-toolbar-force>=0.1.7
+django-elasticsearch-debug-toolbar>=2.0
+django-ormex>=0.2.1
+djangorestframework>=3.12.0,<3.13
+
diff --git a/tox.ini b/tox.ini
index 2b57f5fe..b97de5d2 100755
--- a/tox.ini
+++ b/tox.ini
@@ -1,6 +1,6 @@
 [tox]
 envlist =
-    py{36,37,38,39}-django{22,30,31}-elasticsearch{6,7}
+    py{36,37,38,39}-django{22,31,32}-elasticsearch{6,7}
 
 [testenv]
 envlogdir=
@@ -10,8 +10,8 @@ envlogdir=
 passenv = *
 deps =
     django22: -r{toxinidir}/examples/requirements/django_2_2.txt
-    django30: -r{toxinidir}/examples/requirements/django_3_0.txt
     django31: -r{toxinidir}/examples/requirements/django_3_1.txt
+    django32: -r{toxinidir}/examples/requirements/django_3_2.txt
     elasticsearch6: -r{toxinidir}/examples/requirements/elastic_6x.txt
     elasticsearch7: -r{toxinidir}/examples/requirements/elastic_7x.txt
 ;    coreapischema: -r{toxinidir}/examples/requirements/coreapi_coreschema.txt


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 00000000..0a30fd2e
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,105 @@
+name: Test CI
+
+on:
+  push:
+    branches: [ main, master ]
+  pull_request:
+    branches: [ main, master ]
+
+jobs:
+  test:
+    name: Test
+    runs-on: ubuntu-latest
+    strategy:
+      fail-fast: false
+      matrix:
+        python-version: ['3.6', '3.7', '3.8', '3.9']
+        es-version: ['6', '7']
+        include:
+        - python-version: 3.6
+          tox_env: py36-django22-elasticsearch7
+        - python-version: 3.6
+          tox_env: py36-django31-elasticsearch7
+        - python-version: 3.6
+          tox_env: py36-django32-elasticsearch7
+
+        - python-version: 3.6
+          tox_env: py36-django22-elasticsearch6
+        - python-version: 3.6
+          tox_env: py36-django31-elasticsearch6 
+        - python-version: 3.6
+          tox_env: py36-django32-elasticsearch6
+
+        - python-version: 3.7
+          tox_env: py37-django22-elasticsearch7
+        - python-version: 3.7
+          tox_env: py37-django31-elasticsearch7
+        - python-version: 3.7
+          tox_env: py37-django32-elasticsearch7
+
+        - python-version: 3.7
+          tox_env: py37-django22-elasticsearch6 
+        - python-version: 3.7
+          tox_env: py37-django31-elasticsearch6 
+        - python-version: 3.7
+          tox_env: py37-django32-elasticsearch6
+
+        - python-version: 3.8
+          tox_env: py38-django22-elasticsearch7
+        - python-version: 3.8
+          tox_env: py38-django31-elasticsearch7
+        - python-version: 3.8
+          tox_env: py38-django32-elasticsearch7
+
+        - python-version: 3.8
+          tox_env: py38-django22-elasticsearch6 
+        - python-version: 3.8
+          tox_env: py38-django31-elasticsearch6 
+        - python-version: 3.8
+          tox_env: py38-django32-elasticsearch6
+
+        - python-version: 3.9
+          tox_env: py39-django22-elasticsearch7
+        - python-version: 3.9
+          tox_env: py39-django31-elasticsearch7
+        - python-version: 3.9
+          tox_env: py39-django32-elasticsearch7
+
+        - python-version: 3.9
+          tox_env: py39-django22-elasticsearch6 
+        - python-version: 3.9
+          tox_env: py39-django31-elasticsearch6
+        - python-version: 3.9
+          tox_env: py39-django32-elasticsearch6
+
+    services:
+      elasticsearch:
+        image: bitnami/elasticsearch:${{ matrix.es-version }}
+        ports:
+          - 9200:9200
+        options: >-
+          -e="discovery.type=single-node"
+          --health-cmd="curl http://localhost:9200/_cluster/health"
+          --health-interval=10s
+          --health-timeout=5s
+          --health-retries=10
+
+    steps:
+    - uses: actions/checkout@v2
+    - name: Set up Python ${{ matrix.python-version }}
+      uses: actions/setup-python@v2
+      with:
+        python-version: ${{ matrix.python-version }}
+    - name: Install dependencies
+      run: |
+        python -m pip install --upgrade pip setuptools wheel
+        python -m pip install tox
+        python -m pip install -r examples/requirements/test.txt
+    - name: Run tests
+      uses: nick-invision/retry@v2
+      with:
+        command: tox -e ${{ matrix.tox_env }} -- --color yes
+        timeout_minutes: 15
+        max_attempts: 3
+    - name: Upload to Codecov
+      uses: codecov/codecov-action@v2