Skip to content

Conversation

@claude
Copy link

@claude claude bot commented Jan 22, 2026

Summary

  • Extract common variables (BUILD_DIR, MODULE, LDFLAGS, DOCKER_REGISTRY, COVER_FILE) for better maintainability
  • Fix coverage file naming from go-sim-lb.cover.tmp (copy-paste artifact) to go-template.cover.tmp
  • Fix Docker image tags with proper registry/name:version format
  • Add docker target to build all images
  • Improve lint target with proper error handling for gofmt/gofumpt
  • Add install target for installing binaries to GOPATH/bin
  • Add run-cli and run-httpserver targets for local development
  • Use rm -f instead of unlink for better portability
  • Add Docker section header for better organization

New Targets Available

make install         # Install binaries to GOPATH/bin
make docker          # Build all Docker images
make run-cli         # Build and run the CLI
make run-httpserver  # Build and run the HTTP server

Configuration Variables

The Makefile now supports these configurable variables:

  • DOCKER_REGISTRY - Set your Docker registry (default: your-registry)
  • Example: make docker-cli DOCKER_REGISTRY=ghcr.io/flashbots

Closes #4

Generated with Claude Code

metachris and others added 2 commits January 22, 2026 11:17
- Extract common variables (BUILD_DIR, MODULE, LDFLAGS, DOCKER_REGISTRY, COVER_FILE)
- Fix coverage file naming from go-sim-lb to go-template
- Fix Docker image tags with proper registry/name:version format
- Add docker target to build all images
- Improve lint target with proper error handling for gofmt/gofumpt
- Add install target for installing binaries to GOPATH/bin
- Add run-cli and run-httpserver targets for local development
- Use rm -f instead of unlink for better portability
- Add Docker section header for better organization

Closes #4

Co-authored-by: Chris Hager <metachris@users.noreply.github.com>
@claude
Copy link
Author

claude bot commented Jan 22, 2026

Claude finished @claude[bot]'s task in 1m 9s —— View job


PR Review: Makefile Improvements

  • Analyze PR changes
  • Review Makefile improvements
  • Check for bugs, security issues, and best practices
  • Provide review feedback

Overall Assessment: ✅ Good PR with solid improvements

This PR brings welcome organizational improvements to the Makefile. The changes are well-structured and follow Makefile best practices.

What's Good

  1. Variable extraction - Consolidating BUILD_DIR, MODULE, LDFLAGS, and COVER_FILE into variables at the top improves maintainability significantly

  2. Fixed copy-paste artifact - Renaming go-sim-lb.cover.tmp to go-template.cover.tmp corrects an obvious copy-paste oversight

  3. Docker image tagging - The new format $(DOCKER_REGISTRY)/cli:$(VERSION) with both version and latest tags follows best practices

  4. Portability improvement - Replacing unlink with rm -f improves cross-platform compatibility (some systems don't have unlink)

  5. New convenience targets - install, docker, run-cli, and run-httpserver targets add useful development workflows

Suggestions (see inline comments)

  1. Lint error handling (line 64) - The 2>&1 redirect in the lint checks may mask certain error conditions. Consider a cleaner pattern.

  2. Docker registry validation (line 12) - The default your-registry placeholder could benefit from a guard to prevent accidental use.

Minor Notes

  • The docker composite target and ##@ Docker section header improve discoverability
  • Using ?= for DOCKER_REGISTRY allows easy overrides via environment variables

LGTM with minor suggestions. The improvements are meaningful and the code is clean.

lint: ## Run linters
gofmt -d -s .
gofumpt -d -extra .
@if [ -n "$$(gofmt -d -s . 2>&1)" ]; then gofmt -d -s .; exit 1; fi
Copy link
Author

Choose a reason for hiding this comment

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

⚠️ Potential Issue: The lint check logic has a subtle bug. gofmt -d -s . sends the diff to stdout, but the 2>&1 redirect captures stderr too. If gofmt finds formatting issues, it outputs them to stdout (not stderr), but the exit code is still 0. Your check works because you're testing if there's any output.

However, there's a potential edge case: if gofmt encounters an error (e.g., syntax error in a Go file), it writes to stderr and returns a non-zero exit code. With 2>&1, you're now capturing error messages too, which could mask the original error behavior.

Consider a cleaner approach that separates the concerns:

@gofmt -d -s . | grep . && exit 1 || true

Or to be more explicit about the intent:

@test -z "$$(gofmt -d -s .)" || (gofmt -d -s . && exit 1)

The current implementation will work for the common case, but the error handling could be improved.

LDFLAGS := -X $(MODULE)/common.Version=$(VERSION)

# Docker configuration
DOCKER_REGISTRY ?= your-registry
Copy link
Author

Choose a reason for hiding this comment

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

💡 Suggestion: The default registry value your-registry is a good placeholder, but consider adding a comment or validation to remind users to set this before using Docker targets.

Alternatively, you could add a guard in the docker targets:

docker-cli: ## Build the CLI Docker image
	@test "$(DOCKER_REGISTRY)" != "your-registry" || (echo "Error: DOCKER_REGISTRY must be set" && exit 1)
	...

This would prevent accidentally pushing images to a non-existent registry.

@metachris metachris force-pushed the main branch 10 times, most recently from 9573153 to a3b3190 Compare January 22, 2026 16:29
@metachris metachris closed this Jan 28, 2026
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.

@claude review the Makefile and implement improvements

1 participant