diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c2b5280d1..fbe499466 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -186,6 +186,8 @@ jobs: - unit tags="kvdb_postgres" - unit tags="kvdb_sqlite" - btcd unit-race + - unit-module + steps: - name: git checkout uses: actions/checkout@v3 @@ -217,6 +219,7 @@ jobs: path-to-profile: coverage.txt parallel: true + ######################## # run ubuntu integration tests ######################## diff --git a/Makefile b/Makefile index 3199ca29a..c099d8a8f 100644 --- a/Makefile +++ b/Makefile @@ -184,6 +184,10 @@ unit: $(BTCD_BIN) @$(call print, "Running unit tests.") $(UNIT) +unit-module: + @$(call print, "Running submodule unit tests.") + scripts/unit_test_modules.sh + unit-debug: $(BTCD_BIN) @$(call print, "Running debug unit tests.") $(UNIT_DEBUG) diff --git a/scripts/unit_test_modules.sh b/scripts/unit_test_modules.sh new file mode 100755 index 000000000..1e6f92823 --- /dev/null +++ b/scripts/unit_test_modules.sh @@ -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