Skip to content

Commit

Permalink
Simplify Python linter workflows (#6577)
Browse files Browse the repository at this point in the history
Use pipx (preinstalled on GitHub-hosted runners), which takes care of
virtual environments for us. Remove the apt-get commands; we don't
actually need the packages that they're installing.
  • Loading branch information
SpecLad authored Jul 31, 2023
1 parent 5949ac3 commit 4c1ff85
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 25 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/bandit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,11 @@ jobs:
CHANGED_FILES="${{steps.files.outputs.all_changed_files}}"
if [[ ! -z $CHANGED_FILES ]]; then
sudo apt-get --no-install-recommends install -y build-essential curl python3-dev python3-pip python3-venv
python3 -m venv .env
. .env/bin/activate
pip install -U pip wheel setuptools
pip install bandit
pipx install bandit
echo "Bandit version: "$(bandit --version | head -1)
echo "The files will be checked: "$(echo $CHANGED_FILES)
bandit -a file --ini .bandit $CHANGED_FILES
deactivate
else
echo "No files with the \"py\" extension found"
fi
7 changes: 1 addition & 6 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,14 @@ jobs:
UPDATED_DIRS="${{steps.files.outputs.all_changed_files}}"
if [[ ! -z $UPDATED_DIRS ]]; then
sudo apt-get --no-install-recommends install -y build-essential curl python3-dev python3-pip python3-venv
python3 -m venv .env
. .env/bin/activate
pip install -U pip wheel setuptools
pip install $(egrep "black.*" ./cvat-cli/requirements/development.txt)
pipx install $(egrep "black.*" ./cvat-cli/requirements/development.txt)
echo "Black version: "$(black --version)
echo "The dirs will be checked: $UPDATED_DIRS"
EXIT_CODE=0
for DIR in $UPDATED_DIRS; do
black --check --diff $DIR || EXIT_CODE=$(($? | $EXIT_CODE)) || true
done
deactivate
exit $EXIT_CODE
else
echo "No files with the \"py\" extension found"
Expand Down
7 changes: 1 addition & 6 deletions .github/workflows/isort.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,14 @@ jobs:
UPDATED_DIRS="${{steps.files.outputs.all_changed_files}}"
if [[ ! -z $UPDATED_DIRS ]]; then
sudo apt-get --no-install-recommends install -y build-essential curl python3-dev python3-pip python3-venv
python3 -m venv .env
. .env/bin/activate
pip install -U pip wheel setuptools
pip install $(egrep "isort.*" ./cvat-cli/requirements/development.txt)
pipx install $(egrep "isort.*" ./cvat-cli/requirements/development.txt)
echo "isort version: $(isort --version-number)"
echo "The dirs will be checked: $UPDATED_DIRS"
EXIT_CODE=0
for DIR in $UPDATED_DIRS; do
isort --check $DIR || EXIT_CODE=$(($? | $EXIT_CODE)) || true
done
deactivate
exit $EXIT_CODE
else
echo "No files with the \"py\" extension found"
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,15 @@ jobs:
CHANGED_FILES="${{steps.files.outputs.all_changed_files}}"
if [[ ! -z $CHANGED_FILES ]]; then
sudo apt-get --no-install-recommends install -y build-essential curl python3-dev python3-pip python3-venv
python3 -m venv .env
. .env/bin/activate
pip install -U pip wheel setuptools
pip install $(egrep "pylint.*==.*" ./cvat/requirements/development.txt)
pip install $(egrep "django==.*" ./cvat/requirements/base.txt)
pipx install $(egrep "^pylint==" ./cvat/requirements/development.txt)
pipx inject pylint \
$(egrep "^pylint-.+==" ./cvat/requirements/development.txt) \
$(egrep "^django==" ./cvat/requirements/base.txt)
echo "Pylint version: "$(pylint --version | head -1)
echo "The files will be checked: "$(echo $CHANGED_FILES)
pylint $CHANGED_FILES
deactivate
else
echo "No files with the \"py\" extension found"
fi

0 comments on commit 4c1ff85

Please sign in to comment.