Skip to content

Commit 4901b24

Browse files
author
Test User
committed
fix: resolve CI/CD workflow issues on Windows
1 parent 9954c26 commit 4901b24

File tree

3 files changed

+50
-9
lines changed

3 files changed

+50
-9
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ jobs:
4747
go-version: '1.21'
4848

4949
- name: Build binary
50+
shell: bash
5051
env:
5152
GOOS: ${{ matrix.goos }}
5253
GOARCH: ${{ matrix.goarch }}
@@ -62,6 +63,7 @@ jobs:
6263
go build -ldflags "-X main.version=$VERSION -X main.commit=$COMMIT -X main.date=$BUILD_TIME -s -w" -trimpath -o bin/$BINARY_NAME ./cmd/doplan
6364
6465
- name: Verify binary exists
66+
shell: bash
6567
run: |
6668
if [ "${{ matrix.goos }}" = "windows" ]; then
6769
if [ ! -f "bin/doplan.exe" ]; then
@@ -80,6 +82,7 @@ jobs:
8082
fi
8183
8284
- name: Test binary (native architecture only)
85+
shell: bash
8386
# Only test if building for native architecture (can execute on runner)
8487
# Cross-compiled binaries (arm64 on amd64 runners) cannot be executed
8588
# Strategy: Test amd64 builds which can run on all amd64 runners
@@ -94,7 +97,9 @@ jobs:
9497
./bin/doplan --version
9598
echo "✅ Binary test passed for ${{ matrix.goos }}/${{ matrix.goarch }}"
9699
fi
100+
97101
- name: Verify cross-compiled binary
102+
shell: bash
98103
# For cross-compiled builds (arm64 on amd64 runners), verify binary exists but skip execution
99104
if: matrix.goarch == 'arm64'
100105
run: |

.github/workflows/test.yml

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

internal/statistics/storage_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ func TestNewStorage(t *testing.T) {
1818

1919
assert.NotNil(t, storage)
2020
assert.Equal(t, projectRoot, storage.projectRoot)
21-
21+
2222
// Verify path components (handle Windows path separators)
2323
// Normalize path separators for comparison
2424
normalizedPath := strings.ReplaceAll(storage.storagePath, "\\", "/")
2525
assert.Contains(t, normalizedPath, ".doplan")
2626
assert.Contains(t, normalizedPath, "stats")
2727
assert.Contains(t, normalizedPath, "statistics.json")
28-
28+
2929
// Verify it ends with statistics.json (platform-agnostic)
3030
expectedPath := filepath.Join(projectRoot, ".doplan", "stats", "statistics.json")
31-
assert.Equal(t, expectedPath, storage.storagePath,
31+
assert.Equal(t, expectedPath, storage.storagePath,
3232
"storage path should match expected path (normalized for platform)")
3333
}
3434

0 commit comments

Comments
 (0)