Skip to content

Commit

Permalink
USHIFT-1030: Install pylint in virtual environment for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
chiragkyal committed Apr 9, 2023
1 parent 1aa57ef commit 651db57
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,7 @@ verify-sh:

.PHONY: verify-py
verify-py:
@if ! command -v pylint &>/dev/null; then \
pip3 install pylint ; \
fi
pylint --variable-naming-style=any \
$$(find . -type d \( -path ./_output -o -path ./vendor -o -path ./assets -o -path ./etcd/vendor \) -prune -o -name '*.py' -print)
./hack/verify-py.sh

###############################
# post install validate #
Expand Down
25 changes: 25 additions & 0 deletions hack/verify-py.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

ROOTDIR=$(git rev-parse --show-toplevel)
REQ_FILE=${ROOTDIR}/requirements.txt
VENV="/tmp/venv"
PYLINT="pylint"

if ! command -v ${PYLINT} &>/dev/null; then

check="$(python3 -m pip install -r ${REQ_FILE} 2>&1 | { grep 'Permission denied' || true; })"

# Install pylint in a virtual environment for CI
if [ ! -z "$check" ] ; then
printf "Installing pylint in '${VENV}' virtual environment"
python3 -m venv ${VENV}
${VENV}/bin/python3 -m pip install --upgrade pip
${VENV}/bin/python3 -m pip install -r ${REQ_FILE}
PYLINT="/tmp/venv/bin/pylint"
fi
fi

PYFILES=$(find . -type d \( -path ./_output -o -path ./vendor -o -path ./assets -o -path ./etcd/vendor \) -prune -o -name '*.py' -print)
printf "Running ${PYLINT} for \n${PYFILES}\n"

${PYLINT} --variable-naming-style=any ${PYFILES}
7 changes: 7 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PyGithub==1.56
GitPython==3.1.18
PyYAML==3.12
tabulate==0.8.10
tqdm==4.64.1
jira==3.2.0
pylint==2.13.9

0 comments on commit 651db57

Please sign in to comment.