From 15b1cbb5fbcf8e5e4203727d56969e15652809f2 Mon Sep 17 00:00:00 2001 From: Jade Guiton Date: Mon, 18 Nov 2024 17:21:07 +0100 Subject: [PATCH 1/3] [chore] `make generate` respects `GROUP` and uses `mdatagen` in `.tools` --- Makefile | 5 ++--- Makefile.Common | 24 ++++++++++++++---------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 86ecba3a3276..1cd97b27a1f4 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ PKG_MODS := $(shell find ./pkg/* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) CMD_MODS_0 := $(shell find ./cmd/[a-m]* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) CMD_MODS_1 := $(shell find ./cmd/[n-z]* $(FIND_MOD_ARGS) -not -path "./cmd/otel*col/*" -exec $(TO_MOD_DIR) ) CMD_MODS := $(CMD_MODS_0) $(CMD_MODS_1) -OTHER_MODS := $(shell find . $(EX_COMPONENTS) $(EX_INTERNAL) $(EX_PKG) $(EX_CMD) $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) $(PWD) +OTHER_MODS := $(shell find . $(EX_COMPONENTS) $(EX_INTERNAL) $(EX_PKG) $(EX_CMD) $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) . ALL_MODS := $(RECEIVER_MODS) $(PROCESSOR_MODS) $(EXPORTER_MODS) $(EXTENSION_MODS) $(CONNECTOR_MODS) $(INTERNAL_MODS) $(PKG_MODS) $(CMD_MODS) $(OTHER_MODS) CGO_MODS := ./receiver/hostmetricsreceiver @@ -307,8 +307,7 @@ docker-telemetrygen: .PHONY: generate generate: install-tools - cd ./internal/tools && go install go.opentelemetry.io/collector/cmd/mdatagen - $(MAKE) for-all CMD="$(GOCMD) generate ./..." + PATH="$$PWD/.tools:$$PATH" $(MAKE) $(FOR_GROUP_TARGET) TARGET="modgenerate" $(MAKE) gofmt .PHONY: githubgen-install diff --git a/Makefile.Common b/Makefile.Common index 07ce7e0d9062..e2be36d87c7d 100644 --- a/Makefile.Common +++ b/Makefile.Common @@ -83,29 +83,29 @@ TESTIFYLINT_OPT?= --enable-all --disable=float-compare,require-error,suite-subte # BUILD_TYPE should be one of (dev, release). BUILD_TYPE?=release -ALL_PKG_DIRS := $(shell $(GOCMD) list -f '{{ .Dir }}' ./... | $(NORMALIZE_DIRS)) +ALL_PKG_DIRS = $(shell $(GOCMD) list -f '{{ .Dir }}' ./... | $(NORMALIZE_DIRS)) -ALL_SRC := $(shell find $(ALL_PKG_DIRS) -name '*.go' \ +ALL_SRC = $(shell find $(ALL_PKG_DIRS) -name '*.go' \ -not -path '*/third_party/*' \ -not -path '*/local/*' \ -type f | sort) -ALL_SRC_AND_SHELL := find . -type f \( -iname '*.go' -o -iname "*.sh" \) ! -path '**/third_party/*' | sort +ALL_SRC_AND_SHELL = find . -type f \( -iname '*.go' -o -iname "*.sh" \) ! -path '**/third_party/*' | sort # All source code and documents. Used in spell check. -ALL_SRC_AND_DOC_CMD := find $(ALL_PKG_DIRS) -name "*.md" -o -name "*.go" -o -name "*.yaml" -not -path '*/third_party/*' -type f | sort +ALL_SRC_AND_DOC_CMD = find $(ALL_PKG_DIRS) -name "*.md" -o -name "*.go" -o -name "*.yaml" -not -path '*/third_party/*' -type f | sort ifeq ($(UNIX_SHELL_ON_WINDOWS),true) # Windows has a low limit, 8192 chars, to create a process. Workaround it by breaking it in smaller commands. - MISSPELL_CMD := $(ALL_SRC_AND_DOC_CMD) | xargs -n 20 $(MISSPELL) - MISSPELL_CORRECTION_CMD := $(ALL_SRC_AND_DOC_CMD) | xargs -n 20 $(MISSPELL_CORRECTION) + MISSPELL_CMD = $(ALL_SRC_AND_DOC_CMD) | xargs -n 20 $(MISSPELL) + MISSPELL_CORRECTION_CMD = $(ALL_SRC_AND_DOC_CMD) | xargs -n 20 $(MISSPELL_CORRECTION) else - ALL_SRC_AND_DOC := $(shell $(ALL_SRC_AND_DOC_CMD)) - MISSPELL_CMD := $(MISSPELL) $(ALL_SRC_AND_DOC) - MISSPELL_CORRECTION_CMD := $(MISSPELL_CORRECTION) $(ALL_SRC_AND_DOC) + ALL_SRC_AND_DOC = $(shell $(ALL_SRC_AND_DOC_CMD)) + MISSPELL_CMD = $(MISSPELL) $(ALL_SRC_AND_DOC) + MISSPELL_CORRECTION_CMD = $(MISSPELL_CORRECTION) $(ALL_SRC_AND_DOC) endif # ALL_PKGS is used with 'go cover' -ALL_PKGS := $(shell $(GOCMD) list $(sort $(dir $(ALL_SRC)))) +ALL_PKGS = $(shell $(GOCMD) list $(sort $(dir $(ALL_SRC)))) ADDLICENSE_CMD := $(ADDLICENSE) -s=only -y "" -c "The OpenTelemetry Authors" @@ -254,3 +254,7 @@ testifylint-fix: gci: $(TOOLS_BIN_DIR)/gci @echo "running $(GCI)" @$(GCI) write -s standard -s default -s "prefix(github.com/open-telemetry/opentelemetry-collector-contrib)" $(ALL_SRC_AND_DOC) + +.PHONY: modgenerate +modgenerate: + $(GOCMD) generate ./... From f49be770170a93f29e380d8bc834ed23ac5a37ed Mon Sep 17 00:00:00 2001 From: Jade Guiton Date: Mon, 18 Nov 2024 17:50:54 +0100 Subject: [PATCH 2/3] Revert superfluous changes --- Makefile | 2 +- Makefile.Common | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 1cd97b27a1f4..7fb147ae8968 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ PKG_MODS := $(shell find ./pkg/* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) CMD_MODS_0 := $(shell find ./cmd/[a-m]* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) CMD_MODS_1 := $(shell find ./cmd/[n-z]* $(FIND_MOD_ARGS) -not -path "./cmd/otel*col/*" -exec $(TO_MOD_DIR) ) CMD_MODS := $(CMD_MODS_0) $(CMD_MODS_1) -OTHER_MODS := $(shell find . $(EX_COMPONENTS) $(EX_INTERNAL) $(EX_PKG) $(EX_CMD) $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) . +OTHER_MODS := $(shell find . $(EX_COMPONENTS) $(EX_INTERNAL) $(EX_PKG) $(EX_CMD) $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) $(PWD) ALL_MODS := $(RECEIVER_MODS) $(PROCESSOR_MODS) $(EXPORTER_MODS) $(EXTENSION_MODS) $(CONNECTOR_MODS) $(INTERNAL_MODS) $(PKG_MODS) $(CMD_MODS) $(OTHER_MODS) CGO_MODS := ./receiver/hostmetricsreceiver diff --git a/Makefile.Common b/Makefile.Common index e2be36d87c7d..7d8bb4244aaa 100644 --- a/Makefile.Common +++ b/Makefile.Common @@ -83,29 +83,29 @@ TESTIFYLINT_OPT?= --enable-all --disable=float-compare,require-error,suite-subte # BUILD_TYPE should be one of (dev, release). BUILD_TYPE?=release -ALL_PKG_DIRS = $(shell $(GOCMD) list -f '{{ .Dir }}' ./... | $(NORMALIZE_DIRS)) +ALL_PKG_DIRS := $(shell $(GOCMD) list -f '{{ .Dir }}' ./... | $(NORMALIZE_DIRS)) -ALL_SRC = $(shell find $(ALL_PKG_DIRS) -name '*.go' \ +ALL_SRC := $(shell find $(ALL_PKG_DIRS) -name '*.go' \ -not -path '*/third_party/*' \ -not -path '*/local/*' \ -type f | sort) -ALL_SRC_AND_SHELL = find . -type f \( -iname '*.go' -o -iname "*.sh" \) ! -path '**/third_party/*' | sort +ALL_SRC_AND_SHELL := find . -type f \( -iname '*.go' -o -iname "*.sh" \) ! -path '**/third_party/*' | sort # All source code and documents. Used in spell check. -ALL_SRC_AND_DOC_CMD = find $(ALL_PKG_DIRS) -name "*.md" -o -name "*.go" -o -name "*.yaml" -not -path '*/third_party/*' -type f | sort +ALL_SRC_AND_DOC_CMD := find $(ALL_PKG_DIRS) -name "*.md" -o -name "*.go" -o -name "*.yaml" -not -path '*/third_party/*' -type f | sort ifeq ($(UNIX_SHELL_ON_WINDOWS),true) # Windows has a low limit, 8192 chars, to create a process. Workaround it by breaking it in smaller commands. - MISSPELL_CMD = $(ALL_SRC_AND_DOC_CMD) | xargs -n 20 $(MISSPELL) - MISSPELL_CORRECTION_CMD = $(ALL_SRC_AND_DOC_CMD) | xargs -n 20 $(MISSPELL_CORRECTION) + MISSPELL_CMD := $(ALL_SRC_AND_DOC_CMD) | xargs -n 20 $(MISSPELL) + MISSPELL_CORRECTION_CMD := $(ALL_SRC_AND_DOC_CMD) | xargs -n 20 $(MISSPELL_CORRECTION) else - ALL_SRC_AND_DOC = $(shell $(ALL_SRC_AND_DOC_CMD)) - MISSPELL_CMD = $(MISSPELL) $(ALL_SRC_AND_DOC) - MISSPELL_CORRECTION_CMD = $(MISSPELL_CORRECTION) $(ALL_SRC_AND_DOC) + ALL_SRC_AND_DOC := $(shell $(ALL_SRC_AND_DOC_CMD)) + MISSPELL_CMD := $(MISSPELL) $(ALL_SRC_AND_DOC) + MISSPELL_CORRECTION_CMD := $(MISSPELL_CORRECTION) $(ALL_SRC_AND_DOC) endif # ALL_PKGS is used with 'go cover' -ALL_PKGS = $(shell $(GOCMD) list $(sort $(dir $(ALL_SRC)))) +ALL_PKGS := $(shell $(GOCMD) list $(sort $(dir $(ALL_SRC)))) ADDLICENSE_CMD := $(ADDLICENSE) -s=only -y "" -c "The OpenTelemetry Authors" From d3400def4a1a79f8a3636eaed22ae3e46cb7666e Mon Sep 17 00:00:00 2001 From: Jade Guiton Date: Tue, 19 Nov 2024 14:13:38 +0100 Subject: [PATCH 3/3] Remove `modgenerate` target --- Makefile | 2 +- Makefile.Common | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 7fb147ae8968..40f4df619c81 100644 --- a/Makefile +++ b/Makefile @@ -307,7 +307,7 @@ docker-telemetrygen: .PHONY: generate generate: install-tools - PATH="$$PWD/.tools:$$PATH" $(MAKE) $(FOR_GROUP_TARGET) TARGET="modgenerate" + PATH="$$PWD/.tools:$$PATH" $(MAKE) for-all CMD="$(GOCMD) generate ./..." $(MAKE) gofmt .PHONY: githubgen-install diff --git a/Makefile.Common b/Makefile.Common index 7d8bb4244aaa..07ce7e0d9062 100644 --- a/Makefile.Common +++ b/Makefile.Common @@ -254,7 +254,3 @@ testifylint-fix: gci: $(TOOLS_BIN_DIR)/gci @echo "running $(GCI)" @$(GCI) write -s standard -s default -s "prefix(github.com/open-telemetry/opentelemetry-collector-contrib)" $(ALL_SRC_AND_DOC) - -.PHONY: modgenerate -modgenerate: - $(GOCMD) generate ./...