mirror of
https://github.com/tldr-pages/tldr.git
synced 2024-09-21 08:48:13 +03:00
script/test: ignore python checks if not available (#6530)
This commit is contained in:
parent
3447744e09
commit
6d318892f8
@ -9,6 +9,40 @@
|
|||||||
# NOTE: must be run from the repository root directory to correctly work!
|
# NOTE: must be run from the repository root directory to correctly work!
|
||||||
# NOTE: `set -e` is applied conditionally only if needed.
|
# NOTE: `set -e` is applied conditionally only if needed.
|
||||||
|
|
||||||
|
# check if a command is available to run in the system
|
||||||
|
function exists {
|
||||||
|
command -v "$1" >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Wrapper around black as it outputs everything to stderr,
|
||||||
|
# but we want to only print if there are actual errors, and not
|
||||||
|
# the "All done!" success message.
|
||||||
|
function run_black {
|
||||||
|
# skip black check if command is not available in the system.
|
||||||
|
if [ "$CI" != "true" ] && ! exists black; then
|
||||||
|
echo "Skipping black check, command not available."
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# we want to ignore the exit code from black on failure, so that we can
|
||||||
|
# do the conditional printing below
|
||||||
|
errs=$(black scripts --check 2>&1 || true)
|
||||||
|
if [[ ${errs} != "All done!"* ]]; then
|
||||||
|
echo -e "${errs}" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function run_flake8 {
|
||||||
|
# skip flake8 check if command is not available in the system.
|
||||||
|
if [ "$CI" != "true" ] && ! exists flake8; then
|
||||||
|
echo "Skipping flake8 check, command not available."
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
flake8 scripts
|
||||||
|
}
|
||||||
|
|
||||||
# Default test function, ran by `npm test`.
|
# Default test function, ran by `npm test`.
|
||||||
function run_tests {
|
function run_tests {
|
||||||
markdownlint pages*/**/*.md
|
markdownlint pages*/**/*.md
|
||||||
@ -17,20 +51,7 @@ function run_tests {
|
|||||||
tldr-lint --ignore "TLDR003,TLDR004,TLDR005,TLDR015,TLDR104" ${f}
|
tldr-lint --ignore "TLDR003,TLDR004,TLDR005,TLDR015,TLDR104" ${f}
|
||||||
done
|
done
|
||||||
run_black
|
run_black
|
||||||
flake8 scripts
|
run_flake8
|
||||||
}
|
|
||||||
|
|
||||||
# Wrapper around black as it outputs everything to stderr,
|
|
||||||
# but we want to only print if there are actual errors, and not
|
|
||||||
# the "All done!" success message.
|
|
||||||
function run_black {
|
|
||||||
# we want to ignore the exit code from black on failure, so that we can
|
|
||||||
# do the conditional printing below
|
|
||||||
errs=$(black scripts --check 2>&1 || true)
|
|
||||||
if [[ ${errs} != "All done!"* ]]; then
|
|
||||||
echo -e "${errs}" >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Special test function for GitHub Actions pull request builds.
|
# Special test function for GitHub Actions pull request builds.
|
||||||
|
Loading…
Reference in New Issue
Block a user