From 834277321648297522ce2dbbf46559d96ca7d991 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 19 Jan 2022 10:31:45 +0100 Subject: [mod] manage test.pyright: a commandline to run pyright tests This patch implements the command and Makefile target:: ./manage test.pyright make test.pyright Signed-off-by: Markus Heiser --- manage | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'manage') diff --git a/manage b/manage index 1f4ffa53b..b70e81f52 100755 --- a/manage +++ b/manage @@ -103,6 +103,7 @@ format.: test.: yamllint : lint YAML files (YAMLLINT_FILES) pylint : lint PYLINT_FILES, searx/engines, searx & tests + pyright : static type check of python sources black : check black code format unit : run unit tests coverage : run unit tests with coverage @@ -682,6 +683,15 @@ test.pylint() { dump_return $? } + +test.pyright() { + build_msg TEST "[pyright] static type check of python sources" + nodejs.ensure + pyenv.cmd pyright + dump_return $? +} + + test.black() { build_msg TEST "[black] \$BLACK_TARGETS" pyenv.cmd black --check --diff "${BLACK_OPTIONS[@]}" "${BLACK_TARGETS[@]}" -- cgit v1.2.3 From 3cd5ce55e826a665c6113d5da8195aec9567631a Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Thu, 20 Jan 2022 07:04:39 +0100 Subject: [enh] clarify why we run pyright in the pyenv --- manage | 2 ++ 1 file changed, 2 insertions(+) (limited to 'manage') diff --git a/manage b/manage index b70e81f52..0c0e851c7 100755 --- a/manage +++ b/manage @@ -687,6 +687,8 @@ test.pylint() { test.pyright() { build_msg TEST "[pyright] static type check of python sources" nodejs.ensure + # We run Pyright in the virtual environment because Pyright + # executes "python" to determine the Python version. pyenv.cmd pyright dump_return $? } -- cgit v1.2.3 From 96450b17d4304a740c0af934cbb841de67178d94 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Thu, 20 Jan 2022 08:26:16 +0100 Subject: [mod] add test.pyright to test & ci.test targets Since we currently have many type checking errors, we for now only test with typeCheckingMode: off which makes pyright only check files that contain a comment: # pyright: basic to enable basic type checking, or # pyright: strict to enable strict type checking. --- manage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'manage') diff --git a/manage b/manage index 0c0e851c7..aec3906df 100755 --- a/manage +++ b/manage @@ -689,7 +689,7 @@ test.pyright() { nodejs.ensure # We run Pyright in the virtual environment because Pyright # executes "python" to determine the Python version. - pyenv.cmd pyright + pyenv.cmd pyright -p pyrightconfig-ci.json dump_return $? } -- cgit v1.2.3 From 6d701d2fea07198807351c7c4856001c0f1ebffb Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Thu, 20 Jan 2022 09:11:37 +0100 Subject: [fix] ensure that test.pyright installs pyright nodejs.ensure only sets up NVM if there isn't a system-wide installation of Node that matches our NODE_MINIMUM_VERSION. The ubuntu image in the CI comes with an up to date node version, so pyright from .nvm_packages is never installed. This commit fixes this by introducing a package.json file. --- manage | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'manage') diff --git a/manage b/manage index aec3906df..45853de3d 100755 --- a/manage +++ b/manage @@ -687,9 +687,10 @@ test.pylint() { test.pyright() { build_msg TEST "[pyright] static type check of python sources" nodejs.ensure + npm install # We run Pyright in the virtual environment because Pyright # executes "python" to determine the Python version. - pyenv.cmd pyright -p pyrightconfig-ci.json + pyenv.cmd npx --no-install pyright -p pyrightconfig-ci.json dump_return $? } -- cgit v1.2.3 From 309147d86f08f69ce1467aa4d25d3d6a56b2bc46 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sat, 22 Jan 2022 09:26:17 +0100 Subject: [mod] introduce node.env.devtools function --- manage | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'manage') diff --git a/manage b/manage index 45853de3d..6cc98c1be 100755 --- a/manage +++ b/manage @@ -20,6 +20,8 @@ source "$(dirname "${BASH_SOURCE[0]}")/utils/lib_go.sh" # shellcheck source=utils/lib_redis.sh source "$(dirname "${BASH_SOURCE[0]}")/utils/lib_redis.sh" +PATH="${REPO_ROOT}/node_modules/.bin:${PATH}" + # config PYOBJECTS="searx" @@ -559,6 +561,12 @@ node.env() { dump_return $? } +node.env.devtools() { + nodejs.ensure + build_msg INSTALL "package.json: developer and CI tools" + npm install +} + node.clean() { if ! required_commands npm 2>/dev/null; then build_msg CLEAN "npm is not installed / ignore npm dependencies" @@ -683,11 +691,9 @@ test.pylint() { dump_return $? } - test.pyright() { build_msg TEST "[pyright] static type check of python sources" - nodejs.ensure - npm install + node.env.devtools # We run Pyright in the virtual environment because Pyright # executes "python" to determine the Python version. pyenv.cmd npx --no-install pyright -p pyrightconfig-ci.json -- cgit v1.2.3