diff --git a/.github/workflows/ci_reuse_go.yml b/.github/workflows/ci_reuse_go.yml index 046f9c4..8b32928 100644 --- a/.github/workflows/ci_reuse_go.yml +++ b/.github/workflows/ci_reuse_go.yml @@ -77,9 +77,13 @@ jobs: run-mod-tidy: false - name: Test subfolders - if: ${{ inputs.test_subfolders == 'true' }} + if: ${{ inputs.test_subfolders == 'true' }} run: | - curl -s https://raw.githubusercontent.com/untillpro/ci-action/master/scripts/test_subfolders.sh | bash -s "$(go env GOPATH)" + if [ "${{ inputs.short_test }}" == "true" ]; then + curl -s https://raw.githubusercontent.com/untillpro/ci-action/master/scripts/test_subfolders.sh | bash -s "$(go env GOPATH)" + else + curl -s https://raw.githubusercontent.com/untillpro/ci-action/master/scripts/test_subfolders_full.sh | bash -s "$(go env GOPATH)" + fi - name: Check copyright run: curl -s https://raw.githubusercontent.com/untillpro/ci-action/master/scripts/check_copyright.sh | bash -s "$(go env GOPATH)" diff --git a/scripts/test_subfolders_full.sh b/scripts/test_subfolders_full.sh new file mode 100644 index 0000000..e6cb429 --- /dev/null +++ b/scripts/test_subfolders_full.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -e + +REPO_ROOT=$(git rev-parse --show-toplevel) +cd "$REPO_ROOT" + +# Iterate through all subfolders with their own go.mod and run tests +for dir in $(find . -name "go.mod" -not -path "./go.mod" -exec dirname {} \;); do + echo "Running tests in $dir..." + + # Run tests normally in all other directories + (cd "$dir" && go test ./... ) || any_test_failed=1 +done + +# Check if any test failed and exit with a non-zero status +if [ "$any_test_failed" -ne 0 ]; then + echo "The tests did not pass. Please check the errors above." + exit 1 +fi + +echo "All tests passed successfully." \ No newline at end of file