Skip to content

Commit

Permalink
Makefile: improve "unused-imports" target
Browse files Browse the repository at this point in the history
  • Loading branch information
c-po committed Apr 4, 2024
1 parent 9b4a3bc commit faa1535
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 26 deletions.
39 changes: 15 additions & 24 deletions .github/workflows/unused-imports.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,20 @@
name: Check for unused imports using Pylint
on:
pull_request_target:
types: [opened, reopened, ready_for_review, locked]
on: push
# pull_request_target:
# types: [opened, reopened, ready_for_review, locked]

jobs:
build:
Check-Unused-Imports:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
- name: Analysing the code with pylint
run: |
tmp=$(git ls-files *.py | xargs pylint | grep W0611 | wc -l)
if [[ $tmp -gt 0 ]]; then
echo "Found $tmp occurrence of unused Python import statements!"
exit 1
fi
exit 0
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
- name: Analysing the code with pylint
run: make unused-imports
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ SHIM_DIR := src/shim
LIBS := -lzmq
CFLAGS :=
BUILD_ARCH := $(shell dpkg-architecture -q DEB_BUILD_ARCH)

J2LINT := $(shell command -v j2lint 2> /dev/null)
PYLINT_FILES := $(shell git ls-files *.py)

config_xml_src = $(wildcard interface-definitions/*.xml.in)
config_xml_obj = $(config_xml_src:.xml.in=.xml)
Expand Down Expand Up @@ -114,7 +114,7 @@ sonar:

.PHONY: unused-imports
unused-imports:
git ls-files *.py | xargs pylint | grep W0611
@pylint --disable=all --enable=W0611 $(PYLINT_FILES)

deb:
dpkg-buildpackage -uc -us -tc -b
Expand Down

0 comments on commit faa1535

Please sign in to comment.