Repository: inveniosoftware/invenio-db (language: python)

Issue:
global: migration to github-actions from travis



Discussion / hints:

Fix patch:
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
index ad3ee47..5d37d6f 100644
--- a/CONTRIBUTING.rst
+++ b/CONTRIBUTING.rst
@@ -122,5 +122,5 @@ Before you submit a pull request, check that it meets these guidelines:
 2. If the pull request adds functionality, the docs should be updated. Put
    your new functionality into a function with a docstring.
 3. The pull request should work for Python 2.7, 3.3, 3.4 and 3.5. Check
-   https://travis-ci.com/inveniosoftware/invenio-db/pull_requests
+   https://github.com/inveniosoftware/invenio-db/actions?query=event%3Apull_request
    and make sure that the tests pass for all supported Python versions.
diff --git a/MANIFEST.in b/MANIFEST.in
index c934065..efef656 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -22,3 +22,4 @@ recursive-include docs Makefile
 recursive-include invenio_db *.mako
 recursive-include invenio_db *.py
 recursive-include tests *.py
+recursive-include .github/workflows *.yml
diff --git a/README.rst b/README.rst
index 7a75898..9fa1c3b 100644
--- a/README.rst
+++ b/README.rst
@@ -12,8 +12,8 @@
 .. image:: https://img.shields.io/github/license/inveniosoftware/invenio-db.svg
         :target: https://github.com/inveniosoftware/invenio-db/blob/master/LICENSE
 
-.. image:: https://img.shields.io/travis/inveniosoftware/invenio-db.svg
-        :target: https://travis-ci.org/inveniosoftware/invenio-db
+.. image:: https://github.com/inveniosoftware/invenio-db/workflows/CI/badge.svg
+        :target: https://github.com/inveniosoftware/invenio-db/actions?query=workflow%3ACI
 
 .. image:: https://img.shields.io/coveralls/inveniosoftware/invenio-db.svg
         :target: https://coveralls.io/r/inveniosoftware/invenio-db
