Skip to content

Conversation

@tac0turtle
Copy link
Contributor

Overview

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @tac0turtle, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This PR introduces a dedicated Makefile (tools/tools.mk) to streamline the build, installation, and management of various development tools (da-debug, blob-decoder, cache-analyzer). This new Makefile is integrated into the main Makefile, providing convenient targets for these operations, including versioning support.

Highlights

  • Intent: This pull request aims to integrate build and management targets for various development tools into the project's Makefile system. Specifically, it introduces a new Makefile dedicated to building, installing, cleaning, and listing tools like da-debug, blob-decoder, and cache-analyzer.
  • Changes: The primary change involves adding a new Makefile, tools/tools.mk, which defines targets for managing project-specific tools. This new Makefile is then included in the main Makefile to make these targets accessible. The tools/tools.mk file provides targets such as build-tool-<name>, install-tool-<name>, build-tools (to build all), install-tools (to install all), clean-tools, and list-tools. It also sets up LDFLAGS for versioning information during tool compilation.
  • Reviewer Activity: No specific reviewer activity or comments were provided in the context.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@claude
Copy link
Contributor

claude bot commented Oct 8, 2025

Claude finished @tac0turtle's task —— View job


Code Review Complete

I've reviewed the PR and identified several areas for improvement. Overall, this is a good addition that provides useful build targets for the tools, but there are some maintainability and correctness issues to address.


Critical Issues

1. LDFLAGS Variable Conflict (tools/tools.mk:12-14)

Issue: The LDFLAGS variable uses ?= (conditional assignment), which means it will be overridden by the definition in scripts/build.mk that's included earlier in the main Makefile. The scripts/build.mk defines:

LDFLAGS := \
	-X github.com/evstack/ev-node/pkg/cmd.Version=$(VERSION) \
	-X github.com/evstack/ev-node/pkg/cmd.GitSHA=$(GITSHA)

This targets github.com/evstack/ev-node/pkg/cmd.Version and github.com/evstack/ev-node/pkg/cmd.GitSHA, which don't exist in the tool binaries.

Impact: Version information won't be correctly embedded in the tool binaries. The linker flags will try to set variables in a package path that doesn't match the tools' main packages.

Recommendation: Use a dedicated variable name like TOOLS_LDFLAGS to avoid conflicts:

TOOLS_LDFLAGS := \
	-X main.Version=$(VERSION) \
	-X main.GitSHA=$(GITSHA)

Then update all build/install commands to use $(TOOLS_LDFLAGS) instead of $(LDFLAGS).

2. Missing Version Variables in Tool Binaries

Issue: None of the tool main packages (da-debug, blob-decoder, cache-analyzer) define Version or GitSHA variables that the linker flags are trying to set.

Impact: Even with correct LDFLAGS, the version injection won't work because the target variables don't exist.

Recommendation: Add version variables to each tool's main.go:

var (
	Version = "dev"
	GitSHA  = "unknown"
)

Then expose them through a version command or --version flag.


Maintainability Issues

3. Significant Code Duplication (tools/tools.mk:16-73)

Issue: The build and install targets are highly repetitive. Each tool has nearly identical target definitions, differing only in the tool name. This violates the DRY principle and makes maintenance harder:

  • Adding a new tool requires copying and pasting ~12 lines of code twice
  • Changing build flags or behavior requires updating multiple targets
  • Risk of inconsistencies between tool targets

Current pattern (repeated 3 times for build, 3 times for install):

build-tool-da-debug:
	@echo "--> Building da-debug tool"
	@mkdir -p $(TOOLS_BUILD_DIR)
	@cd tools/da-debug && go build -ldflags "$(LDFLAGS)" -o $(TOOLS_BUILD_DIR)/da-debug .
	@echo "--> da-debug built: $(TOOLS_BUILD_DIR)/da-debug"
.PHONY: build-tool-da-debug

Recommendation: Use Make's define and eval to generate targets from templates. This is a standard Make pattern for reducing duplication. Here's a suggested refactor:

# Define build template
define BUILD_TOOL_template
## build-tool-$(1): Build $(1) tool
build-tool-$(1):
	@echo "--> Building $(1) tool"
	@mkdir -p $$(TOOLS_BUILD_DIR)
	@cd tools/$(1) && go build -ldflags "$$(TOOLS_LDFLAGS)" -o $$(TOOLS_BUILD_DIR)/$(1) .
	@echo "--> $(1) built: $$(TOOLS_BUILD_DIR)/$(1)"
.PHONY: build-tool-$(1)
endef

# Define install template
define INSTALL_TOOL_template
## install-tool-$(1): Install $(1) tool to Go bin
install-tool-$(1):
	@echo "--> Installing $(1) tool"
	@cd tools/$(1) && go install -ldflags "$$(TOOLS_LDFLAGS)" .
	@echo "--> $(1) installed to Go bin"
