ci/ts
6function run_python_tests() {
7 GIT_ROOT=$(git rev-parse --show-toplevel
)
9 pushd "$GIT_ROOT" >/dev/null
10 # If there's a `scripts` folder with a test script, run that
11 if find
"scripts" -name
'run_*_tests.sh' >/dev/null
2>
&1; then
12 print_info
"-> bash scripts/run_*_tests.sh"
13 bash scripts/run_*_tests.sh
17 # If there's a `go.mod` in the root, this is a Go project.
18 # Look for changed Go packages, and pass the list to `go test`.
19 if test -e go.mod
; then
20 if test -e
"./tool/go"; then
27 git ls-files --modified
\
30 | xargs -I
'{}' echo "./{}" \
34 print_info
"$GO test $CHANGED_PACKAGES"
35 "$GO" test $CHANGED_PACKAGES
39 REPO_NAME="$(basename
$(pwd))"
41 # Run ruff to do Python formatting
42 print_info
"-> ruff format"
47 print_info
"-> ruff check --fix"
52 # This is one repo which is a bit special -- I'm gradually trying to chase
53 # the code into `src`, but for now I have to remember to look at *.py
54 if [[ "$REPO_NAME" = "library-lookup" ]]
56 print_info
'-> mypy *.py src tests'
59 print_info
'-> mypy src tests'
61 if mypy src tests >/dev/null
63 mypy src tests --no-color-output
72 print_info
"-> coverage run -m pytest tests"
73 coverage run -m pytest tests --quiet
77 print_info
"-> coverage report"
79 if [[ $(coverage report --format
=total
) = "100" ]]
87function run_rust_tests() {
88 print_info
"-> cargo fmt"
93 print_info
"-> cargo build"
98 print_info -n
"-> cargo test"
106 run_python_tests
"$@"