Skip to content

feat(build): split makefile, ensure tools isolation.#1041

Closed
Zenithar wants to merge 2 commits intomainfrom
zenithar/chaos-controller/modernise_makefile
Closed

feat(build): split makefile, ensure tools isolation.#1041
Zenithar wants to merge 2 commits intomainfrom
zenithar/chaos-controller/modernise_makefile

Conversation

@Zenithar
Copy link

@Zenithar Zenithar commented Feb 18, 2026

[Build] Modularise Makefile and isolate tool management

Summary

What: Splits the monolithic 530+ line Makefile into focused modules under mk/ and introduces stamp-based isolated tool management in .tools/.

Why: The original Makefile was difficult to navigate, mixed concerns (build, test, lint, deploy, tool installation), and installed tools globally into $GOBIN, causing version conflicts between projects and non-reproducible developer environments.

How: The root Makefile becomes a thin entry point that sets shared variables and includes seven domain-specific modules. All tool binaries are now installed in a project-local .tools/bin/ directory, with stamp files that track versions, so Make skips reinstalling when versions haven't changed.

Changes

Build System (Makefile, mk/*.mk):

  • Refactored monolithic Makefile (530 lines) into a thin entry point (~100 lines) with shared variables
  • Created mk/tools.mk — Stamp-based tool version management, all tools install to .tools/bin/
  • Created mk/docker.mk — Docker build, save, and push targets for injector/handler/manager
  • Created mk/test.mk — Unit tests, e2e tests, and chaosli test targets
  • Created mk/generate.mk — CRD manifests, deepcopy, protobuf (DRY template), and mock generation
  • Created mk/lint.mkfmt, vet, lint, and spellcheck targets
  • Created mk/lima.mk — Lima cluster lifecycle, deployment, and local development helpers
  • Created mk/ci.mk — CI-specific targets (minikube, headers, licenses, deps, release, Datadog agent)
  • Added make help target that auto-generates help from ## comments

Tool Isolation:

  • All tools install to .tools/bin/ instead of global $GOBIN
  • Stamp files in .tools/stamps/ track installed versions — version bumps trigger reinstall, same version is a no-op
  • Added .tools/ to .gitignore
  • PATH is extended at the Makefile level to include .tools/bin/
  • clean-tools target to wipe the local tool directory

Protobuf:

  • Regenerated chaosdogfood.pb.go and disruptionlistener.pb.go with protoc-gen-go v1.36.11 (aligned with go.mod)
  • Protobuf generation now uses a DRY foreach template instead of duplicated targets
  • protoc-gen-go and protoc-gen-go-grpc are managed as isolated tools with pinned versions

Other:

  • Replaced = (recursive) with := (simple) for most variable assignments where appropriate
  • Standardised .PHONY declarations across all targets
  • Aligned variable formatting for readability

Testing

Unit Tests:

  • make test still works as before (generates + runs ginkgo suite)
  • make lint installs golangci-lint locally and runs

Manual Testing:

  • make help displays all available targets
  • Tools install to .tools/bin/ on first use
  • Subsequent make invocations skip tool install (stamp hit)
  • make clean-tools removes .tools/
  • make generate works with locally installed controller-gen
  • make manifests works with locally installed controller-gen + yamlfmt

Breaking Changes

Potential behavioural change:

  • Tools are no longer installed into global $GOBIN / $GOPATH/bin. They now go to .tools/bin/. This is intentional but means running golangci-lint or controller-gen directly outside of Make will use the system-installed version, not the project-pinned one.
  • The spellcheck-report and spellcheck-format-spelling targets were removed (they were rarely used utilities).

Dependencies

  • No new Go dependencies added
  • protoc-gen-go bumped from v1.27.1 to v1.36.11 (aligned with go.mod dependency and generated code updated accordingly)
  • No changes to go.mod / go.sum

Checklist

  • All existing Make targets preserved (no functional regression)
  • .tools/ added to .gitignore
  • Generated protobuf code regenerated with updated tooling
  • make help provides discoverability for all targets
  • No sensitive information in committed files

@Zenithar Zenithar self-assigned this Feb 18, 2026
@datadog-datadog-prod-us1
Copy link

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 39.29% (+0.00%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: c27cc6c | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@Zenithar
Copy link
Author

Closing this PR in favour of a deeper building system restructuring.

@Zenithar Zenithar closed this Feb 18, 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.

1 participant

Comments