Skip to content

Commit

Permalink
run all tests in one workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ivvist committed Dec 1, 2024
1 parent f578369 commit b607db1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/ci_reuse_go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
21 changes: 21 additions & 0 deletions scripts/test_subfolders_full.sh
Original file line number Diff line number Diff line change
@@ -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."

0 comments on commit b607db1

Please sign in to comment.