diff --git a/setup.py b/setup.py
index 5de07c7..ae31e9b 100644
--- a/setup.py
+++ b/setup.py
@@ -16,9 +16,9 @@
 history = open('CHANGES.rst').read()
 
 tests_require = [
-    'pytest-invenio>=1.4.0',
-    'cryptography>=2.1.4',
-    'mock>=4.0.0',
+    "pytest-invenio>=1.4.0",
+    "cryptography>=2.1.4",
+    "mock>=4.0.0"
 ]
 
 extras_require = {


Test patch:
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 3059580..c79d000 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -20,72 +20,32 @@ jobs:
     runs-on: ubuntu-20.04
     strategy:
       matrix:
-          python-version: [3.6, 3.7, 3.8]
-          services: [release-sqlite, release-pg9, release-pg10, release-pg11, release-pg12, release-mysql5, lowest-pg9, lowest-mysql5, lowest-sqlite]
+          python-version: [3.6, 3.7, 3.8, 3.9]
+          requirements-level: [min, pypi]
+          db-service: [postgresql9, postgresql11, mysql5]
+          exclude:
+          - python-version: 3.8
+            requirements-level: min
+
+          - python-version: 3.9
+            requirements-level: min
+
+          - db-service: postgresql11
+            python-version: 3.6
+
           include:
-          - services: release-sqlite
-            SQLALCHEMY_DATABASE_URI: "sqlite:///test.db"
-            EXTRAS: "docs,versioning,tests,sqlite"
-            REQUIREMENTS_LEVEL: "pypi"
-          - services: release-pg9
-            DB: postgresql
-            SQLALCHEMY_DATABASE_URI: "postgresql+psycopg2://invenio:invenio@localhost:5432/invenio"
-            POSTGRESQL_VERSION: POSTGRESQL_9_LATEST
-            EXTRAS: "docs,versioning,tests,postgresql"
-            REQUIREMENTS_LEVEL: "pypi"
-          - services: release-pg10
-            DB: postgresql
-            SQLALCHEMY_DATABASE_URI: "postgresql+psycopg2://invenio:invenio@localhost:5432/invenio"
-            POSTGRESQL_VERSION: POSTGRESQL_10_LATEST
-            EXTRAS: "docs,versioning,tests,postgresql"
-            REQUIREMENTS_LEVEL: "pypi"
-          - services: release-pg11
-            DB: postgresql
-            SQLALCHEMY_DATABASE_URI: "postgresql+psycopg2://invenio:invenio@localhost:5432/invenio"
-            POSTGRESQL_VERSION: POSTGRESQL_11_LATEST
-            EXTRAS: "docs,versioning,tests,postgresql"
-            REQUIREMENTS_LEVEL: "pypi"
-          - services: release-pg12
-            DB: postgresql
-            SQLALCHEMY_DATABASE_URI: "postgresql+psycopg2://invenio:invenio@localhost:5432/invenio"
-            POSTGRESQL_VERSION: POSTGRESQL_12_LATEST
-            EXTRAS: "docs,versioning,tests,postgresql"
-            REQUIREMENTS_LEVEL: "pypi"
-          - services: release-mysql5
-            DB: mysql
-            SQLALCHEMY_DATABASE_URI: "mysql+pymysql://invenio:invenio@localhost:3306/invenio"
-            MYSQL_VERSION: MYSQL_5_LATEST
-            EXTRAS: "docs,versioning,tests,mysql"
-            REQUIREMENTS_LEVEL: "pypi"
-          # NOTE: To reenable, add "release-mysql8" to "services" above.
-          # - services: release-mysql8
-          #   DB: mysql
-          #   SQLALCHEMY_DATABASE_URI: "mysql+pymysql://invenio:invenio@localhost:3306/invenio"
-          #   MYSQL_VERSION: MYSQL_8_LATEST
-          #   EXTRAS: "docs,versioning,tests,mysql"
-          #   REQUIREMENTS_LEVEL: "pypi"
-          - services: lowest-pg9
-            DB: postgresql
-            SQLALCHEMY_DATABASE_URI: "postgresql+psycopg2://invenio:invenio@localhost:5432/invenio"
-            POSTGRESQL_VERSION: POSTGRESQL_9_LATEST
-            EXTRAS: "docs,versioning,tests,postgresql"
-            REQUIREMENTS_LEVEL: "min"
-          - services: lowest-mysql5
-            DB: mysql
-            SQLALCHEMY_DATABASE_URI: "mysql+pymysql://invenio:invenio@localhost:3306/invenio"
-            MYSQL_VERSION: MYSQL_5_LATEST
-            EXTRAS: "docs,versioning,tests,postgresql"
-            REQUIREMENTS_LEVEL: "min"
-          - services: lowest-sqlite
-            SQLALCHEMY_DATABASE_URI: "sqlite:///test.db"
-            EXTRAS: "docs,versioning,tests,sqlite"
-            REQUIREMENTS_LEVEL: "min"
-    env:
-      SQLALCHEMY_DATABASE_URI: ${{matrix.SQLALCHEMY_DATABASE_URI}}
-      POSTGRESQL_VERSION: ${{matrix.POSTGRESQL_VERSION}}
-      MYSQL_VERSION: ${{matrix.MYSQL_VERSION}}
-      DB: ${{matrix.DB}}
+          - db-service: postgresql9
+            DB_EXTRAS: "postgresql"
 
+          - db-service: postgresql11
+            DB_EXTRAS: "postgresql"
+
+          - db-service: mysql5
+            DB_EXTRAS: "mysql"
+
+    env:
+      DB: ${{ matrix.db-service }}
+      EXTRAS: all,${{ matrix.DB_EXTRAS }}
     steps:
       - name: Checkout
         uses: actions/checkout@v2
@@ -98,18 +58,18 @@ jobs:
       - name: Generate dependencies
         run: |
           python -m pip install --upgrade pip setuptools py wheel requirements-builder
-          requirements-builder -e ${{ matrix.EXTRAS }} --level=${{ matrix.REQUIREMENTS_LEVEL }} setup.py > .${{ matrix.REQUIREMENTS_LEVEL }}-${{ matrix.python-version }}-requirements.txt
+          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') }}
+          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 -e .[all]
+          pip install -r .${{ matrix.requirements-level }}-${{ matrix.python-version }}-requirements.txt
+          pip install ".[$EXTRAS]"
           pip freeze
           docker --version
           docker-compose --version
diff --git a/run-tests.sh b/run-tests.sh
index c7bf096..aff9156 100755
--- a/run-tests.sh
+++ b/run-tests.sh
@@ -7,10 +7,23 @@
 # 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.
 
-docker-services-cli up ${DB} && \
-python -m check_manifest --ignore ".*-requirements.txt" && \
-python -m sphinx.cmd.build -qnNW docs docs/_build/html && \
+# 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
+
+
+python -m check_manifest --ignore ".*-requirements.txt"
+python -m sphinx.cmd.build -qnNW docs docs/_build/html
+eval "$(docker-services-cli up --db ${DB:-postgresql} --env)"
 python -m pytest
 tests_exit_code=$?
-docker-services-cli down
+python -m sphinx.cmd.build -qnNW -b doctest docs docs/_build/doctest
 exit "$tests_exit_code"