run = { cmd = "scripts/poe-tasks/run", help = "Run Knot Resolver" }
run-debug = { cmd = "scripts/poe-tasks/run-debug", help = "Debug Knot Resolver with debugpy" }
doc = { cmd = "scripts/poe-tasks/doc", help = "Create Knot Resolver HTML documentation" }
-doc-schema = { cmd = "scripts/poe-tasks/doc-schema", help = "Generate a JSON schema of the Knot Resolver configuration"}
+schema = { cmd = "scripts/poe-tasks/schema", help = "Generate a JSON schema of the Knot Resolver configuration"}
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" }
+lint = { cmd = "scripts/poe-tasks/lint", help = "Run static code analysis (Ruff) and check typing (Mypy)" }
+check = { cmd = "scripts/poe-tasks/check", help = "Check that all dependencies are properly installed and generated files are not behind project." }
examples = { cmd = "scripts/poe-tasks/examples", help = "Validate all configuration examples using 'kresctl validate' utility" }
gen-constantspy = { cmd = "scripts/poe-tasks/gen-constantspy", help = "Generate 'constants.py' module using Meson configured options" }
gen-setuppy = { cmd = "scripts/poe-tasks/gen-setuppy", help = "Generate 'setup.py' file for backwards compatibility" }
src_dir="$(dirname "$(realpath "$0")")"
source $src_dir/utils/_env.sh
-aggregate_rv=0
-function check_rv {
- if test "$1" -eq 0; then
- echo -e " ${green}OK${reset}"
- else
- echo -e " ${red}FAIL${reset}"
- fi
- aggregate_rv=$(( $aggregate_rv + $1 ))
-}
-
# stop failing early, because we wouldn't do anything else than fail
set +e
echo
# early exit when dependencies are not installed
-if test "$aggregate_rv" -ne "0"; then
+if test "$aggregated_rv" -ne "0"; then
echo -e "${red}Dependencies are not properly installed. Run this command to fix it:${reset}"
echo -e " ${red}poetry install${reset}"
exit 1
fi
-# check format using ruff
-echo -e "${yellow}Code format checking using ruff...${reset}"
-ruff format --check --diff python/knot_resolver tests/manager scripts/poe-tasks/utils/create_setup.py
-check_rv $?
-echo
-
-# check imports using ruff
-echo -e "${yellow}Imports format checking using ruff...${reset}"
-ruff check --select I python/knot_resolver tests/manager scripts/poe-tasks/utils/create_setup.py
-check_rv $?
-echo
-
-# check code with ruff
-echo -e "${yellow}Code linting using ruff...${reset}"
-ruff check python/knot_resolver tests/pytests
-check_rv $?
-echo
-
-# check types using mypy
-echo -e "${yellow}Type checking using mypy...${reset}"
-mypy python/knot_resolver
-check_rv $?
-echo
-
# check that setup.py is not behind pyproject.toml
echo -e "${yellow}Checking setup.py${reset}"
python scripts/poe-tasks/utils/create_setup.py | diff - setup.py
echo
# fancy messages at the end :)
-if test "$aggregate_rv" -eq "0"; then
- echo -e "${green}Everything looks great!${reset}"
-else
- echo -e "${red}Failure.${reset}"
- echo -e "${red}These commands might help you:${reset}"
- echo -e "${red}\tpoe format${reset}"
- echo -e "${red}\tpoe gen-setuppy${reset}"
- echo -e "${red}\tpoe gen-constantspy${reset}"
- echo -e "${red}\tpoe doc-schema${reset}"
- echo -e "${red}That's not great. Could you please fix that?${reset} 😲😟"
-fi
+fancy_message
# exit with the aggregate return value
-exit $aggregate_rv
+exit $aggregated_rv
dirs="python/knot_resolver/ tests/manager scripts/poe-tasks/utils/create_setup.py"
# sort python import
+echo -e "${yellow}Sorting Python imports using ruff...${reset}"
ruff check --select I --fix $dirs
+check_rv $?
+echo
# format python code
+echo -e "${yellow}Formatting Python code using ruff...${reset}"
ruff format $dirs
+check_rv $?
+echo
+
+# fancy messages at the end :)
+fancy_message
+
+# exit with the aggregate return value
+exit $aggregated_rv
--- /dev/null
+#!/usr/bin/env bash
+
+# ensure consistent behaviour
+src_dir="$(dirname "$(realpath "$0")")"
+source $src_dir/utils/_env.sh
+
+# stop failing early, because we wouldn't do anything else than fail
+set +e
+
+# check code using ruff
+echo -e "${yellow}Linting using ruff...${reset}"
+ruff check python/knot_resolver tests/pytests
+check_rv $?
+echo
+
+# check types using mypy
+echo -e "${yellow}Checking types using mypy...${reset}"
+mypy python/knot_resolver
+check_rv $?
+echo
+
+# fancy messages at the end :)
+fancy_message
+
+# exit with the aggregate return value
+exit $aggregated_rv
cp $build_dir/python/knot_resolver/constants.py $gitroot/python/knot_resolver/constants.py
python -m knot_resolver.client schema > $schema_file
-echo New configuration JSON schem saved to $schema_file
\ No newline at end of file
+echo New JSON schema saved to $schema_file
\ No newline at end of file
# update PATH with node_modules
PATH="$PATH:$gitroot/node_modules/.bin"
+# aggregated return value
+aggregated_rv=0
+
# fail even on unbound variables
set -o nounset
ninja -C $build_dev_dir
ninja install -C $build_dev_dir
}
+
+function check_rv {
+ if test "$1" -eq 0; then
+ echo -e " ${green}OK${reset}"
+ else
+ echo -e " ${red}FAIL${reset}"
+ fi
+ aggregated_rv=$(( $aggregated_rv + $1 ))
+}
+
+function fancy_message {
+ if test "$aggregated_rv" -eq "0"; then
+ echo -e "${green}Everything looks great!${reset}"
+ else
+ echo -e "${red}Failure.${reset}"
+ echo -e "${red}These commands might help you:${reset}"
+ echo -e "${red}\tpoe format${reset}"
+ echo -e "${red}\tpoe gen-setuppy${reset}"
+ echo -e "${red}\tpoe gen-constantspy${reset}"
+ echo -e "${red}\tpoe gen-schema${reset}"
+ echo -e "${red}That's not great. Could you please fix that?${reset} 😲😟"
+ fi
+}