Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jun 27, 2025

This PR addresses the issue of testing libraries being included in production builds, which unnecessarily increases binary size.

Problem

The github.com/stretchr/testify library was being imported by non-test files, causing it to be included in production builds even though it's only needed for testing.

Changes Made

1. Renamed test utility files to follow Go conventions

  • block/test_utils.goblock/test_utils_test.go
  • execution/evm/test_helpers.goexecution/evm/test_helpers_test.go

Files with the _test.go suffix are automatically excluded from production builds by the Go compiler.

2. Added build tags to exclude mock files from production

  • Added //go:build test tag to da/internal/mocks/da.go

This ensures mock files are only included when building with the test tag.

Verification

Production builds no longer include testify:

# Production build works without testify
go build ./...

# Verify no testify imports in production code
go mod why github.com/stretchr/testify
# Output: (main module does not need package github.com/stretchr/testify)

Tests continue to work:

# Regular tests pass
go test ./...

# DA module tests with mocks
cd da && go test -tags=test ./...

Impact

  • Reduced binary size: Testing libraries are excluded from production builds
  • Clean separation: Clear distinction between test and production code
  • No breaking changes: All existing tests continue to pass
  • Development workflow preserved: No impact on testing or development

The mock files in the test/ directory are naturally excluded from production builds due to their location, while the renamed utility files and tagged mock files ensure complete separation of test dependencies from production code.

Fixes #2350.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits June 27, 2025 02:03
…lities

Co-authored-by: Manav-Aggarwal <16928547+Manav-Aggarwal@users.noreply.github.com>
Co-authored-by: Manav-Aggarwal <16928547+Manav-Aggarwal@users.noreply.github.com>
Copilot AI changed the title [WIP] Get rid of testing libs from prod environments Remove testing libraries from production environments Jun 27, 2025
Copilot AI requested a review from Manav-Aggarwal June 27, 2025 02:06
@github-actions
Copy link
Contributor

github-actions bot commented Jun 27, 2025

The latest Buf updates on your PR. Results from workflow CI and Release / buf-check (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed⏩ skipped✅ passed✅ passedJun 27, 2025, 2:23 AM

@tac0turtle
Copy link
Contributor

the goal of this issue is to remove tc "github.com/testcontainers/testcontainers-go/modules/compose" from the production path. its not super urgent but this pr doesnt do that

@tac0turtle tac0turtle closed this Jun 30, 2025
@github-project-automation github-project-automation bot moved this to Done in Evolve Jun 30, 2025
@tac0turtle tac0turtle deleted the copilot/fix-2350 branch July 8, 2025 10:22
@tac0turtle tac0turtle removed this from Evolve Aug 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Get rid of testing libs from prod environments

3 participants