fix: make Linux example tests resilient to CI environments#11
Merged
christiangda merged 14 commits intomainfrom Mar 21, 2026
Merged
fix: make Linux example tests resilient to CI environments#11christiangda merged 14 commits intomainfrom
christiangda merged 14 commits intomainfrom
Conversation
Linux example tests were failing on CI runners (ubuntu-latest) because: - ExampleProvider_Diagnostics expected exactly 2 collected components, but the count varies: /sys/class/dmi/id/product_uuid requires root, /etc/machine-id availability differs across environments. - Example_integrity expected WithMotherboard() to produce a different ID, but /sys/class/dmi/id/board_serial requires root on CI, so the motherboard component silently fails and both IDs are identical. - Example_linuxFileSources used WithDisk() which needs lsblk or /sys/block access that may not work on CI runners. Fix: use salt-based differentiation (always works regardless of hardware access), assert >= 1 collected instead of exact counts, and use only /proc/cpuinfo (always readable) in the file sources example. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use go-test-coverage with .testcoverage.yml config for structured coverage reporting. Add set -o pipefail to catch failures in piped commands. Add pass/fail indicators to coverage output. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
All three workflows (release, main, pr) were hiding make command
output due to exec_cmd redirecting to /dev/null. This made test
failures impossible to debug in CI.
Changes:
- Replace MAKE_STOP_ON_ERRORS with MAKE_DEBUG=true globally so all
make commands show raw output in CI logs
- Pipe make output through 2>&1 | tee for step summaries
- Align step names across all workflows ("Check out code", "Set up Go")
- Add explicit job names to main.yml and pr.yml
- Remove redundant "Go version" steps (setup-go already logs it)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Run tests on all three target platforms (ubuntu-latest, macos-latest, windows-latest) using a matrix strategy with fail-fast disabled. The test matrix uses `go test` directly (not `make test`) to avoid Makefile/bash portability issues on Windows runners. The Linux-only report job (summary, scc, coverage, build) runs after all platform tests pass. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
After testing, each matrix runner (Linux, macOS, Windows) now builds the CLI binary and runs a smoke test that: - Prints version info - Generates a default machine ID and validates it is 64-char hex - Runs all components with JSON + diagnostics output - Validates the generated ID against the current machine - Tests VM-friendly, format 32, and salt modes Uses shell: bash on all runners (available on windows-latest) and runner.temp for the binary path to avoid cross-OS path issues. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The mockExecutor was accessed concurrently by Windows collectIdentifiers goroutines without synchronization, causing data races on callCount map writes and concurrent map reads. Add sync.RWMutex to protect all map access in Execute, setOutput, and setError. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Update all documentation to reflect the go.mod bump to Go 1.26.1: - README.md: Go 1.25+ -> Go 1.26+ - CONTRIBUTING.md: Go 1.22 -> Go 1.26 - copilot-instructions.md: Go 1.22+ -> Go 1.26+ Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
On Windows CI runners, WMI can become transiently unavailable after repeated rapid invocations (each spawning concurrent wmic/PowerShell processes). This caused -vm and other modes to fail intermittently. The smoke test now: - Strictly validates the core path: version, 64-char hex ID, and round-trip validation (these must pass) - Runs additional CLI exercises (-all, -vm, -format, -salt) as non-fatal with WARN logging, since the core validation already proved the binary works Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix README.md: add missing ctx argument to ID() calls in Testing and Best Practices sections - Add sync.RWMutex to mock executor example in README.md to reflect thread safety requirement - Document that CommandExecutor implementations must be safe for concurrent use (Windows parallel goroutines) - Update doc.go Testing section with concurrency note Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove auto-generated boilerplate comments, align step names with other workflows, and remove unused swift runner conditional. The file coverage deprecation warning on PRs is a CodeQL informational notice and requires no action (coverage still runs on push/schedule). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Set CODEQL_ACTION_FILE_COVERAGE_ON_PRS=false to explicitly adopt the new default (April 2026) and suppress the informational warning. File coverage is still computed on push and schedule analyses. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
ubuntu-latest) because they depended on DMI/hardware access that requires root privilegesExampleProvider_Diagnostics: expected exactly 2 collected components, but/sys/class/dmi/id/product_uuidrequires root — now asserts>= 1insteadExample_integrity: expectedWithMotherboard()to produce a different ID, but/sys/class/dmi/id/board_serialrequires root — now uses salt-based differentiation which always worksExample_linuxFileSources: usedWithDisk()which needslsblk//sys/block— now uses onlyWithCPU()since/proc/cpuinfois always readableTest plan
GOOS=linux go build ./...succeedsGOOS=linux go vet ./...passesGOOS=linux golangci-lint run ./...reports 0 issuesmake testpasses onubuntu-latest(this PR)🤖 Generated with Claude Code