diff --git a/.github/codecov.yml b/.github/codecov.yml new file mode 100644 index 0000000..a023978 --- /dev/null +++ b/.github/codecov.yml @@ -0,0 +1,20 @@ +codecov: + require_ci_to_pass: yes + +coverage: + precision: 2 + round: down + range: "80...100" + +parsers: + gcov: + branch_detection: + conditional: yes + loop: yes + method: no + macro: no + +comment: + layout: "reach,diff,flags,tree" + behavior: default + require_changes: no diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..fe43bec --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,128 @@ +# This file is part of REANA. +# Copyright (C) 2020 CERN. +# +# REANA 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, pull_request] + +jobs: + lint-shellcheck: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Runs shell script static analysis + run: | + sudo apt-get install shellcheck + ./run-tests.sh --check-shellscript + + lint-black: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Check Python code formatting + run: | + pip install --upgrade pip + pip install black==19.10b0 + ./run-tests.sh --check-black + + lint-pydocstyle: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Check compliance with Python docstring conventions + run: | + pip install --upgrade pip + pip install pydocstyle + ./run-tests.sh --check-pydocstyle + + lint-check-manifest: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Check Python manifest completeness + run: | + pip install --upgrade pip + pip install check-manifest + ./run-tests.sh --check-manifest + + docs-sphinx: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Install system dependencies + run: | + sudo apt-get update -y + sudo apt install libcurl4-openssl-dev libssl-dev + sudo apt-get install libgnutls28-dev + + - name: Install Python dependencies + run: | + pip install --upgrade pip setuptools py + pip install -e .[all] + + - name: Run Sphinx documentation with doctests + run: ./run-tests.sh --check-sphinx + + python-tests: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.6, 3.7, 3.8] + + 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: Install Python dependencies + run: | + pip install --upgrade pip setuptools py + pip install twine wheel + pip install -e .[all] + + - name: Run pytest + run: ./run-tests.sh --check-pytest + + - name: Codecov Coverage + if: matrix.python-version == 3.8 + uses: codecov/codecov-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: coverage.xml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index cab76c5..0000000 --- a/.travis.yml +++ /dev/null @@ -1,38 +0,0 @@ -# This file is part of REANA. -# Copyright (C) 2018 CERN. -# -# REANA 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 - -sudo: true - -language: python - -cache: - - pip - -services: - - docker - -matrix: - fast_finish: true - include: - - python: 3.6 - - python: 3.7 - - python: 3.8 - -before_install: - - travis_retry pip install --upgrade pip setuptools py - - travis_retry pip install twine wheel coveralls - -install: - - travis_retry pip install -e .[all] - -script: - - ./run-tests.sh - -after_success: - - coveralls diff --git a/README.rst b/README.rst index 8ab6a64..e74f585 100644 --- a/README.rst +++ b/README.rst @@ -5,14 +5,14 @@ REANA DB .. image:: https://img.shields.io/pypi/pyversions/reana-db.svg :target: https://pypi.org/pypi/reana-db -.. image:: https://img.shields.io/travis/reanahub/reana-db.svg - :target: https://travis-ci.org/reanahub/reana-db +.. image:: https://github.com/reanahub/reana-db/workflows/CI/badge.svg + :target: https://github.com/reanahub/reana-db/actions .. image:: https://readthedocs.org/projects/reana-db/badge/?version=latest :target: https://reana-db.readthedocs.io/en/latest/?badge=latest -.. image:: https://img.shields.io/coveralls/reanahub/reana-db.svg - :target: https://coveralls.io/r/reanahub/reana-db +.. image:: https://codecov.io/gh/reanahub/reana-db/branch/master/graph/badge.svg + :target: https://codecov.io/gh/reanahub/reana-db .. image:: https://badges.gitter.im/Join%20Chat.svg :target: https://gitter.im/reanahub/reana?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge diff --git a/pytest.ini b/pytest.ini index 2c404d1..387920f 100644 --- a/pytest.ini +++ b/pytest.ini @@ -5,4 +5,4 @@ # under the terms of the MIT License; see LICENSE file for more details. [pytest] -addopts = --ignore=docs --cov=reana_db --cov-report=term-missing +addopts = --ignore=docs --cov=reana_db --cov-report=term-missing --cov-report=xml diff --git a/run-tests.sh b/run-tests.sh index ebf420a..18662b6 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -15,7 +15,7 @@ set -o nounset export REANA_SQLALCHEMY_DATABASE_URI=postgresql+psycopg2://postgres:mysecretpassword@localhost/postgres # Verify that db container is running before continuing -_check_ready() { +_check_ready () { RETRIES=40 while ! $2 do @@ -29,11 +29,11 @@ _check_ready() { done } -_db_check() { +_db_check () { docker exec --user postgres postgres__reana-db bash -c "pg_isready" &>/dev/null; } -clean_old_db_container() { +clean_old_db_container () { OLD="$(docker ps --all --quiet --filter=name=postgres__reana-db)" if [ -n "$OLD" ]; then echo '==> [INFO] Cleaning old DB container...' @@ -41,29 +41,67 @@ clean_old_db_container() { fi } -start_db_container() { +start_db_container () { echo '==> [INFO] Starting DB container...' docker run --rm --name postgres__reana-db -p 5432:5432 -e POSTGRES_PASSWORD=mysecretpassword -d postgres _check_ready "Postgres" _db_check } -stop_db_container() { +stop_db_container () { echo '==> [INFO] Stopping DB container...' docker stop postgres__reana-db } -check_black() { - echo '==> [INFO] Checking Black compliance...' +check_script () { + shellcheck run-tests.sh +} + +check_pydocstyle () { + pydocstyle reana_db +} + +check_black () { black --check . } -pydocstyle reana_db -check_black -check-manifest --ignore ".travis-*" -sphinx-build -qnNW docs docs/_build/html -clean_old_db_container -start_db_container -python setup.py test -stop_db_container -sphinx-build -qnNW -b doctest docs docs/_build/doctest -echo '==> [INFO] All tests passed! ✅' +check_manifest () { + check-manifest +} + +check_sphinx () { + sphinx-build -qnNW docs docs/_build/html +} + +check_pytest () { + clean_old_db_container + start_db_container + python setup.py test + stop_db_container +} + +check_all () { + check_script + check_pydocstyle + check_black + check_manifest + check_sphinx + check_pytest +} + +if [ $# -eq 0 ]; then + check_all + exit 0 +fi + +for arg in "$@" +do + case $arg in + --check-shellscript) check_script;; + --check-pydocstyle) check_pydocstyle;; + --check-black) check_black;; + --check-manifest) check_manifest;; + --check-sphinx) check_sphinx;; + --check-pytest) check_pytest;; + *) + esac +done