You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add tests and refactor buildInfo metadata for memory efficiency
Adds comprehensive tests for buildInfo metadata collection and refactors
the implementation to address review comments on memory efficiency.
Tests Added:
- tests/core/buildinfo/metadata_test.go: Runtime test validating BuildInfo
embedding for internal dependencies with multi-level dependency chains
- tests/core/buildinfo/external_deps_test.go: Runtime test for external
dependencies with real version metadata from package_info
- Supporting test infrastructure including BUILD.bazel and README.md
Refactoring Changes (addressing review comments from @fmeum):
1. buildinfo_aspect.bzl - Changed provider schema:
- Split version_map into separate importpaths and metadata_providers depsets
- Only traverse deps/embed attributes instead of all attributes (*)
- Defer version matching to execution time to avoid quadratic memory usage
- Extract empty provider as shared constant (_EMPTY_BUILDINFO_METADATA)
- Remove applicable_licenses fallback (only Bazel 6+ supported)
2. archive.bzl - Removed quadratic aggregation:
- Removed _buildinfo_deps tuple collection from GoArchiveData
- BuildInfo metadata now collected only via aspect, not in archives
- Eliminates O(n²) memory growth with dependency depth
3. link.bzl - Deferred materialization:
- Updated to receive buildinfo_metadata provider instead of pre-computed tuples
- Materialize depsets only once at link time
- Extract versions from package_metadata providers on-demand
4. binary.bzl & rules/binary.bzl - Simplified metadata passing:
- Pass BuildInfoMetadata provider directly instead of creating version_map file
- Removed intermediate file generation and tuple aggregation
The refactoring maintains the same functionality while significantly reducing
memory usage for large dependency graphs by deferring depset materialization
until the final link step.
Tests validate:
- BuildInfo is properly embedded in binaries
- Main package path and Go version are included
- All transitive dependencies appear in dependency list
- Internal packages show "(devel)" as version
- External dependencies with package_metadata show real versions
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
0 commit comments