Skip to content

Commit

Permalink
CI: Add Github Actions
Browse files Browse the repository at this point in the history
Added Github Action CI workflow
Addded Codecov for code coverage
Remove Travis CI and Coveralls
Added Flake8
  • Loading branch information
Parth Shandilya committed Oct 12, 2020
1 parent 252b3fb commit 92404ce
Show file tree
Hide file tree
Showing 9 changed files with 215 additions and 67 deletions.
19 changes: 19 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[flake8]
max-line-length = 89

exclude =
build
dist
docs
coverage.xml
cernopendata_client.egg-info
.*/
env/
.git
__pycache__

ignore = E203, E231, E266, E501, W503, F403, F401, W605

max-complexity = 18

select = B,C,E,F,W,T4,B9
137 changes: 137 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
name: CI

on:
push:
branches: master
pull_request:
branches: master

jobs:
Lint-black:
runs-on: ubuntu-latest
steps:
- 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 black
./run-tests.sh --check-black
Lint-pydocstyle:
runs-on: ubuntu-latest
steps:
- 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 pydocstyle
./run-tests.sh --check-pydocstyle
Lint-flake8:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Check compliance with pep8, pyflakes and circular complexity
run: |
pip install flake8
./run-tests.sh --check-flake8
Lint-check-manifest:
runs-on: ubuntu-latest
steps:
- 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 check-manifest
./run-tests.sh --check-manifest
Docs-sphinx:
runs-on: ubuntu-latest
steps:
- 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: [2.7, 3.6, 3.7, 3.8]

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- 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 pytest
run: ./run-tests.sh --pytest

- name: Codecov Coverage
if: matrix.python-version == 3.8
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml

Docker-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Build and Run
run: |
docker build -t cernopendata/cernopendata-client .
docker run --rm cernopendata/cernopendata-client version
45 changes: 0 additions & 45 deletions .travis.yml

This file was deleted.

2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
include *.rst
include *.sh
include *.yml
include .flake8
include Dockerfile
include LICENSE
include docs/requirements.txt
Expand Down
2 changes: 1 addition & 1 deletion cernopendata_client/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ def parse_parameters(filter_input):
try:
filters = " ".join(filter_input).split(",")
return filters
except:
except Exception:
raise click.BadParameter("Wrong input format \n")
2 changes: 1 addition & 1 deletion cernopendata_client/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def validate_range(range=None, count=None):
param_hint=["--filter-range"],
)
range_from, range_to = int(range.split("-")[0]), int(range.split("-")[-1])
except:
except Exception:
raise click.BadParameter(
"Range should have start and end index(i-j)",
param_hint=["--filter-range"],
Expand Down
20 changes: 20 additions & 0 deletions 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
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
# it under the terms of the GPLv3 license; see LICENSE file for more details.

[pytest]
addopts = --ignore=docs --cov=cernopendata_client --cov-report=term-missing
addopts = --ignore=docs --cov=cernopendata_client --cov-report xml
53 changes: 34 additions & 19 deletions run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,37 @@ set -o errexit
# Quit on unbound symbols
set -o nounset

# Check compliance with Python docstring conventions
pydocstyle cernopendata_client

# Check Python code formatting
if which black; then
black --check .
fi

# Check Python manifest completeness
check-manifest --ignore ".travis-*"

# Check Sphinx documentation
sphinx-build -qnNW docs docs/_build/html

# Run test suite
python setup.py test

# Check Sphinx documentation with doctests
sphinx-build -qnNW -b doctest docs docs/_build/doctest
for arg in "$@"
do
case $arg in
--check-black) # Check Python code formatting
black --check .
;;
--check-pydocstyle) # Check compliance with Python docstring conventions
pydocstyle cernopendata_client
;;
--check-flake8) # Check compliance with pep8, pyflakes and circular complexity
flake8 .
;;
--check-manifest) # Check Python manifest completeness
check-manifest
;;
--check-sphinx) # Check Sphinx documentation with doctests
sphinx-build -qnNW docs docs/_build/html
sphinx-build -qnNW -b doctest docs docs/_build/doctest
;;
--pytest) # Run test suite
python setup.py test
;;
--all) # Run all tests locally
black --check .
pydocstyle cernopendata_client
flake8 .
check-manifest
sphinx-build -qnNW docs docs/_build/html
sphinx-build -qnNW -b doctest docs docs/_build/doctest
python setup.py test
;;
*)
esac
done

0 comments on commit 92404ce

Please sign in to comment.