From 11aa24e38f118db8a241a1a440568db337e278cf Mon Sep 17 00:00:00 2001 From: Antonio Vivace Date: Tue, 8 Dec 2020 08:54:50 +0100 Subject: [PATCH] Migrate to gh-actions --- .github/workflows/pypi-publish.yml | 35 ++++++++++++ .github/workflows/tests.yml | 47 +++++++--------- .travis.yml | 87 ------------------------------ CONTRIBUTING.rst | 2 +- MANIFEST.in | 1 + README.rst | 4 +- pytest.ini | 1 + run-tests.sh | 16 +++--- setup.py | 2 +- 9 files changed, 67 insertions(+), 128 deletions(-) create mode 100644 .github/workflows/pypi-publish.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/pypi-publish.yml b/.github/workflows/pypi-publish.yml new file mode 100644 index 00000000..556367a7 --- /dev/null +++ b/.github/workflows/pypi-publish.yml @@ -0,0 +1,35 @@ +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 + # Remove `compile_catalog` if the package has no translations. + run: | + python setup.py compile_catalog sdist bdist_wheel + + - name: Publish on PyPI + uses: pypa/gh-action-pypi-publish@v1.3.1 + with: + user: __token__ + # The token is provided by the inveniosoftware organization + password: ${{ secrets.pypi_token }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index de6dbcf1..be81ea4b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,12 +20,16 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - python-version: [3.6, 3.7, 3.8] - python-requirements: [min, pypi] + 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 - python-requirements: min + requirements-level: min + + - python-version: 3.9 + requirements-level: min - db-service: postgresql11 python-version: 3.6 @@ -35,34 +39,21 @@ jobs: include: - db-service: postgresql9 - DB: postgresql - POSTGRESQL_VERSION: POSTGRESQL_9_LATEST - SQLALCHEMY_DATABASE_URI: "postgresql+psycopg2://invenio:invenio@localhost:5432/invenio" - EXTRAS: "all,postgresql" + DB_EXTRAS: "postgresql" - db-service: postgresql11 - DB: postgresql - POSTGRESQL_VERSION: POSTGRESQL_11_LATEST - SQLALCHEMY_DATABASE_URI: "postgresql+psycopg2://invenio:invenio@localhost:5432/invenio" - EXTRAS: "all,postgresql" + DB_EXTRAS: "postgresql" - db-service: mysql5 - DB: mysql - MYSQL_VERSION: MYSQL_5_LATEST - SQLALCHEMY_DATABASE_URI: "mysql+pymysql://invenio:invenio@localhost:3306/invenio" - EXTRAS: "all,mysql" + DB_EXTRAS: "mysql" - db-service: mysql8 - DB: mysql - MYSQL_VERSION: MYSQL_8_LATEST - SQLALCHEMY_DATABASE_URI: "mysql+pymysql://invenio:invenio@localhost:3306/invenio" - EXTRAS: "all,mysql" - env: - SQLALCHEMY_DATABASE_URI: ${{matrix.SQLALCHEMY_DATABASE_URI}} - POSTGRESQL_VERSION: ${{matrix.POSTGRESQL_VERSION}} - MYSQL_VERSION: ${{matrix.MYSQL_VERSION}} - DB: ${{ matrix.DB }} + DB_EXTRAS: "mysql" + env: + CACHE: ${{ matrix.cache-service }} + DB: ${{ matrix.db-service }} + EXTRAS: all,${{ matrix.DB_EXTRAS }} steps: - name: Checkout uses: actions/checkout@v2 @@ -75,18 +66,18 @@ jobs: - name: Generate dependencies run: | python -m pip install --upgrade pip setuptools py wheel requirements-builder - requirements-builder -e ${{ matrix.EXTRAS }} --level=${{ matrix.python-requirements }} setup.py > .${{ matrix.python-requirements }}-${{ 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.python-requirements }}-${{ 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.python-requirements}}-${{ matrix.python-version }}-requirements.txt - pip install .[${{ matrix.EXTRAS }}] + pip install -r .${{ matrix.requirements-level }}-${{ matrix.python-version }}-requirements.txt + pip install ".[$EXTRAS]" pip freeze docker --version docker-compose --version diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 67752611..00000000 --- a/.travis.yml +++ /dev/null @@ -1,87 +0,0 @@ -# -*- coding: utf-8 -*- -# -# This file is part of Invenio. -# Copyright (C) 2015-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. - -addons: - postgresql: 9.4 - firefox: "49.0" - apt: - packages: - - xvfb - -notifications: - email: false - -language: python - -matrix: - fast_finish: true - allow_failures: - - env: REQUIREMENTS=devel E2E_WEBDRIVER_BROWSERS="" EXTRAS=all,sqlite SQLALCHEMY_DATABASE_URI="sqlite:///test.db" - - env: REQUIREMENTS=devel E2E_WEBDRIVER_BROWSERS="" EXTRAS=all,mysql SQLALCHEMY_DATABASE_URI="mysql+pymysql://travis@localhost:3306/invenio" - - env: REQUIREMENTS=devel E2E_WEBDRIVER_BROWSERS="" EXTRAS=all,postgresql SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://postgres@localhost:5432/invenio" - - python: "3.8" - -before_cache: - - "rm -f $HOME/selenium/geckodriver-v0.11.1-linux32.tar.gz" - -cache: - pip: true - directories: - - $HOME/selenium - -services: - - mysql - - postgresql - - redis - - xvfb - -env: - - REQUIREMENTS=lowest E2E_WEBDRIVER_BROWSERS="" EXTRAS=all,sqlite SQLALCHEMY_DATABASE_URI="sqlite:///test.db" - - REQUIREMENTS=lowest E2E_WEBDRIVER_BROWSERS="" EXTRAS=all,mysql SQLALCHEMY_DATABASE_URI="mysql+pymysql://travis@localhost:3306/invenio" - - REQUIREMENTS=lowest E2E_WEBDRIVER_BROWSERS="" EXTRAS=all,postgresql SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://postgres@localhost:5432/invenio" - - REQUIREMENTS=release E2E_WEBDRIVER_BROWSERS="" EXTRAS=all,sqlite SQLALCHEMY_DATABASE_URI="sqlite:///test.db" - - REQUIREMENTS=release E2E_WEBDRIVER_BROWSERS="" EXTRAS=all,mysql SQLALCHEMY_DATABASE_URI="mysql+pymysql://travis@localhost:3306/invenio" - - REQUIREMENTS=release E2E_WEBDRIVER_BROWSERS="Firefox" EXTRAS=all,postgresql SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://postgres@localhost:5432/invenio" - - REQUIREMENTS=devel E2E_WEBDRIVER_BROWSERS="" EXTRAS=all,sqlite SQLALCHEMY_DATABASE_URI="sqlite:///test.db" - - REQUIREMENTS=devel E2E_WEBDRIVER_BROWSERS="" EXTRAS=all,mysql SQLALCHEMY_DATABASE_URI="mysql+pymysql://travis@localhost:3306/invenio" - - REQUIREMENTS=devel E2E_WEBDRIVER_BROWSERS="" 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" - - "if [ ! -f $HOME/selenium/geckodriver ]; then wget https://github.com/mozilla/geckodriver/releases/download/v0.11.1/geckodriver-v0.11.1-linux32.tar.gz -P $HOME/selenium; tar xvfz $HOME/selenium/geckodriver-v0.11.1-linux32.tar.gz -C $HOME/selenium; fi" - - "PATH=$PATH:$HOME/selenium" - -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: "Cz3TIh93zaYcO/JviDqyqMdGc8sMl7F9VJdIBqDBaX+B8HBLHFRUhd5EcSkh7hBi3SVbbdvR5qU+YwjpiBQ4Tilihg8DphBQoixUfl5UORlSfndO/w6JVnVdbG81NXOksSm0hC/nJ/aft8PZ/4l65QXcGiiJVjw9UfxTMPpyf1R1ey6vsK8zT/ImtVgIUdDiDmp3/NIwnBQb+9cSK5qCy16/qrohcrt0HQXJr41j/9ckD3wGCYbbhJ05sAvVaupgED7YOPGZW0R6BUJ44pliaxS5R1bIUkva5QOgSAIEhrINAXmhbmCh7qflo1LAFh1hj+vX9AcSzDp3G0J6iIZzG3sfEhcNZDQMNO9cXBCOYOFVLR6C5Dkfe85FaDYD9yVPzX49Vai7X2q7gV0s4aEvevhs1SYtMCkZgHSBmlELrJ/olYF8/DL1cZpm8B6iCuoY8HHIp8OwaDqZ3LHscadKVo9TdLdFsC7rTo0HyDDuvl+zf1Nahy5Px6iyHf+SjfTj320ypxch0AU+BQbdbXjuq/dmAIJ3b7isKI9TgUCQkQPrQBg5e5co9fnVbKBCfO8DLq6GLxNu43HMkCX0WyVINBq73eFKLVTzpGEm8qF3lSbPbEJGR3jsvpPPW1BOv29/oFVwqbdB5ikt1kueTUq6KS7AyN/2qo4hItJb3oGjYcg=" - distributions: "compile_catalog sdist bdist_wheel" - skip_existing: true - on: - tags: true diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index e1f3cc85..2e573279 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -121,5 +121,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.org/inveniosoftware/invenio-accounts/pull_requests + https://github.com/inveniosoftware/invenio-accounts/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 33ac4a37..f5dd7da9 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -28,3 +28,4 @@ recursive-include invenio_accounts *.txt recursive-include invenio_accounts *.po *.pot *.mo recursive-include invenio_accounts *.py recursive-include tests *.py +recursive-include .github/workflows *.yml diff --git a/README.rst b/README.rst index 26541f49..3464e4f6 100644 --- a/README.rst +++ b/README.rst @@ -12,8 +12,8 @@ .. image:: https://img.shields.io/github/license/inveniosoftware/invenio-accounts.svg :target: https://github.com/inveniosoftware/invenio-accounts/blob/master/LICENSE -.. image:: https://img.shields.io/travis/inveniosoftware/invenio-accounts.svg - :target: https://travis-ci.org/inveniosoftware/invenio-accounts +.. image:: https://github.com/inveniosoftware/invenio-accounts/workflows/CI/badge.svg + :target: https://github.com/inveniosoftware/invenio-accounts/actions?query=workflow%3ACI .. image:: https://img.shields.io/coveralls/inveniosoftware/invenio-accounts.svg :target: https://coveralls.io/r/inveniosoftware/invenio-accounts diff --git a/pytest.ini b/pytest.ini index 7e9a77b2..c5c708ac 100644 --- a/pytest.ini +++ b/pytest.ini @@ -8,3 +8,4 @@ [pytest] addopts = --isort --pydocstyle --pycodestyle --doctest-glob="*.rst" --doctest-modules --cov=invenio_accounts --cov-report=term-missing +testpaths = tests invenio_accounts \ No newline at end of file diff --git a/run-tests.sh b/run-tests.sh index b69eec40..6efe8ac1 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -2,14 +2,11 @@ # -*- 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. -# Usage: -# env DB=postgresql ./run-tests.sh - # Quit on errors set -o errexit @@ -17,15 +14,16 @@ set -o errexit set -o nounset # Always bring down docker services -function cleanup { - docker-services-cli down +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 -docker-services-cli up redis ${DB:-} +eval "$(docker-services-cli up --db ${DB:-postgresql} --cache ${CACHE:-redis} --env)" python -m pytest -python -m sphinx.cmd.build -qnNW -b doctest docs docs/_build/doctest tests_exit_code=$? -exit "$tests_exit_code" +python -m sphinx.cmd.build -qnNW -b doctest docs docs/_build/doctest +exit "$tests_exit_code" \ No newline at end of file diff --git a/setup.py b/setup.py index 68a4881c..7b06ecb3 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ history = open('CHANGES.rst').read() tests_require = [ - 'pytest-invenio>=1.4.0', + "pytest-invenio>=1.4.0" ] extras_require = {