.PHONY: install-tool-$(1)
endef

# Generate all targets
$(foreach tool,$(TOOLS),$(eval $(call BUILD_TOOL_template,$(tool))))
$(foreach tool,$(TOOLS),$(eval $(call INSTALL_TOOL_template,$(tool))))

Benefits:

  • Adding a new tool only requires updating the TOOLS variable
  • Changes to build/install logic happen in one place
  • Reduced file size (90 lines → ~40 lines)
  • Easier to maintain and less error-prone

Documentation & Quality

4. README Improvements Look Good

The additions to the README files are excellent:

  • da-debug/README.md: Added installation section (lines 9-18)
  • cache-analyzer/README.md: Added installation section (lines 9-18)
  • blob-decoder/README.md: New comprehensive documentation

These provide clear installation instructions using go install, which complements the new Makefile targets nicely.

5. Good Build System Integration

The integration into the main Makefile (line 6) follows the existing pattern and the targets are well-organized with:

  • Clear target naming (build-tool-*, install-tool-*)
  • Helpful comments for make help
  • Logical grouping (build, install, clean, list)

Recommendations Summary

Priority: High

  1. Fix LDFLAGS variable conflict by using TOOLS_LDFLAGS
  2. Add Version and GitSHA variables to tool main packages

Priority: Medium
3. Refactor to use template-based target generation to reduce duplication

Optional Enhancements
4. Consider adding a version command to each tool to display the injected version info
5. Consider adding tests for the build targets (e.g., in CI)


Testing Notes

I recommend testing the build targets to verify:

make build-tools          # Should build all three tools
make install-tools        # Should install all three tools
make build-tool-da-debug  # Should build individual tool
make list-tools           # Should list available tools

After fixing the LDFLAGS issues, verify version injection works:

./build/da-debug --version  # Should show actual version

julienrbrt
julienrbrt previously approved these changes Oct 8, 2025
Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@github-actions
Copy link
Contributor

github-actions bot commented Oct 8, 2025

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

BuildFormatLintBreakingUpdated (UTC)
✅ passed⏩ skipped✅ passed✅ passedOct 8, 2025, 8:49 AM

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

Thank you for adding this Makefile for the tools. I've found a couple of areas for improvement related to maintainability and a bug in how version information is handled. My main suggestion combines a fix for the bug with a refactoring to make the Makefile much cleaner and easier to maintain in the future. Please take a look at the detailed comment.

Comment on lines +12 to +73
LDFLAGS ?= \
-X main.Version=$(VERSION) \
-X main.GitSHA=$(GITSHA)

# Individual tool build targets
## build-tool-da-debug: Build da-debug tool
build-tool-da-debug:
@echo "--> Building da-debug tool"
@mkdir -p $(TOOLS_BUILD_DIR)
@cd tools/da-debug && go build -ldflags "$(LDFLAGS)" -o $(TOOLS_BUILD_DIR)/da-debug .
@echo "--> da-debug built: $(TOOLS_BUILD_DIR)/da-debug"
.PHONY: build-tool-da-debug

## build-tool-blob-decoder: Build blob-decoder tool
build-tool-blob-decoder:
@echo "--> Building blob-decoder tool"
@mkdir -p $(TOOLS_BUILD_DIR)
@cd tools/blob-decoder && go build -ldflags "$(LDFLAGS)" -o $(TOOLS_BUILD_DIR)/blob-decoder .
@echo "--> blob-decoder built: $(TOOLS_BUILD_DIR)/blob-decoder"
.PHONY: build-tool-blob-decoder

## build-tool-cache-analyzer: Build cache-analyzer tool
build-tool-cache-analyzer:
@echo "--> Building cache-analyzer tool"
@mkdir -p $(TOOLS_BUILD_DIR)
@cd tools/cache-analyzer && go build -ldflags "$(LDFLAGS)" -o $(TOOLS_BUILD_DIR)/cache-analyzer .
@echo "--> cache-analyzer built: $(TOOLS_BUILD_DIR)/cache-analyzer"
.PHONY: build-tool-cache-analyzer

# Build all tools
## build-tools: Build all tools
build-tools: $(addprefix build-tool-, $(TOOLS))
@echo "--> All tools built successfully!"
.PHONY: build-tools

# Install individual tools
## install-tool-da-debug: Install da-debug tool to Go bin
install-tool-da-debug:
@echo "--> Installing da-debug tool"
@cd tools/da-debug && go install -ldflags "$(LDFLAGS)" .
@echo "--> da-debug installed to Go bin"
.PHONY: install-tool-da-debug

