From 8c2103038480f2256cafc977c12c75a6172e4c9f Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Wed, 3 Apr 2024 00:17:21 +0200 Subject: GitHub: add action to check for unused imports (cherry picked from commit 74198e68a6edbdb36a6103a7666de530bdd71696) --- .github/workflows/unused-imports.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/unused-imports.yml (limited to '.github/workflows') diff --git a/.github/workflows/unused-imports.yml b/.github/workflows/unused-imports.yml new file mode 100644 index 000000000..6bb3d2cc7 --- /dev/null +++ b/.github/workflows/unused-imports.yml @@ -0,0 +1,23 @@ +name: Pylint + +on: [push] + +jobs: + build: + 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: | + make unused-imports -- cgit v1.2.3 From ca84e6845e6cfeb5f4f5798594b390afb735901f Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Wed, 3 Apr 2024 21:12:26 +0200 Subject: GitHub: run unused imports action only for pull requests (cherry picked from commit 8205e3cf918142a55e00c00dc241a6a30914fbd9) --- .github/workflows/unused-imports.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/unused-imports.yml b/.github/workflows/unused-imports.yml index 6bb3d2cc7..83098ddf6 100644 --- a/.github/workflows/unused-imports.yml +++ b/.github/workflows/unused-imports.yml @@ -1,6 +1,7 @@ -name: Pylint - -on: [push] +name: Check for unused imports using Pylint +on: + pull_request_target: + types: [opened, reopened, ready_for_review, locked] jobs: build: @@ -20,4 +21,9 @@ jobs: pip install pylint - name: Analysing the code with pylint run: | - make unused-imports + 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 -- cgit v1.2.3