Repository: inveniosoftware/invenio-query-parser (language: python)

Issue:
global: migrate CI to GH actions



Discussion / hints:

Fix patch:
diff --git a/.editorconfig b/.editorconfig
index 5fa7bd5..4a9cd6f 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -46,8 +46,8 @@ indent_size = 4
 [*.{css,html,js,json,yml}]
 indent_size = 2
 
-# Matches the exact files either package.json or .travis.yml
-[{package.json,.travis.yml}]
+# Matches the exact files either package.json or .github/workflows/*.yml
+[{package.json, .github/workflows/*.yml}]
 indent_size = 2
 
 # Dockerfile
diff --git a/.github/workflows/pypi-publish.yml b/.github/workflows/pypi-publish.yml
new file mode 100644
index 0000000..a158b22
--- /dev/null
+++ b/.github/workflows/pypi-publish.yml
@@ -0,0 +1,41 @@
+# -*- coding: utf-8 -*-
+#
+# This file is part of Invenio.
+# Copyright (C) 2020 CERN.
+#
+# Invenio is free software; you can redistribute it and/or modify it
+# under the terms of the MIT License; see LICENSE file for more details.
+
+name: Publish
+
+on:
+  push:
+    tags:
+      - v*
+
+jobs:
+  Publish:
+    runs-on: ubuntu-20.04
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v2
+
+      - name: Set up Python
+        uses: actions/setup-python@v2
+        with:
+          python-version: 3.7
+
+      - name: Install dependencies
+        run: |
+          python -m pip install --upgrade pip
+          pip install setuptools wheel
+
+      - name: Build package
+        run: |
+          python setup.py sdist bdist_wheel
+
+      - name: Publish on PyPI
+        uses: pypa/gh-action-pypi-publish@v1.3.1
+        with:
+          user: __token__
+          password: ${{ secrets.pypi_token }}
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 7632abd..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,67 +0,0 @@
-# This file is part of Invenio-Query-Parser.
-# Copyright (C) 2014, 2015, 2016 CERN.
-#
-# Invenio-Query-Parser is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation; either version 2 of the
-# License, or (at your option) any later version.
-#
-# Invenio-Query-Parser is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Invenio; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
-#
-# In applying this licence, CERN does not waive the privileges and immunities
-# granted to it by virtue of its status as an Intergovernmental Organization
-# or submit itself to any jurisdiction.
-
-notifications:
-  email: false
-
-sudo: false
-
-language: python
-
-cache:
-  - pip
-
-env:
-  - REQUIREMENTS=lowest EXTRAS=docs,tests,elasticsearch
-  - REQUIREMENTS=release EXTRAS=docs,tests,elasticsearch
-  - REQUIREMENTS=devel EXTRAS=docs,tests,elasticsearch
-
-python:
-  - "2.7"
-  - "3.5"
-
-before_install:
-  - "travis_retry pip install --upgrade pip setuptools py"
-  - "travis_retry pip install twine wheel coveralls requirements-builder"
-  - "requirements-builder --level=min setup.py > .travis-lowest-requirements.txt"
-  - "requirements-builder --level=pypi setup.py > .travis-release-requirements.txt"
-  - "requirements-builder --level=dev --req requirements-devel.txt setup.py > .travis-devel-requirements.txt"
-
-install:
-  - "travis_retry pip install -r .travis-${REQUIREMENTS}-requirements.txt"
-  - "travis_retry pip install -e .[${EXTRAS}]"
-
-script:
-  - "./run-tests.sh"
-
-after_success:
-  - coveralls
-
-deploy:
-  provider: pypi
-  user: jirikuncar
-  password:
-    secure: QD2ZJ4Oyj4ykvT2uASsLWHUTEHY9cIp0WibRyrTJWFG8uQAPHGFtYNuNTXCP4XOrEFx0OHL6Om+YrsgYT1eR7Aj7GA84TCXcEuPmdQxFdgQuOdvP/jYJyuD1MY5Lf8GdC0m4VdRwm+92d7DCiYSkFwVFzidUtc/eyVdBi3Ay/Iw=
-  distributions: "sdist bdist_wheel"
-  on:
-    python: "2.7"
-    repo: inveniosoftware/invenio-query-parser
-    tags: true
diff --git a/MANIFEST.in b/MANIFEST.in
index 786d448..b661f9e 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -30,3 +30,4 @@ include LICENSE
 include MAINTAINERS
 include tests/*.ini tests/*.py
 include tox.ini
+recursive-include .github/workflows *.yml
diff --git a/README.rst b/README.rst
index b9bea52..0f3aea7 100644
--- a/README.rst
+++ b/README.rst
@@ -2,8 +2,8 @@
  Invenio-Query-Parser
 ======================
 
-.. image:: https://travis-ci.org/inveniosoftware/invenio-query-parser.png?branch=master
-   :target: https://travis-ci.org/inveniosoftware/invenio-query-parser
+.. image:: https://github.com/inveniosoftware/invenio-query-parser/actions?query=workflow%3ACI.png?branch=master
+   :target: https://github.com/inveniosoftware/invenio-query-parser/actions?query=workflow%3ACI
 .. image:: https://coveralls.io/repos/inveniosoftware/invenio-query-parser/badge.png?branch=master
    :target: https://coveralls.io/r/inveniosoftware/invenio-query-parser
 .. image:: https://pypip.in/v/invenio-query-parser/badge.png
diff --git a/setup.py b/setup.py
index a41bdd0..f1f6f56 100644
--- a/setup.py
+++ b/setup.py
@@ -38,17 +38,25 @@
     ).group('version')
 
 tests_require = [
-    'check-manifest>=0.25',
-    'coverage>=4.0.0',
-    'isort>=4.2.2',
-    'pydocstyle>=1.0.0',
     'pytest-cache>=1.0',
-    'pytest-cov>=2.1.0',
-    'pytest-pep8>=1.0.6',
     'pytest-runner>=2.7.0',
-    'pytest>=2.8.0',
+    'pytest-invenio>=1.4.0'
 ]
 
+extras_require = {
+    'docs': [
+        'sphinx_rtd_theme>=0.1.9',
+    ],
+    'elasticsearch': [
+        'elasticsearch-dsl>=2.0.0',
+    ],
+    'tests': tests_require,
+}
+
+extras_require["all"] = []
+for reqs in extras_require.values():
+    extras_require["all"].extend(reqs)
+
 setup(
     name='invenio-query-parser',
     version=version,
@@ -66,19 +74,9 @@
         'ordereddict>=1.1',
         'six>=1.10.0',
     ],
-    extras_require={
-        'docs': [
-            'sphinx_rtd_theme>=0.1.9',
-        ],
-        'elasticsearch': [
-            'elasticsearch-dsl>=2.0.0',
-        ],
-        'tests': tests_require,
-    },
+    extras_require=extras_require,
     tests_require=tests_require,
     classifiers=[
-        'Programming Language :: Python :: 2',
-        'Programming Language :: Python :: 2.7',
         'Programming Language :: Python :: 3',
         'Programming Language :: Python :: 3.5',
         'Programming Language :: Python :: Implementation :: CPython',


Test patch:
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
new file mode 100644
index 0000000..e5efa9b
--- /dev/null
+++ b/.github/workflows/tests.yml
@@ -0,0 +1,84 @@
+# -*- coding: utf-8 -*-
+#
+# This file is part of Invenio.
+# Copyright (C) 2020 CERN.
+#
+# Invenio is free software; you can redistribute it and/or modify it
+# under the terms of the MIT License; see LICENSE file for more details.
+
+name: CI
+
+on:
+  push:
+    branches: master
+  pull_request:
+    branches: master
+  schedule:
+    # * is a special character in YAML so you have to quote this string
+    - cron:  '0 3 * * 6'
+  workflow_dispatch:
+    inputs:
+      reason:
+        description: 'Reason'
+        required: false
+        default: 'Manual trigger'
+
+jobs:
+  Tests:
+    runs-on: ubuntu-20.04
+    strategy:
+      matrix:
+          python-version: [3.6, 3.7, 3.8, 3.9]
+          requirements-level: [min, pypi]
+          search-service: [elasticsearch6, elasticsearch7]
+          exclude:
+          - python-version: 3.8
+            requirements-level: min
+
+          - python-version: 3.9
+            requirements-level: min
+
+          - search-service: elasticsearch7
+            python-version: 3.6
+          include:
+
+          - search-service: elasticsearch6
+            SEARCH_EXTRAS: "elasticsearch6"
+
+          - search-service: elasticsearch7
+            SEARCH_EXTRAS: "elasticsearch7"
+
+    env:
+      SEARCH: ${{ matrix.search-service }}
+      EXTRAS: all,${{ matrix.SEARCH_EXTRAS }}
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v2
+
+      - name: Set up Python ${{ matrix.python-version }}
+        uses: actions/setup-python@v2
+        with:
+          python-version: ${{ matrix.python-version }}
+
+      - name: Generate dependencies
+        run: |
+          python -m pip install --upgrade pip setuptools py wheel requirements-builder
+          requirements-builder -e "$EXTRAS" --level=${{ matrix.requirements-level }} setup.py > .${{ matrix.requirements-level }}-${{ matrix.python-version }}-requirements.txt
+
+      - name: Cache pip
+        uses: actions/cache@v2
+        with:
+          path: ~/.cache/pip
+          key: ${{ runner.os }}-pip-${{ hashFiles('.${{ matrix.requirements-level }}-${{ matrix.python-version }}-requirements.txt') }}
+
+      - name: Install dependencies
+        run: |
+          pip install -r .${{ matrix.requirements-level }}-${{ matrix.python-version }}-requirements.txt
+          pip install ".[$EXTRAS]"
+          pip freeze
+          docker --version
+          docker-compose --version
+
+      - name: Run tests
+        run: |
+          ./run-tests.sh
diff --git a/pytest.ini b/pytest.ini
index 5580305..f13ef37 100644
--- a/pytest.ini
+++ b/pytest.ini
@@ -20,4 +20,5 @@
 # or submit itself to any jurisdiction.
 
 [pytest]
-addopts = --pep8 --ignore=docs --cov=invenio_query_parser --cov-report=term-missing
+addopts = --isort --pydocstyle --pycodestyle --doctest-glob="*.rst" --doctest-modules --cov=invenio_query_parser --cov-report=term-missing
+testpaths = tests invenio_query_parser
diff --git a/run-tests.sh b/run-tests.sh
index 7219a36..cb4b100 100755
--- a/run-tests.sh
+++ b/run-tests.sh
@@ -1,29 +1,29 @@
-#!/bin/sh
+#!/usr/bin/env bash
+# -*- coding: utf-8 -*-
 #
-# This file is part of Invenio-Query-Parser.
-# Copyright (C) 2016 CERN.
+# This file is part of Invenio.
+# Copyright (C) 2020 CERN.
 #
-# Invenio-Query-Parser is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation; either version 2 of the
-# License, or (at your option) any later version.
-#
-# Invenio-Query-Parser is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Invenio; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
-#
-# In applying this licence, CERN does not waive the privileges and immunities
-# granted to it by virtue of its status as an Intergovernmental Organization
-# or submit itself to any jurisdiction.
+# Invenio is free software; you can redistribute it and/or modify it
+# under the terms of the MIT License; see LICENSE file for more details.
+
+# Quit on errors
+set -o errexit
+
+# Quit on unbound symbols
+set -o nounset
+
+# Always bring down docker services
+function cleanup() {
+    eval "$(docker-services-cli down --env)"
+}
+trap cleanup EXIT
+
 
-# pydocstyle invenio_query_parser && \
-isort -rc -c -df **/*.py && \
-check-manifest --ignore ".travis-*" && \
-sphinx-build -qnNW docs docs/_build/html && \
-python setup.py test # && \
-# sphinx-build -qnNW -b doctest docs docs/_build/doctest
+python -m check_manifest --ignore ".*-requirements.txt"
+python -m sphinx.cmd.build -qnNW docs docs/_build/html
+eval "$(docker-services-cli up --search ${SEARCH:-elasticsearch} --env)"
+python -m pytest
+tests_exit_code=$?
+python -m sphinx.cmd.build -qnNW -b doctest docs docs/_build/doctest
+exit "$tests_exit_code"