## install-tool-blob-decoder: Install blob-decoder tool to Go bin
install-tool-blob-decoder:
@echo "--> Installing blob-decoder tool"
@cd tools/blob-decoder && go install -ldflags "$(LDFLAGS)" .
@echo "--> blob-decoder installed to Go bin"
.PHONY: install-tool-blob-decoder

## install-tool-cache-analyzer: Install cache-analyzer tool to Go bin
install-tool-cache-analyzer:
@echo "--> Installing cache-analyzer tool"
@cd tools/cache-analyzer && go install -ldflags "$(LDFLAGS)" .
@echo "--> cache-analyzer installed to Go bin"
.PHONY: install-tool-cache-analyzer

# Install all tools
## install-tools: Install all tools to Go bin
install-tools: $(addprefix install-tool-, $(TOOLS))
@echo "--> All tools installed successfully!"
.PHONY: install-tools
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This new Makefile for tools has a couple of areas for improvement regarding maintainability and correctness.

  1. Code Duplication: The build-tool-* and install-tool-* targets are highly repetitive. This makes the file verbose and harder to maintain. Adding a new tool requires duplicating code blocks, which is error-prone.
  2. Incorrect Linker Flags: The LDFLAGS variable is defined with ?= and is being overridden by a definition in scripts/build.mk meant for a different application. This means the version information is not being correctly embedded into the tool binaries. Furthermore, the tool's main packages are missing the Version and GitSHA variables that the linker flags are trying to set.

I suggest a refactoring that addresses both issues. This involves:

  • Using define and foreach to generate the build/install targets from a template, adhering to the DRY (Don't Repeat Yourself) principle.
  • Using a dedicated variable TOOLS_LDFLAGS for the tools' linker flags to avoid conflicts.

Here is a suggested replacement that incorporates these improvements. Please note that you will still need to add the Version and GitSHA variables to the main package of each Go tool for the version injection to work.

TOOLS_LDFLAGS := \
	-X main.Version=$(VERSION) \
	-X main.GitSHA=$(GITSHA)

# --- Template for building a tool ---
define BUILD_TOOL_template
## build-tool-$(1): Build $(1) tool
build-tool-$(1):
	@echo "--> Building $(1) tool"
	@mkdir -p $$(TOOLS_BUILD_DIR)
	@cd tools/$(1) && go build -ldflags "$$(TOOLS_LDFLAGS)" -o $$(TOOLS_BUILD_DIR)/$(1) .
	@echo "--> $(1) built: $$(TOOLS_BUILD_DIR)/$(1)"
.PHONY: build-tool-$(1)
endef

# --- Template for installing a tool ---
define INSTALL_TOOL_template
## install-tool-$(1): Install $(1) tool to Go bin
install-tool-$(1):
	@echo "--> Installing $(1) tool"
	@cd tools/$(1) && go install -ldflags "$$(TOOLS_LDFLAGS)" .
	@echo "--> $(1) installed to Go bin"
.PHONY: install-tool-$(1)
endef

# --- Generate targets from templates ---
$(foreach tool,$(TOOLS),$(eval $(call BUILD_TOOL_template,$(tool))))
$(foreach tool,$(TOOLS),$(eval $(call INSTALL_TOOL_template,$(tool))))

# Build all tools
## build-tools: Build all tools
build-tools: $(addprefix build-tool-, $(TOOLS))
	@echo "--> All tools built successfully!"
.PHONY: build-tools

# Install all tools
## install-tools: Install all tools to Go bin
install-tools: $(addprefix install-tool-, $(TOOLS))
	@echo "--> All tools installed successfully!"
.PHONY: install-tools

@codecov
Copy link

codecov bot commented Oct 8, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.17%. Comparing base (fdc59ab) to head (882f535).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2743   +/-   ##
=======================================
  Coverage   62.17%   62.17%           
=======================================
  Files          79       79           
  Lines        8497     8497           
=======================================
  Hits         5283     5283           
  Misses       2721     2721           
  Partials      493      493           
Flag Coverage Δ
combined 62.17% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tac0turtle tac0turtle merged commit 2c85e06 into main Oct 8, 2025
21 of 22 checks passed
@tac0turtle tac0turtle deleted the marko/tools-make branch October 8, 2025 08:50
@github-project-automation github-project-automation bot moved this to Done in Evolve Oct 8, 2025
alpe added a commit that referenced this pull request Oct 9, 2025
* main:
  feat(store)!: add batching for atomicity  (#2746)
  refactor(apps): rollback cmd updates (#2744)
  chore: add makefile for tools (#2743)
  chore: fix markdown lint (#2742)
  build(deps): Bump the all-go group across 5 directories with 6 updates (#2738)
  refactor(block): improve cancellation (#2741)
  chore: make the prompt go oriented  (#2739)
  perf(block): use `sync/atomic` instead of mutexes (#2735)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants