@@ -49,17 +49,53 @@ jobs:
4949 - name : Download dependencies
5050 run : go mod download
5151
52- - name : Clean coverage files
52+ - name : Clean coverage files and artifacts
5353 shell : bash
5454 run : |
5555 # Remove any existing coverage files that might interfere with test discovery
5656 # Go test can fail if coverage files are present and cause package discovery issues
57- rm -f coverage.out coverage.html coverage_*.out 2>/dev/null || true
58- # Remove any .out files in root directory
59- find . -maxdepth 1 -name "*.out" -type f ! -name "coverage.out" -delete 2>/dev/null || true
60-
57+ echo "Cleaning up coverage files and artifacts..."
58+ # Remove all .out files recursively (except we'll create coverage.out later)
59+ find . -name "*.out" -type f -delete 2>/dev/null || true
60+ # Remove any .out directories
61+ find . -name ".out" -type d -exec rm -rf {} + 2>/dev/null || true
62+ # Remove any .out files in root
63+ rm -f .out coverage.out coverage.html coverage_*.out 2>/dev/null || true
64+ # Verify cleanup
65+ echo "Verifying cleanup..."
66+ if find . -maxdepth 1 -name "*.out" -type f 2>/dev/null | grep -q .; then
67+ echo "Warning: Some .out files still exist"
68+ find . -maxdepth 1 -name "*.out" -type f 2>/dev/null
69+ else
70+ echo "✅ Cleanup complete - no .out files found"
71+ fi
72+
6173 - name : Run tests
62- run : go test -v -race -coverprofile=coverage.out ./...
74+ shell : bash
75+ run : |
76+ # Run tests - cleanup should have removed any problematic .out files
77+ echo "Running tests..."
78+ # Use go test directly - cleanup step should have removed any .out files
79+ go test -v -race -coverprofile=coverage.out ./... 2>&1 || {
80+ EXIT_CODE=$?
81+ echo "Tests failed with exit code $EXIT_CODE"
82+ # Check if the error is related to .out package
83+ if go list ./... 2>&1 | grep -q "\.out"; then
84+ echo "Error: .out package detected. Attempting to clean and retry..."
85+ find . -name "*.out" -type f -delete 2>/dev/null || true
86+ find . -name ".out" -type d -exec rm -rf {} + 2>/dev/null || true
87+ # Retry with explicit package list
88+ PACKAGES=$(go list ./... 2>&1 | grep -v "\.out" | grep -v "no required module" || true)
89+ if [ -n "$PACKAGES" ]; then
90+ echo "Retrying with filtered packages..."
91+ go test -v -race -coverprofile=coverage.out $PACKAGES
92+ else
93+ exit $EXIT_CODE
94+ fi
95+ else
96+ exit $EXIT_CODE
97+ fi
98+ }
6399
64100 - name : Upload coverage reports
65101 uses : codecov/codecov-action@v4
0 commit comments