summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/ci.yml13
-rw-r--r--ChangeLog.adoc1
-rwxr-xr-xtools/check_scripts.sh50
3 files changed, 54 insertions, 10 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 8884af879..45a766ef1 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -5,7 +5,7 @@ on:
- pull_request
env:
- WEECHAT_DEPENDENCIES: devscripts equivs python3-pip autopoint cmake ninja-build lcov pkg-config libncursesw5-dev gem2deb libperl-dev python3-dev libaspell-dev liblua5.3-dev tcl8.6-dev guile-3.0-dev libv8-dev libcurl4-gnutls-dev libgcrypt20-dev libgnutls28-dev libzstd-dev zlib1g-dev curl libcpputest-dev php8.0-dev libphp8.0-embed libargon2-dev libsodium-dev pylint python3-bandit asciidoctor ruby-pygments.rb
+ WEECHAT_DEPENDENCIES: devscripts equivs python3-pip autopoint cmake ninja-build lcov pkg-config libncursesw5-dev gem2deb libperl-dev python3-dev libaspell-dev liblua5.3-dev tcl8.6-dev guile-3.0-dev libv8-dev libcurl4-gnutls-dev libgcrypt20-dev libgnutls28-dev libzstd-dev zlib1g-dev curl libcpputest-dev php8.0-dev libphp8.0-embed libargon2-dev libsodium-dev pylint python3-bandit asciidoctor ruby-pygments.rb shellcheck
jobs:
@@ -42,15 +42,8 @@ jobs:
- name: Check gettext files
run: msgcheck po/*.po
- - name: Check Python scripts
- run: |
- pylint --additional-builtins=_ doc/docgen.py
- pylint doc/python_stub.py
- pylint tests/scripts/python/testapigen.py tests/scripts/python/testapi.py tests/scripts/python/unparse.py
- pylint tools/check_curl_symbols.py
- bandit doc/docgen.py doc/python_stub.py
- bandit tests/scripts/python/testapigen.py tests/scripts/python/testapi.py tests/scripts/python/unparse.py
- bandit tools/check_curl_symbols.py
+ - name: Check shell and Python scripts
+ run: ./tools/check_scripts.sh
- name: Check Python stub file
run: ./doc/python_stub.py | diff src/plugins/python/weechat.pyi -
diff --git a/ChangeLog.adoc b/ChangeLog.adoc
index e0e95e871..d6698b95f 100644
--- a/ChangeLog.adoc
+++ b/ChangeLog.adoc
@@ -58,6 +58,7 @@ Bug fixes::
Tests::
+ * core: add script check_scripts.sh
* core: add script check_curl_symbols.py
* gui: add tests on input functions
* scripts: add tests on config functions
diff --git a/tools/check_scripts.sh b/tools/check_scripts.sh
new file mode 100755
index 000000000..52845e8df
--- /dev/null
+++ b/tools/check_scripts.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+#
+# Copyright (C) 2023 Sébastien Helleu <flashcode@flashtux.org>
+#
+# This file is part of WeeChat, the extensible chat client.
+#
+# WeeChat is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# WeeChat is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with WeeChat. If not, see <https://www.gnu.org/licenses/>.
+#
+
+#
+# Check shell and Python scripts in WeeChat git repository using these tools:
+# - shell scripts: shellcheck
+# - Python scripts: flake8 + pylint + bandit
+#
+
+# exit on any error
+set -e
+
+# check git repository
+ROOT_DIR=$(git rev-parse --show-toplevel)
+cd "${ROOT_DIR}"
+
+SHELL_SCRIPTS=$(git ls-files "*.sh")
+PYTHON_SCRIPTS=$(git ls-files "*.py")
+
+# display commands
+set -x
+
+# check shell scripts
+for script in $SHELL_SCRIPTS; do
+ shellcheck "${ROOT_DIR}/$script"
+done
+
+# check Python scripts
+for script in $PYTHON_SCRIPTS; do
+ flake8 --max-line-length=100 --builtins=_ "${ROOT_DIR}/$script"
+ pylint --additional-builtins=_ "${ROOT_DIR}/$script"
+ bandit "${ROOT_DIR}/$script"
+done