Makefile+action: add make unit-module to test submodules

This commit adds a new command `make unit-module` to run unit tests for
submodules to avoid future build errors.
This commit is contained in:
yyforyongyu
2023-09-04 19:17:53 +08:00
parent 08f4940e88
commit 5296509474
3 changed files with 34 additions and 0 deletions

27
scripts/unit_test_modules.sh Executable file
View File

@@ -0,0 +1,27 @@
#!/bin/bash
IGNORE="tools"
SUBMODULES=$(find . -mindepth 2 -name "go.mod" | cut -d'/' -f2 | grep -v "$IGNORE")
for submodule in $SUBMODULES
do
pushd $submodule
echo "Running submodule unit tests in $(pwd)"
echo "testing $submodule..."
go test -timeout=5m || exit 1
if [[ "$submodule" == "kvdb" ]]
then
echo "testing $submodule with sqlite..."
go test -tags="kvdb_sqlite" -timeout=5m || exit 1
echo "testing $submodule with postgres..."
go test -tags="kvdb_postgres" -timeout=5m || exit 1
echo "testing $submodule with etcd..."
go test -tags="kvdb_etcd" -timeout=5m || exit 1
fi
popd
done