Fix Windows compatibility and cross-platform test issues#12
Merged
victoralfred merged 25 commits intomainfrom Jan 19, 2026
Merged
Fix Windows compatibility and cross-platform test issues#12victoralfred merged 25 commits intomainfrom
victoralfred merged 25 commits intomainfrom
Conversation
Add comprehensive GitHub Actions workflows for: License Workflow: - Verify LICENSE file exists and is MIT - Check dependency licenses for compatibility - Scan for copyleft licenses (GPL/LGPL/AGPL) - Generate license reports for all dependencies Go Workflow: - Test matrix across multiple Go versions and OS (1.22, 1.23, stable) - Vulnerability scanning with govulncheck - Go module tidiness checks - Static analysis with staticcheck and revive - Code formatting validation (gofmt, goimports) - Benchmark tests on main branch - Code coverage with Codecov integration - Weekly scheduled runs for dependency updates
Replace golangci-lint style directives with staticcheck-native format to properly suppress intentional nil context test cases. Changed from: //nolint:staticcheck // Testing nil context To: //lint:ignore SA1012 Testing nil context handling This resolves CI failures while preserving valuable nil context validation tests across 16 test files.
Changed all nil context tests to pass nil instead of context.TODO() and added nolint:staticcheck comments on the same line as the call
Changed //nolint:staticcheck to //lint:ignore SA1012 since staticcheck only recognizes its own lint:ignore directive format
Changed //lint:ignore SA1012 to //nolint:staticcheck since golangci-lint requires the nolint format for staticcheck rules
The //lint:ignore SA1012 directive is recognized by both standalone staticcheck and golangci-lint, unlike //nolint which only works with golangci-lint
Instead of passing nil directly to functions, assign nil to a context.Context variable first. This avoids triggering SA1012 staticcheck warning while still testing nil context handling
This update resolves Windows-specific path handling issues where drive letters were being corrupted (e.g., \C:: instead of C:\), causing file write operations to fail on Windows platforms. All tests now pass on Linux, macOS, and Windows.
Replace hardcoded Unix paths with cross-platform alternatives: - Use t.TempDir() instead of /tmp for temporary directories - Use exec.LookPath to find absolute paths to binaries - Replace /bin/echo with platform-independent go binary This ensures all tests pass on Windows, macOS, and Linux.
Replace hardcoded /tmp paths with t.TempDir() in: - internal/policy/decision_test.go - internal/policy/engine_test.go - internal/scanner/osv/osv_security_test.go - internal/scanner/osv/osv_test.go These tests were failing on Windows because /tmp translates to D:\tmp which doesn't exist. Using t.TempDir() ensures cross-platform compatibility.
Replace hardcoded /tmp paths with t.TempDir() in: - internal/scanner/semgrep/semgrep_test.go (4 instances) - internal/scanner/trivy/trivy_test.go (4 instances) These tests were failing on Windows due to hardcoded /tmp paths.
Increase timeout from 1 nanosecond to 1 millisecond and sleep time from 10 nanoseconds to 10 milliseconds to make the test more reliable across different platforms, especially Windows where nanosecond-level timing can be unreliable.
Change timeout from 1 nanosecond to 1 millisecond and sleep from 10 nanoseconds to 10 milliseconds for reliable cross-platform behavior.
Use direct string concatenation instead of filepath.Join for test cases that intentionally test invalid paths containing newlines and null bytes. Added nolint directives with explanation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes all Windows compatibility issues and ensures tests pass across Linux, macOS, and Windows platforms.
Changes Made
1. Updated Dependencies
\C::instead ofC:\)2. Fixed Hardcoded Unix Paths (18+ instances)
Replaced hardcoded
/tmppaths witht.TempDir()for cross-platform compatibility:internal/cli/scan_edge_test.gointernal/cli/scan_security_test.gointernal/helm/chart_test.gointernal/pipeline/runner_test.gointernal/policy/decision_test.gointernal/policy/engine_test.gointernal/scanner/osv/osv_security_test.gointernal/scanner/osv/osv_test.gointernal/scanner/semgrep/semgrep_test.gointernal/scanner/trivy/trivy_test.go3. Fixed Platform-Specific Command Issues
/bin/echowithexec.LookPath("go")for cross-platform binary execution4. Fixed Flaky Timing Tests
5. Fixed Linter Warnings
//nolintdirectives with explanations6. Fixed Staticcheck SA1012 Warnings
Test Results
All tests now pass on all platforms:
CI Status
Breaking Changes
None
Additional Notes
These changes ensure full cross-platform compatibility without affecting functionality. All fixes maintain backward compatibility and follow Go best practices.