scripts/_common.py: add a shared Python file to move duplicated code (#12755)

* `scripts/_common.py`: add a shared Python file to move duplicated code

---------

Co-authored-by: Vítor Henrique <87824454+vitorhcl@users.noreply.github.com>
Co-authored-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com>
This commit is contained in:
Sebastiaan Speck
2024-05-18 02:33:40 +02:00
committed by GitHub
parent 4a0f674e61
commit dff913f486
9 changed files with 732 additions and 354 deletions

View File

@@ -57,6 +57,20 @@ function run_flake8 {
flake8 scripts
}
function run_pytest {
# skip pytest check if the command is not available in the system.
if [[ $CI != true ]] && ! exists pytest; then
echo "Skipping pytest check, command not available."
return 0
fi
errs=$(pytest scripts/*.py 2>&1 || true)
if [[ ${errs} == *"failed"* ]]; then
echo -e "${errs}" >&2
return 1
fi
}
# Default test function, run by `npm test`.
function run_tests {
find pages* -name '*.md' -exec markdownlint {} +
@@ -74,6 +88,7 @@ function run_tests {
done
run_black
run_flake8
run_pytest
}
# Special test function for GitHub Actions pull request builds.