Skip to content

Commit

Permalink
ci: add darglint to ci (#2007)
Browse files Browse the repository at this point in the history
* ci: add darglint to ci

* ci: add test file to validate

* ci: add test file to validate

* ci: add pydocstyle and dummy files

* ci: testing docstrings linter

* ci: add test file to validate

* ci: add test file to validate

* ci: add test file to validate

* ci: add test file to validate

* ci: add test file to validate

* ci: add test file to validate

* ci: add test file to validate

* ci: debug changed file in loop

* ci: debug changed file in loop

* ci: rename workflow add echo

* ci: test printing all outputs

* ci: testing docstring linter

* ci: capture output of both

* ci: remove dummy files

Co-authored-by: cristian mtr <cristian.mitroi@jina.ai>
  • Loading branch information
bwanglzu and cristianmtr committed Feb 24, 2021
1 parent 8090dac commit 0f6b961
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -69,6 +69,23 @@ jobs:
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude .git,__pycache__,docs/source/conf.py,old,build,dist,tests/,jina/hub/
check-docstring:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- id: file_changes
uses: jitterbit/get-changed-files@v1
- name: docstring check with darglint and pydocstyle
run: ./scripts/docstrings_lint.sh
env:
CHANGED_FILES: ${{ steps.file_changes.outputs.all }}

prep-testbed:
runs-on: ubuntu-18.04
steps:
Expand Down
28 changes: 28 additions & 0 deletions scripts/docstrings_lint.sh
@@ -0,0 +1,28 @@
#!/bin/bash
# required in order to get the status of all the files at once
pip install darglint==1.6.0
pip install pydocstyle==5.1.1
echo ====================================================================================
echo DOCSTRINGS LINT: checking $CHANGED_FILES
echo ------------------------------------------------------------------------------------
echo 'removing files under /tests...'
arrVar=()
# we ignore tests files
for changed_file in $CHANGED_FILES; do
if [[ ${changed_file}} != tests/* ]]; then
echo keeping ${changed_file}
arrVar+=(${changed_file})
fi
done
DARGLINT_OUTPUT=$(darglint -v 2 -s sphinx "${arrVar[@]}"); PYDOCSTYLE_OUTPUT=$(pydocstyle --select=D101,D102,D103 "${arrVar[@]}")
# status captured here
if [[ -z "$PYDOCSTYLE_OUTPUT" ]] && [[ -z "$DARGLINT_OUTPUT" ]]; then
echo 'OK'
exit 0
else
echo 'failure'
echo $DARGLINT_OUTPUT
echo $PYDOCSTYLE_OUTPUT
exit 1
fi
echo ====================================================================================

0 comments on commit 0f6b961

Please sign in to comment.