Skip to content

Comprehensive improvements: fixes, tests, CI/CD, and documentation#6

Merged
nikoksr merged 10 commits intomainfrom
improvements/code-review-fixes
Dec 12, 2025
Merged

Comprehensive improvements: fixes, tests, CI/CD, and documentation#6
nikoksr merged 10 commits intomainfrom
improvements/code-review-fixes

Conversation

@nikoksr
Copy link
Copy Markdown
Owner

@nikoksr nikoksr commented Dec 12, 2025

Summary

This PR implements comprehensive improvements to the assert-go library based on a thorough code review.

Changes

Fixes

  • Fix typo in Assert function documentation: 'Gloabbly' → 'Globally'
  • Clarify internal assert() function documentation
  • Improve AssertionError type documentation
  • Resolve race condition in config tests by running them serially
  • Optimize string building in assert() using strings.Builder
  • Remove deprecated +build directives, keep only //go:build

Documentation

  • Add 4 comprehensive example functions for pkg.go.dev
  • Enhance README with CI and Go Report Card badges
  • Add Performance section with benchmark results
  • Rewrite 'A Personal Perspective' section for clarity and impact
  • Add thread safety note for SetConfig
  • Add 'More Projects' section
  • Update example timestamps to 2025

Testing

  • Add comprehensive benchmark suite (6 benchmarks)
  • Verify ~3ns per assertion with zero allocations
  • Add explanatory comment for odd number values handling

CI/CD

  • Add GitHub Actions workflow with 3 jobs (test, lint, format)
  • Test against Go 1.18.x, 1.23.x, and 1.25.x
  • Include race detector and code coverage
  • Test both with and without assertdebug tag

Development

  • Add 7 new make targets: test, test-debug, test-coverage, bench, bench-debug, check, ci
  • Update golangci-lint configuration to v2.7.2

Compatibility

  • Lower Go version requirement from 1.23.3 to 1.18
  • Replace built-in max() with simple if statement for compatibility
  • Maintain zero performance impact (benchmarked)
  • Support 3.75 years of Go versions (1.18 through 1.25)

Verification

All tests pass with race detector
Linter passes with 0 issues (80+ linters enabled)
94.2% code coverage
Benchmarks confirm identical performance
Compatible with Go 1.18+

Impact

This PR makes assert-go more reliable (fixed race conditions, comprehensive tests), better documented (examples, improved narrative, performance data), more compatible (Go 1.18+ support), easier to maintain (CI/CD pipeline, make targets, strict linting), and more contributor-friendly (automated checks, clear documentation).

- Fix typo in Assert function comment: 'Gloabbly' -> 'Globally'
- Clarify internal assert() function documentation
- Improve AssertionError type documentation
- Add explanatory comment for odd number values handling
- Optimize string building in assert() using strings.Builder
- Remove deprecated +build directives, keep only //go:build
Config tests that modify the global activeConfig variable now run
serially instead of in parallel to prevent data races with other tests.
Add four example functions demonstrating:
- Basic Assert usage
- Assert with contextual values
- Configuration with SetConfig
- Debug assertions with build tags
Add benchmarks for:
- Successful assertions (with and without values)
- Source context configurations
- Debug assertions (disabled and enabled)

Results show ~3ns per assertion with zero allocations on hot path.
Add CI pipeline with three jobs:
- Test: Run tests with race detector on Go 1.22.x and 1.23.x,
  test both with and without assertdebug tag, upload coverage
- Lint: Run golangci-lint with strict configuration
- Format: Verify code formatting with all tools

Helps contributors catch issues before review.
Add new make targets:
- test: Run tests with race detector and coverage
- test-debug: Run tests with assertdebug tag
- test-coverage: Generate HTML coverage report
- bench: Run benchmarks
- bench-debug: Run benchmarks with assertdebug tag
- check: Run fmt, lint, and test (local pre-commit)
- ci: Run lint, test, and test-debug (mirrors CI)
…ative

- Add CI status and Go Report Card badges
- Add performance highlight to About section
- Add comprehensive Performance section with benchmark results
- Add thread safety note for SetConfig
- Rewrite 'A Personal Perspective' section for clarity and impact
- Add mention of negative-space testing
- Replace Philosophy section with More Projects showcase
- Add footer with author credit
- Update example timestamp to 2025
Reduces minimum Go version from 1.23.3 to 1.21 to support users on
older Go versions. All features used (built-in max() function,
//go:build syntax) are available in Go 1.21.
@nikoksr nikoksr force-pushed the improvements/code-review-fixes branch from 02e791e to 00b91e9 Compare December 12, 2025 20:10
@nikoksr nikoksr merged commit 93474a5 into main Dec 12, 2025
6 checks passed
@nikoksr nikoksr deleted the improvements/code-review-fixes branch December 12, 2025 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant