]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
scripts/poe-tasks: scripts for some tasks
authorAleš Mrázek <ales.mrazek@nic.cz>
Thu, 1 Aug 2024 15:56:20 +0000 (17:56 +0200)
committerAleš Mrázek <ales.mrazek@nic.cz>
Mon, 26 Aug 2024 12:28:10 +0000 (14:28 +0200)
It would be useful to be able to run some tasks outside of the Poetry environment.

pyproject.toml
scripts/create_setup.py [moved from scripts/poe-tasks/create_setup.py with 100% similarity]
scripts/poe-tasks/format [new file with mode: 0755]
scripts/poe-tasks/gen-setuppy [new file with mode: 0755]
scripts/poe-tasks/test [new file with mode: 0755]

index c241727a26060927eb71d928d3359458d8e15fc2..81b7a960629affe45e500bd6461817459e112035 100644 (file)
@@ -74,13 +74,13 @@ configure = { cmd = "scripts/poe-tasks/configure", help = "(Re)configure Meson b
 run = { cmd = "scripts/poe-tasks/run", help = "Run Knot Resolver" }
 run-debug = { cmd = "scripts/poe-tasks/run-debug", help = "Debug Knot Resolver with debugpy" }
 docs = { cmd = "scripts/poe-tasks/docs", help = "Create Knot Resolver HTML documentation" }
-test = { shell = "env PYTHONPATH=. pytest --junitxml=unit.junit.xml --cov=manager/knot_resolver_manager --show-capture=all tests/manager", help = "Run unit tests" }
+test = { cmd = "scripts/poe-tasks/test", help = "Run pytest unit tests" }
 check = { cmd = "scripts/poe-tasks/check", help = "Check that all dependencies are installed and run static code analysis" }
 examples = { cmd = "scripts/poe-tasks/examples", help = "Validate all configuration examples using 'kresctl validate' utility" }
 man = {cmd = "scripts/poe-tasks/man", help = "Display Knot Resolver manpage from sources" }
+gen-setuppy = { cmd = "scripts/poe-tasks/gen-setuppy", help = "Generate 'setup.py' file for backwards compatibility" }
+format = { cmd = "scripts/poe-tasks/format", help = "Run code formatter" }
 # tasks runned directly
-gen-setuppy = { shell = "python scripts/poe-tasks/create_setup.py > setup.py", help = "Generate 'setup.py' file for backwards compatibility" }
-format = { shell = "black manager/knot_resolver_manager/ tests/manager scripts/create_setup.py manager/build_c_extensions.py; isort .", help = "Run code formatter" }
 fixdeps = { shell = "poetry install; npm install; npm update", help = "Install/update dependencies according to configuration files"}
 kresctl = { script = "knot_resolver_manager.cli.main:main", cwd="${POE_PWD}", help="Run kresctl utility" }
 kresctl-nocwd = { script = "knot_resolver_manager.cli.main:main", help="Run kresctl utility" } # Python <3.8 and poethepoet <0.22.0 compatibility (see also `./poe`)
diff --git a/scripts/poe-tasks/format b/scripts/poe-tasks/format
new file mode 100755 (executable)
index 0000000..fa113f1
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+# ensure consistent behaviour
+src_dir="$(dirname "$(realpath "$0")")"
+source $src_dir/_env.sh
+
+dirs="manager/knot_resolver_manager/ tests/manager scripts/create_setup.py build_c_extensions.py"
+
+# run black code formater
+black $dirs
+
+# sort python imports
+isort $dirs
diff --git a/scripts/poe-tasks/gen-setuppy b/scripts/poe-tasks/gen-setuppy
new file mode 100755 (executable)
index 0000000..752beea
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+# ensure consistent behaviour
+src_dir="$(dirname "$(realpath "$0")")"
+source $src_dir/_env.sh
+
+# create setup.py
+python scripts/create_setup.py > setup.py
diff --git a/scripts/poe-tasks/test b/scripts/poe-tasks/test
new file mode 100755 (executable)
index 0000000..0f451b6
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+# ensure consistent behaviour
+src_dir="$(dirname "$(realpath "$0")")"
+source $src_dir/_env.sh
+
+# run pytest
+env PYTHONPATH=. pytest --junitxml=unit.junit.xml --cov=manager/knot_resolver_manager --show-capture=all tests/manager