Skip to content

Commit

Permalink
ci: capture output of both
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianmtr committed Feb 23, 2021
1 parent a7640a1 commit 54bc525
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 25 deletions.
28 changes: 3 additions & 25 deletions .github/workflows/ci.yml
Expand Up @@ -82,31 +82,9 @@ jobs:
- id: file_changes
uses: jitterbit/get-changed-files@v1
- name: docstring check with darglint and pydocstyle
run: |
pip install darglint==1.6.0
pip install pydocstyle==5.1.1
echo ====================================================================================
echo DOCSTRINGS LINT: checking ${{ steps.file_changes.outputs.all }}
echo ------------------------------------------------------------------------------------
echo 'removing files under /tests...'
arrVar=()
# we ignore tests files
for changed_file in ${{ steps.file_changes.outputs.all }}; do
if [[ ${changed_file}} != tests/* ]]; then
echo keeping ${changed_file}
arrVar+=(${changed_file})
fi
done
# required in order to get the status of all the files at once
darglint -v 2 -s sphinx "${arrVar[@]}"; export DARGLINT_STATUS=$?; pydocstyle --select=D101,D102,D103 "${arrVar[@]}"; export PYDOCSTYLE_STATUS=$?
if [[ $DARGLINT_STATUS -eq 0 ]] && [[ $DARGLINT_STATUS -eq 0 ]]; then
echo 'failed'
exit 0
else:
echo 'OK'
exit 1
fi
echo ====================================================================================
run: ./scripts/docstrings_lint.sh
env:
CHANGED_FILES: ${{ steps.file_changes.outputs.all }}

prep-testbed:
runs-on: ubuntu-18.04
Expand Down
30 changes: 30 additions & 0 deletions scripts/docstrings_lint.sh
@@ -0,0 +1,30 @@
#!/bin/bash
# required in order to get the status of all the files at once
err=0
trap 'err=1' ERR
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 54bc525

Please sign in to comment.