From 0eec9802fbd0880b06c81ed8cdca24f014b87a17 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Thu, 20 Nov 2025 15:11:57 -0500 Subject: [PATCH] Add 'make generate-fakes' and use it Signed-off-by: Marc Khouzam --- .github/CONTRIBUTING.md | 17 ++++++++++++++++- Makefile | 7 ++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 6bf9409c4a..e4f05b9d51 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -136,7 +136,22 @@ below. The CLI uses [`counterfeiter`](https://github.com/maxbrunsfeld/counterfeiter) to generate fakes from interfaces for the unit tests. If any changes are made to an -interface, the fakes be should regenerated using counterfeiter: +interface, the fakes be should regenerated using counterfeiter. + +### Regenerating all non-legacy fakes + +To regenerate fakes for all non-legacy packages (recommended for most cases): + +```bash +make generate-fakes +``` + +This will safely regenerate fakes in the `util`, `plugin`, `command`, `api`, and +`actor` packages without touching the legacy `cf/` codebase. + +### Regenerating fakes for a specific package + +If you only need to regenerate fakes for a specific package: ```bash go generate .//... diff --git a/Makefile b/Makefile index 4f68fc1cf9..754ea5ddf0 100644 --- a/Makefile +++ b/Makefile @@ -67,6 +67,11 @@ fly-windows-units: format: ## Run go fmt go fmt ./... +generate-fakes: ## Regenerate counterfeiter fakes for non-legacy packages + @echo "Generating fakes for non-legacy packages..." + go generate ./util/... ./plugin/... ./command/... ./api/... ./actor/... + @echo "Fakes generated successfully!" + install-test-deps: ## Install "global" dependencies needed to run tests # Running `go install ` without a version specifier will use version specified in go.mod # See https://go.dev/ref/mod#go-install @@ -235,7 +240,7 @@ units-full: build units-plugin units-non-plugin version: ## Print the version number of what would be built @echo $(CF_BUILD_VERSION)+$(CF_BUILD_SHA).$(CF_BUILD_DATE) -.PHONY: all build clean format version lint +.PHONY: all build clean format generate-fakes version lint .PHONY: test units units-full install-test-deps integration integration-tests-full integration-cleanup integration-experimental integration-plugin integration-isolated integration-push .PHONY: check-target-env fly-windows-experimental fly-windows-isolated fly-windows-plugin fly-windows-push .PHONY: help