Skip to content

Commit

Permalink
ci: added github actions workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
audrium committed Oct 28, 2020
1 parent 7969764 commit f2b4dfa
Show file tree
Hide file tree
Showing 6 changed files with 208 additions and 60 deletions.
20 changes: 20 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -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
128 changes: 128 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
38 changes: 0 additions & 38 deletions .travis.yml

This file was deleted.

8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
72 changes: 55 additions & 17 deletions run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,41 +29,79 @@ _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...'
docker stop postgres__reana-db
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

0 comments on commit f2b4dfa

Please sign in to comment.