diff --git a/.editorconfig b/.editorconfig index 24719be0..f807958c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -34,8 +34,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 00000000..dee02385 --- /dev/null +++ b/.github/workflows/pypi-publish.yml @@ -0,0 +1,33 @@ +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.8 + + - 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/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..1a0ae622 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,95 @@ +# -*- 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] + cache-service: [redis] + db-service: [postgresql9, postgresql11, mysql5, mysql8] + exclude: + - python-version: 3.8 + requirements-level: min + + - python-version: 3.9 + requirements-level: min + + - db-service: postgresql11 + python-version: 3.6 + + - db-service: mysql8 + python-version: 3.6 + + include: + - db-service: postgresql9 + DB_EXTRAS: "postgresql" + + - db-service: postgresql11 + DB_EXTRAS: "postgresql" + + - db-service: mysql5 + DB_EXTRAS: "mysql" + + - db-service: mysql8 + DB_EXTRAS: "mysql" + + env: + CACHE: ${{ matrix.cache-service }} + DB: ${{ matrix.db-service }} + EXTRAS: all,${{ matrix.DB_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/.travis.yml b/.travis.yml deleted file mode 100644 index 892f1c61..00000000 --- a/.travis.yml +++ /dev/null @@ -1,77 +0,0 @@ -# -*- coding: utf-8 -*- -# -# This file is part of Invenio. -# Copyright (C) 2015-2018 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. - -notifications: - email: false - -language: python - -matrix: - fast_finish: true - allow_failures: - - env: REQUIREMENTS=devel EXTRAS=all,sqlite SQLALCHEMY_DATABASE_URI="sqlite:///test.db" - - env: REQUIREMENTS=devel EXTRAS=all,mysql SQLALCHEMY_DATABASE_URI="mysql+pymysql://root@localhost:3306/invenio" - - env: REQUIREMENTS=devel EXTRAS=all,postgresql SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://postgres@localhost:5432/invenio" - - python: 3.8 - -cache: - - pip - -services: - - mysql - - postgresql - - redis-server - -env: - - REQUIREMENTS=lowest EXTRAS=all,sqlite SQLALCHEMY_DATABASE_URI="sqlite:///test.db" - - REQUIREMENTS=lowest EXTRAS=all,mysql SQLALCHEMY_DATABASE_URI="mysql+pymysql://root@localhost:3306/invenio" - - REQUIREMENTS=lowest EXTRAS=all,postgresql SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://postgres@localhost:5432/invenio" - - REQUIREMENTS=release EXTRAS=all,sqlite SQLALCHEMY_DATABASE_URI="sqlite:///test.db" - - REQUIREMENTS=release EXTRAS=all,mysql SQLALCHEMY_DATABASE_URI="mysql+pymysql://root@localhost:3306/invenio" - - REQUIREMENTS=release EXTRAS=all,postgresql SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://postgres@localhost:5432/invenio" DEPLOY=true - - REQUIREMENTS=devel EXTRAS=all,sqlite SQLALCHEMY_DATABASE_URI="sqlite:///test.db" - - REQUIREMENTS=devel EXTRAS=all,mysql SQLALCHEMY_DATABASE_URI="mysql+pymysql://root@localhost:3306/invenio" - - REQUIREMENTS=devel EXTRAS=all,postgresql SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://postgres@localhost:5432/invenio" - -python: - - "3.6" - - "3.7" - - "3.8" - -before_install: - - "pip uninstall -y six" - - "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" - - "mysql -e 'CREATE DATABASE IF NOT EXISTS invenio;'" - - "mysql -e 'GRANT ALL ON invenio.* TO 'root'@'localhost';' -uroot;" - - "psql -c 'CREATE DATABASE invenio;' -U postgres" - -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: inveniosoftware - password: - secure: "WUU11aLRd9ttsk+pvnXJu6Kq4cXhgcjT0UcDMQ1rtOZg+FulHOXMEKqPiHWZxob01hmRkYKHGF0yM6kEE1cvTP2dSPC91YVwQvANmoV9TUXU35vEOlY4iOcZhfKGzM67Sx7Idh78ildCSm834+nP7iTB60TtNqxWDn839S9GpvHxyJLwblOkYxZWIrlGJ2dE41NxjGUDnmU/Js8s+yCORN1ckkIMGbO2ZkSCqwmWj+DhceEz9JBgeEyO5x2Zp0uqaUtM4gnUA+dkWqAhwLvwtsLvI7zF5ihHZGYEeHdRdEG8J43t+2MieTq+LkAh+mggTrfP5BeCnA0kATCuHeIYycgXVOX8fCaH789x9dsIkWXHGXsFz9Qb7pYKUCQZXOhMwCecaM4mXspIHjl1GZZx5FBQ3hkZu/ogIoAUmjd8q1gLi5oq+ZNIExXoPuzRnXQT5/qTapV+c+r7w1BIOX03Z2+RxyDCZsdIiICAYzAv5kQjFqyTB9nosNFuDyn1ZZIHWXCZ8lAJnbTj/ha3cafH1957K/r6RItl+rEpZCT0DnaG0ChBqdqqze33/+L45Bp95ALA+nEB1FcyqVGFTl8J68YFBHGeW7U+IvwuC16S03cRGbe0s1xtcxilshT27PnyBERyM9r1Ub61QytlOt6a9FlVbxpgCIbffhWxfAbjHBw=" - distributions: "compile_catalog sdist bdist_wheel" - skip_existing: true - on: - tags: true - python: "3.6" - condition: $DEPLOY = true diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 2c8e9b1c..836ae67f 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -120,6 +120,6 @@ Before you submit a pull request, check that it meets these guidelines: 1. The pull request should include tests and must not decrease test coverage. 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.org/inveniosoftware/invenio-access/pull_requests +3. The pull request should work for Python 3.6, 3.7, 3.8 and 3.9. Check + https://github.com/inveniosoftware/invenio-access/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 2dbbe0b5..c36b92bc 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -27,3 +27,4 @@ recursive-include invenio_access *.po recursive-include invenio_access *.pot recursive-include invenio_access *.py recursive-include tests *.py +recursive-include .github/workflows *.yml diff --git a/README.rst b/README.rst index a1771318..5b1b2c5d 100644 --- a/README.rst +++ b/README.rst @@ -12,8 +12,8 @@ .. image:: https://img.shields.io/github/license/inveniosoftware/invenio-access.svg :target: https://github.com/inveniosoftware/invenio-access/blob/master/LICENSE -.. image:: https://img.shields.io/travis/inveniosoftware/invenio-access.svg - :target: https://travis-ci.org/inveniosoftware/invenio-access +.. image:: https://github.com/inveniosoftware/invenio-access/workflows/CI/badge.svg + :target: https://github.com/inveniosoftware/invenio-access/actions?query=workflow%3ACI .. image:: https://img.shields.io/coveralls/inveniosoftware/invenio-access.svg :target: https://coveralls.io/r/inveniosoftware/invenio-access diff --git a/pytest.ini b/pytest.ini index b6f87ebd..a32fc2ac 100644 --- a/pytest.ini +++ b/pytest.ini @@ -7,5 +7,5 @@ # under the terms of the MIT License; see LICENSE file for more details. [pytest] -pep8ignore = docs/conf.py ALL -addopts = --pep8 --doctest-glob="*.rst" --doctest-modules --cov=invenio_access --cov-report=term-missing +addopts = --isort --pydocstyle --pycodestyle --doctest-glob="*.rst" --doctest-modules --cov=invenio_access --cov-report=term-missing +testpaths = tests invenio_access diff --git a/run-tests.sh b/run-tests.sh index 4f206a26..28814f10 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -1,16 +1,29 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash # -*- coding: utf-8 -*- # # This file is part of Invenio. -# Copyright (C) 2015-2018 CERN. +# 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. -export PYTEST_ADDOPTS='docs tests invenio_access' +# Quit on errors +set -o errexit -pydocstyle invenio_access tests docs && \ -isort -rc -c -df && \ -check-manifest --ignore ".travis-*" && \ -sphinx-build -qnNW docs docs/_build/html && \ -python setup.py test +# 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" +eval "$(docker-services-cli up --db ${DB:-postgresql} --cache ${CACHE:-redis} --env)" +python -m pytest +tests_exit_code=$? +python -m sphinx.cmd.build -qnNW docs docs/_build/html +python -m sphinx.cmd.build -qnNW -b doctest docs docs/_build/doctest +exit "$tests_exit_code" diff --git a/setup.py b/setup.py index 10b2a6ed..d9930dd2 100644 --- a/setup.py +++ b/setup.py @@ -18,20 +18,14 @@ tests_require = [ 'SQLAlchemy-Continuum>=1.2.1', 'cachelib>=0.1', - 'check-manifest>=0.25', - 'coverage>=4.0', - 'isort>=4.3.0', 'mock>=1.0.0', - 'pydocstyle>=1.0.0', - 'pytest-cov>=1.8.0', - 'pytest-pep8>=1.0.6', - 'pytest>=3.6.0', - 'redis>=2.10.3' + 'redis>=2.10.5', + 'pytest-invenio>=1.4.0' ] extras_require = { 'docs': [ - 'Sphinx>=1.8.4,<3', + 'Sphinx>=3', ], 'mysql': [ 'invenio-db[mysql]>=1.0.0',