Skip to content

Commit

Permalink
ci: add hadolint and flake8 linters
Browse files Browse the repository at this point in the history
  • Loading branch information
audrium committed Nov 17, 2020
1 parent f0f9e4f commit c711d5f
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 6 deletions.
20 changes: 20 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[flake8]
max-line-length = 89

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

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

max-complexity = 18

select = B,C,E,F,W,T4,B9
28 changes: 27 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,23 @@ jobs:
pip install black==19.10b0
./run-tests.sh --check-black
lint-flake8:
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 pep8, pyflakes and circular complexity
run: |
pip install --upgrade pip
pip install flake8
./run-tests.sh --check-flake8
lint-pydocstyle:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -122,11 +139,20 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml

lint-dockerfile:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Check Dockerfile compliance
run: ./run-tests.sh --check-dockerfile

docker-build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Build docker image
- name: Build Docker image
run: ./run-tests.sh --check-docker-build
11 changes: 7 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# This file is part of REANA.
# Copyright (C) 2017, 2018 CERN.
# Copyright (C) 2017, 2018, 2019, 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.

FROM fedora:25
# hadolint ignore=DL3041
RUN dnf -y update &&\
dnf install -y gcc gcc-c++ graphviz-devel ImageMagick python-devel libffi-devel openssl openssl-devel unzip nano autoconf automake libtool python-pip &&\
dnf install -y dnf redhat-rpm-config
ADD . /code
dnf install -y dnf redhat-rpm-config &&\
dnf clean all
COPY . /code
WORKDIR /code
# hadolint ignore=DL3013
RUN pip install --upgrade pip &&\
pip install -e .[all]
pip install -e '.[all]'
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ include LICENSE
include *.rst
include *.sh
include *.txt
include .flake8
include pytest.ini
recursive-include docs *.py
recursive-include docs *.png
Expand Down
12 changes: 12 additions & 0 deletions run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ check_black () {
black --check .
}

check_flake8 () {
flake8 .
}

check_manifest () {
check-manifest
}
Expand All @@ -36,6 +40,10 @@ check_pytest () {
python setup.py test
}

check_dockerfile () {
docker run -i --rm hadolint/hadolint < Dockerfile
}

check_docker_build () {
docker build -t reanahub/reana-workflow-monitor .
}
Expand All @@ -44,9 +52,11 @@ check_all () {
check_script
check_pydocstyle
check_black
check_flake8
check_manifest
check_sphinx
check_pytest
check_dockerfile
check_docker_build
}

Expand All @@ -61,9 +71,11 @@ do
--check-shellscript) check_script;;
--check-pydocstyle) check_pydocstyle;;
--check-black) check_black;;
--check-flake8) check_flake8;;
--check-manifest) check_manifest;;
--check-sphinx) check_sphinx;;
--check-pytest) check_pytest;;
--check-dockerfile) check_dockerfile;;
--check-docker-build) check_docker_build;;
*)
esac
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

# Get the version string. Cannot be done with import!
with open(os.path.join("reana_workflow_monitor", "version.py"), "rt") as f:
version = re.search('__version__\s*=\s*"(?P<version>.*)"\n', f.read()).group(
version = re.search(r'__version__\s*=\s*"(?P<version>.*)"\n', f.read()).group(
"version"
)

Expand Down

0 comments on commit c711d5f

Please sign in to comment.