Skip to content

Commit f7c1cf7

Browse files
committed
CI: scan all Python scripts
Now that commit b1781ef established a pattern to find all shell scripts for linting, do the same for all Python scripts. This way, adding a file anywhere in the repository will be sufficient to ensure it is scanned, instead of hoping that we remember to amend the lint invocations. Signed-off-by: Robie Basak <[email protected]>
1 parent 8812cf3 commit f7c1cf7

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

.github/workflows/static-checks.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,38 @@ jobs:
2323
runs-on: ubuntu-latest
2424
steps:
2525
- name: Install flake8
26-
run: sudo apt update && sudo apt -y install flake8
26+
run: sudo apt update && sudo apt -y install file findutils flake8
2727

2828
- uses: actions/checkout@v4
2929
with:
3030
fetch-depth: 0
3131

3232
- name: Run Flake8
33-
run: flake8 scripts/*.py
33+
run:
34+
# Run flake8 against all files outside .git/ that `file` reports
35+
# as text/x-script.python
36+
find . -path ./.git -prune -o -print0 | \
37+
xargs -0n1 sh -c 'test "$(file --brief --mime-type "$1")" = "text/x-script.python" && printf "%s\000" "$1"' -- | \
38+
xargs -0t flake8
3439

3540
pylint:
3641
name: Install and run Pylint on Python scripts
3742
runs-on: ubuntu-latest
3843
steps:
3944
- name: Install Pylint
40-
run: sudo apt update && sudo apt -y install pylint
45+
run: sudo apt update && sudo apt -y install file findutils pylint
4146

4247
- uses: actions/checkout@v4
4348
with:
4449
fetch-depth: 0
4550

4651
- name: Run Pylint (error mode)
47-
run: pylint --errors-only scripts/*.py
52+
run:
53+
# Run pylint against all files outside .git/ that `file` reports
54+
# as text/x-script.python
55+
find . -path ./.git -prune -o -print0 | \
56+
xargs -0n1 sh -c 'test "$(file --brief --mime-type "$1")" = "text/x-script.python" && printf "%s\000" "$1"' -- | \
57+
xargs -0t pylint --errors-only
4858

4959
shellcheck:
5060
name: Install and run ShellCheck on shell scripts

0 commit comments

Comments
 (0)