| 
									
										
										
										
											2020-03-25 14:47:17 -07:00
										 |  |  | # Copyright The OpenTelemetry Authors
 | 
					
						
							| 
									
										
										
										
											2024-02-29 07:05:28 +01:00
										 |  |  | # SPDX-License-Identifier: Apache-2.0
 | 
					
						
							| 
									
										
										
										
											2020-03-25 14:47:17 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-09 12:14:03 -04:00
										 |  |  | TOOLS_MOD_DIR := ./internal/tools | 
					
						
							| 
									
										
										
										
											2019-09-19 18:16:09 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-02 10:44:32 -07:00
										 |  |  | ALL_DOCS := $(shell find . -name '*.md' -type f | sort) | 
					
						
							| 
									
										
										
										
											2022-02-15 14:03:38 -08:00
										 |  |  | ALL_GO_MOD_DIRS := $(shell find . -type f -name 'go.mod' -exec dirname {} \; | sort) | 
					
						
							|  |  |  | OTEL_GO_MOD_DIRS := $(filter-out $(TOOLS_MOD_DIR), $(ALL_GO_MOD_DIRS)) | 
					
						
							| 
									
										
										
										
											2022-10-19 13:45:39 -07:00
										 |  |  | ALL_COVERAGE_MOD_DIRS := $(shell find . -type f -name 'go.mod' -exec dirname {} \; | grep -E -v '^./example|^$(TOOLS_MOD_DIR)' | sort) | 
					
						
							| 
									
										
										
										
											2019-08-02 10:44:32 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-01 08:38:23 -08:00
										 |  |  | GO = go | 
					
						
							|  |  |  | TIMEOUT = 60 | 
					
						
							| 
									
										
										
										
											2019-07-02 16:21:24 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-29 14:20:03 -08:00
										 |  |  | # User to run as in docker images.
 | 
					
						
							|  |  |  | DOCKER_USER=$(shell id -u):$(shell id -g) | 
					
						
							|  |  |  | DEPENDENCIES_DOCKERFILE=./dependencies.Dockerfile | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-02 16:21:24 -07:00
										 |  |  | .DEFAULT_GOAL := precommit | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-01 08:38:23 -08:00
										 |  |  | .PHONY: precommit ci | 
					
						
							| 
									
										
										
										
											2024-11-18 02:33:55 -07:00
										 |  |  | precommit: generate toolchain-check license-check misspell go-mod-tidy golangci-lint-fix verify-readmes verify-mods test-default | 
					
						
							|  |  |  | ci: generate toolchain-check license-check lint vanity-import-check verify-readmes verify-mods build test-default check-clean-work-tree test-coverage | 
					
						
							| 
									
										
										
										
											2019-06-18 17:09:49 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-01 08:38:23 -08:00
										 |  |  | # Tools
 | 
					
						
							| 
									
										
										
										
											2019-06-18 17:09:49 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-01 08:38:23 -08:00
										 |  |  | TOOLS = $(CURDIR)/.tools | 
					
						
							| 
									
										
										
										
											2019-06-18 17:09:49 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-01 08:38:23 -08:00
										 |  |  | $(TOOLS): | 
					
						
							|  |  |  | 	@mkdir -p $@ | 
					
						
							| 
									
										
										
										
											2024-04-19 09:02:14 +02:00
										 |  |  | $(TOOLS)/%: $(TOOLS_MOD_DIR)/go.mod | $(TOOLS) | 
					
						
							| 
									
										
										
										
											2020-02-07 03:51:00 +09:00
										 |  |  | 	cd $(TOOLS_MOD_DIR) && \
 | 
					
						
							| 
									
										
										
										
											2021-03-01 08:38:23 -08:00
										 |  |  | 	$(GO) build -o $@ $(PACKAGE) | 
					
						
							| 
									
										
										
										
											2019-08-02 10:44:32 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-01 16:20:32 -04:00
										 |  |  | MULTIMOD = $(TOOLS)/multimod | 
					
						
							|  |  |  | $(TOOLS)/multimod: PACKAGE=go.opentelemetry.io/build-tools/multimod | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-01 08:38:23 -08:00
										 |  |  | CROSSLINK = $(TOOLS)/crosslink | 
					
						
							| 
									
										
										
										
											2022-05-06 07:40:59 -07:00
										 |  |  | $(TOOLS)/crosslink: PACKAGE=go.opentelemetry.io/build-tools/crosslink | 
					
						
							| 
									
										
										
										
											2019-08-22 20:16:51 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-12 13:40:43 -07:00
										 |  |  | SEMCONVKIT = $(TOOLS)/semconvkit | 
					
						
							|  |  |  | $(TOOLS)/semconvkit: PACKAGE=go.opentelemetry.io/otel/$(TOOLS_MOD_DIR)/semconvkit | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-15 11:01:30 +02:00
										 |  |  | VERIFYREADMES = $(TOOLS)/verifyreadmes | 
					
						
							|  |  |  | $(TOOLS)/verifyreadmes: PACKAGE=go.opentelemetry.io/otel/$(TOOLS_MOD_DIR)/verifyreadmes | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-01 08:38:23 -08:00
										 |  |  | GOLANGCI_LINT = $(TOOLS)/golangci-lint | 
					
						
							| 
									
										
										
										
											2025-03-26 10:46:44 -07:00
										 |  |  | $(TOOLS)/golangci-lint: PACKAGE=github.com/golangci/golangci-lint/v2/cmd/golangci-lint | 
					
						
							| 
									
										
										
										
											2020-03-30 13:10:18 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-01 08:38:23 -08:00
										 |  |  | MISSPELL = $(TOOLS)/misspell | 
					
						
							| 
									
										
										
										
											2021-09-28 04:37:26 +02:00
										 |  |  | $(TOOLS)/misspell: PACKAGE=github.com/client9/misspell/cmd/misspell | 
					
						
							| 
									
										
										
										
											2019-07-02 16:21:24 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-14 17:10:15 +02:00
										 |  |  | GOCOVMERGE = $(TOOLS)/gocovmerge | 
					
						
							| 
									
										
										
										
											2021-09-28 04:37:26 +02:00
										 |  |  | $(TOOLS)/gocovmerge: PACKAGE=github.com/wadey/gocovmerge | 
					
						
							| 
									
										
										
										
											2021-08-14 17:10:15 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-01 08:38:23 -08:00
										 |  |  | STRINGER = $(TOOLS)/stringer | 
					
						
							|  |  |  | $(TOOLS)/stringer: PACKAGE=golang.org/x/tools/cmd/stringer | 
					
						
							| 
									
										
										
										
											2020-08-24 09:43:29 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-28 04:37:26 +02:00
										 |  |  | PORTO = $(TOOLS)/porto | 
					
						
							|  |  |  | $(TOOLS)/porto: PACKAGE=github.com/jcchavezs/porto/cmd/porto | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-02 12:28:35 -07:00
										 |  |  | GOTMPL = $(TOOLS)/gotmpl | 
					
						
							|  |  |  | $(GOTMPL): PACKAGE=go.opentelemetry.io/build-tools/gotmpl | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-14 16:42:08 +02:00
										 |  |  | GORELEASE = $(TOOLS)/gorelease | 
					
						
							|  |  |  | $(GORELEASE): PACKAGE=golang.org/x/exp/cmd/gorelease | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-10 14:13:37 +05:30
										 |  |  | GOVULNCHECK = $(TOOLS)/govulncheck | 
					
						
							|  |  |  | $(TOOLS)/govulncheck: PACKAGE=golang.org/x/vuln/cmd/govulncheck | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-01 08:38:23 -08:00
										 |  |  | .PHONY: tools | 
					
						
							| 
									
										
										
										
											2025-07-07 12:23:23 -07:00
										 |  |  | tools: $(CROSSLINK) $(GOLANGCI_LINT) $(MISSPELL) $(GOCOVMERGE) $(STRINGER) $(PORTO) $(VERIFYREADMES) $(MULTIMOD) $(SEMCONVKIT) $(GOTMPL) $(GORELEASE) | 
					
						
							| 
									
										
										
										
											2019-07-02 16:21:24 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-18 09:06:27 -07:00
										 |  |  | # Virtualized python tools via docker
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # The directory where the virtual environment is created.
 | 
					
						
							|  |  |  | VENVDIR := venv | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # The directory where the python tools are installed.
 | 
					
						
							|  |  |  | PYTOOLS := $(VENVDIR)/bin | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # The pip executable in the virtual environment.
 | 
					
						
							|  |  |  | PIP := $(PYTOOLS)/pip | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # The directory in the docker image where the current directory is mounted.
 | 
					
						
							|  |  |  | WORKDIR := /workdir | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # The python image to use for the virtual environment.
 | 
					
						
							| 
									
										
										
										
											2025-01-29 14:20:03 -08:00
										 |  |  | PYTHONIMAGE := $(shell awk '$$4=="python" {print $$2}' $(DEPENDENCIES_DOCKERFILE)) | 
					
						
							| 
									
										
										
										
											2023-05-18 09:06:27 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | # Run the python image with the current directory mounted.
 | 
					
						
							| 
									
										
										
										
											2025-01-29 14:20:03 -08:00
										 |  |  | DOCKERPY := docker run --rm -u $(DOCKER_USER) -v "$(CURDIR):$(WORKDIR)" -w $(WORKDIR) $(PYTHONIMAGE) | 
					
						
							| 
									
										
										
										
											2023-05-18 09:06:27 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | # Create a virtual environment for Python tools.
 | 
					
						
							|  |  |  | $(PYTOOLS): | 
					
						
							|  |  |  | # The `--upgrade` flag is needed to ensure that the virtual environment is
 | 
					
						
							|  |  |  | # created with the latest pip version.
 | 
					
						
							| 
									
										
										
										
											2025-01-29 14:20:03 -08:00
										 |  |  | 	@$(DOCKERPY) bash -c "python3 -m venv $(VENVDIR) && $(PIP) install --upgrade --cache-dir=$(WORKDIR)/.cache/pip pip" | 
					
						
							| 
									
										
										
										
											2023-05-18 09:06:27 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | # Install python packages into the virtual environment.
 | 
					
						
							| 
									
										
										
										
											2024-04-19 09:02:14 +02:00
										 |  |  | $(PYTOOLS)/%: $(PYTOOLS) | 
					
						
							| 
									
										
										
										
											2025-01-29 14:20:03 -08:00
										 |  |  | 	@$(DOCKERPY) $(PIP) install --cache-dir=$(WORKDIR)/.cache/pip -r requirements.txt | 
					
						
							| 
									
										
										
										
											2023-05-18 09:06:27 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | CODESPELL = $(PYTOOLS)/codespell | 
					
						
							|  |  |  | $(CODESPELL): PACKAGE=codespell | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-18 16:16:29 +02:00
										 |  |  | # Generate
 | 
					
						
							| 
									
										
										
										
											2021-03-01 08:38:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-18 16:16:29 +02:00
										 |  |  | .PHONY: generate | 
					
						
							| 
									
										
										
										
											2023-05-23 16:30:49 +02:00
										 |  |  | generate: go-generate vanity-import-fix | 
					
						
							| 
									
										
										
										
											2022-02-15 14:03:38 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-23 16:30:49 +02:00
										 |  |  | .PHONY: go-generate | 
					
						
							|  |  |  | go-generate: $(OTEL_GO_MOD_DIRS:%=go-generate/%) | 
					
						
							|  |  |  | go-generate/%: DIR=$* | 
					
						
							| 
									
										
										
										
											2024-04-19 09:02:14 +02:00
										 |  |  | go-generate/%: $(STRINGER) $(GOTMPL) | 
					
						
							| 
									
										
										
										
											2022-02-15 14:03:38 -08:00
										 |  |  | 	@echo "$(GO) generate $(DIR)/..." \
 | 
					
						
							|  |  |  | 		&& cd $(DIR) \
 | 
					
						
							| 
									
										
										
										
											2023-05-23 16:30:49 +02:00
										 |  |  | 		&& PATH="$(TOOLS):$${PATH}" $(GO) generate ./... | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .PHONY: vanity-import-fix | 
					
						
							| 
									
										
										
										
											2024-04-19 09:02:14 +02:00
										 |  |  | vanity-import-fix: $(PORTO) | 
					
						
							| 
									
										
										
										
											2023-05-23 16:30:49 +02:00
										 |  |  | 	@$(PORTO) --include-internal -w . | 
					
						
							| 
									
										
										
										
											2022-02-15 14:03:38 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-08 21:29:39 +02:00
										 |  |  | # Generate go.work file for local development.
 | 
					
						
							|  |  |  | .PHONY: go-work | 
					
						
							| 
									
										
										
										
											2024-04-19 09:02:14 +02:00
										 |  |  | go-work: $(CROSSLINK) | 
					
						
							| 
									
										
										
										
											2025-02-13 16:03:38 +01:00
										 |  |  | 	$(CROSSLINK) work --root=$(shell pwd) --go=1.22.7 | 
					
						
							| 
									
										
										
										
											2023-06-08 21:29:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-18 16:16:29 +02:00
										 |  |  | # Build
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .PHONY: build | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | build: $(OTEL_GO_MOD_DIRS:%=build/%) $(OTEL_GO_MOD_DIRS:%=build-tests/%) | 
					
						
							| 
									
										
										
										
											2022-02-15 14:03:38 -08:00
										 |  |  | build/%: DIR=$* | 
					
						
							|  |  |  | build/%: | 
					
						
							|  |  |  | 	@echo "$(GO) build $(DIR)/..." \
 | 
					
						
							|  |  |  | 		&& cd $(DIR) \
 | 
					
						
							|  |  |  | 		&& $(GO) build ./... | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | build-tests/%: DIR=$* | 
					
						
							|  |  |  | build-tests/%: | 
					
						
							|  |  |  | 	@echo "$(GO) build tests $(DIR)/..." \
 | 
					
						
							|  |  |  | 		&& cd $(DIR) \
 | 
					
						
							|  |  |  | 		&& $(GO) list ./... \
 | 
					
						
							|  |  |  | 		| grep -v third_party \
 | 
					
						
							|  |  |  | 		| xargs $(GO) test -vet=off -run xxxxxMatchNothingxxxxx >/dev/null | 
					
						
							| 
									
										
										
										
											2019-11-22 10:48:53 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-01 08:38:23 -08:00
										 |  |  | # Tests
 | 
					
						
							| 
									
										
										
										
											2019-07-02 16:21:24 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-16 16:04:50 -04:00
										 |  |  | TEST_TARGETS := test-default test-bench test-short test-verbose test-race test-concurrent-safe test-fuzz | 
					
						
							| 
									
										
										
										
											2021-03-01 08:38:23 -08:00
										 |  |  | .PHONY: $(TEST_TARGETS) test | 
					
						
							| 
									
										
										
										
											2022-02-15 14:03:38 -08:00
										 |  |  | test-default test-race: ARGS=-race | 
					
						
							| 
									
										
										
										
											2021-03-01 08:38:23 -08:00
										 |  |  | test-bench:   ARGS=-run=xxxxxMatchNothingxxxxx -test.benchtime=1ms -bench=. | 
					
						
							|  |  |  | test-short:   ARGS=-short | 
					
						
							| 
									
										
										
										
											2025-09-16 16:04:50 -04:00
										 |  |  | test-fuzz:    ARGS=-fuzztime=10s -fuzz | 
					
						
							| 
									
										
										
										
											2022-02-15 14:03:38 -08:00
										 |  |  | test-verbose: ARGS=-v -race | 
					
						
							| 
									
										
										
										
											2024-09-03 17:09:04 -07:00
										 |  |  | test-concurrent-safe: ARGS=-run=ConcurrentSafe -count=100 -race | 
					
						
							|  |  |  | test-concurrent-safe: TIMEOUT=120 | 
					
						
							| 
									
										
										
										
											2021-03-01 08:38:23 -08:00
										 |  |  | $(TEST_TARGETS): test | 
					
						
							| 
									
										
										
										
											2022-02-15 14:03:38 -08:00
										 |  |  | test: $(OTEL_GO_MOD_DIRS:%=test/%) | 
					
						
							|  |  |  | test/%: DIR=$* | 
					
						
							|  |  |  | test/%: | 
					
						
							|  |  |  | 	@echo "$(GO) test -timeout $(TIMEOUT)s $(ARGS) $(DIR)/..." \
 | 
					
						
							|  |  |  | 		&& cd $(DIR) \
 | 
					
						
							|  |  |  | 		&& $(GO) list ./... \
 | 
					
						
							|  |  |  | 		| grep -v third_party \
 | 
					
						
							|  |  |  | 		| xargs $(GO) test -timeout $(TIMEOUT)s $(ARGS) | 
					
						
							| 
									
										
										
										
											2020-09-25 13:27:03 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-01 08:38:23 -08:00
										 |  |  | COVERAGE_MODE    = atomic | 
					
						
							|  |  |  | COVERAGE_PROFILE = coverage.out | 
					
						
							|  |  |  | .PHONY: test-coverage | 
					
						
							| 
									
										
										
										
											2024-04-19 09:02:14 +02:00
										 |  |  | test-coverage: $(GOCOVMERGE) | 
					
						
							| 
									
										
										
										
											2021-03-01 08:38:23 -08:00
										 |  |  | 	@set -e; \
 | 
					
						
							|  |  |  | 	printf "" > coverage.txt; \
 | 
					
						
							|  |  |  | 	for dir in $(ALL_COVERAGE_MOD_DIRS); do \
 | 
					
						
							| 
									
										
										
										
											2021-08-14 17:10:15 +02:00
										 |  |  | 	  echo "$(GO) test -coverpkg=go.opentelemetry.io/otel/... -covermode=$(COVERAGE_MODE) -coverprofile="$(COVERAGE_PROFILE)" $${dir}/..."; \
 | 
					
						
							| 
									
										
										
										
											2021-03-01 08:38:23 -08:00
										 |  |  | 	  (cd "$${dir}" && \
 | 
					
						
							| 
									
										
										
										
											2021-03-03 18:24:57 +00:00
										 |  |  | 	    $(GO) list ./... \
 | 
					
						
							|  |  |  | 	    | grep -v third_party \
 | 
					
						
							| 
									
										
										
										
											2022-04-12 13:40:43 -07:00
										 |  |  | 	    | grep -v 'semconv/v.*' \
 | 
					
						
							| 
									
										
										
										
											2021-03-03 18:24:57 +00:00
										 |  |  | 	    | xargs $(GO) test -coverpkg=./... -covermode=$(COVERAGE_MODE) -coverprofile="$(COVERAGE_PROFILE)" && \
 | 
					
						
							|  |  |  | 	  $(GO) tool cover -html=coverage.out -o coverage.html); \
 | 
					
						
							| 
									
										
										
										
											2021-03-01 08:38:23 -08:00
										 |  |  | 	done; \
 | 
					
						
							| 
									
										
										
										
											2021-08-14 17:10:15 +02:00
										 |  |  | 	$(GOCOVMERGE) $$(find . -name coverage.out) > coverage.txt | 
					
						
							| 
									
										
										
										
											2021-03-01 08:38:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-12 12:00:18 -05:00
										 |  |  | .PHONY: benchmark | 
					
						
							| 
									
										
										
										
											2024-07-30 00:49:57 -07:00
										 |  |  | benchmark: $(OTEL_GO_MOD_DIRS:%=benchmark/%) | 
					
						
							| 
									
										
										
										
											2023-10-12 12:00:18 -05:00
										 |  |  | benchmark/%: | 
					
						
							| 
									
										
										
										
											2024-07-30 00:49:57 -07:00
										 |  |  | 	@echo "$(GO) test -run=xxxxxMatchNothingxxxxx -bench=. $*..." \
 | 
					
						
							| 
									
										
										
										
											2023-10-12 12:00:18 -05:00
										 |  |  | 		&& cd $* \
 | 
					
						
							| 
									
										
										
										
											2024-07-30 00:49:57 -07:00
										 |  |  | 		&& $(GO) list ./... \
 | 
					
						
							|  |  |  | 		| grep -v third_party \
 | 
					
						
							|  |  |  | 		| xargs $(GO) test -run=xxxxxMatchNothingxxxxx -bench=. | 
					
						
							| 
									
										
										
										
											2023-10-12 12:00:18 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-15 14:03:38 -08:00
										 |  |  | .PHONY: golangci-lint golangci-lint-fix | 
					
						
							|  |  |  | golangci-lint-fix: ARGS=--fix | 
					
						
							|  |  |  | golangci-lint-fix: golangci-lint | 
					
						
							|  |  |  | golangci-lint: $(OTEL_GO_MOD_DIRS:%=golangci-lint/%) | 
					
						
							|  |  |  | golangci-lint/%: DIR=$* | 
					
						
							| 
									
										
										
										
											2024-04-19 09:02:14 +02:00
										 |  |  | golangci-lint/%: $(GOLANGCI_LINT) | 
					
						
							| 
									
										
										
										
											2022-02-15 14:03:38 -08:00
										 |  |  | 	@echo 'golangci-lint $(if $(ARGS),$(ARGS) ,)$(DIR)' \
 | 
					
						
							|  |  |  | 		&& cd $(DIR) \
 | 
					
						
							|  |  |  | 		&& $(GOLANGCI_LINT) run --allow-serial-runners $(ARGS) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .PHONY: crosslink | 
					
						
							| 
									
										
										
										
											2024-04-19 09:02:14 +02:00
										 |  |  | crosslink: $(CROSSLINK) | 
					
						
							| 
									
										
										
										
											2022-05-06 07:40:59 -07:00
										 |  |  | 	@echo "Updating intra-repository dependencies in all go modules" \
 | 
					
						
							|  |  |  | 		&& $(CROSSLINK) --root=$(shell pwd) --prune | 
					
						
							| 
									
										
										
										
											2022-02-15 14:03:38 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | .PHONY: go-mod-tidy | 
					
						
							|  |  |  | go-mod-tidy: $(ALL_GO_MOD_DIRS:%=go-mod-tidy/%) | 
					
						
							|  |  |  | go-mod-tidy/%: DIR=$* | 
					
						
							| 
									
										
										
										
											2024-04-19 09:02:14 +02:00
										 |  |  | go-mod-tidy/%: crosslink | 
					
						
							| 
									
										
										
										
											2022-02-15 14:03:38 -08:00
										 |  |  | 	@echo "$(GO) mod tidy in $(DIR)" \
 | 
					
						
							|  |  |  | 		&& cd $(DIR) \
 | 
					
						
							| 
									
										
										
										
											2024-02-25 10:48:32 -08:00
										 |  |  | 		&& $(GO) mod tidy -compat=1.21 | 
					
						
							| 
									
										
										
										
											2022-02-15 14:03:38 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-27 11:27:41 -08:00
										 |  |  | .PHONY: lint | 
					
						
							| 
									
										
										
										
											2025-04-02 05:32:28 -04:00
										 |  |  | lint: misspell go-mod-tidy golangci-lint govulncheck | 
					
						
							| 
									
										
										
										
											2021-03-01 08:38:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-28 04:37:26 +02:00
										 |  |  | .PHONY: vanity-import-check | 
					
						
							| 
									
										
										
										
											2024-04-19 09:02:14 +02:00
										 |  |  | vanity-import-check: $(PORTO) | 
					
						
							| 
									
										
										
										
											2023-06-30 13:05:35 +02:00
										 |  |  | 	@$(PORTO) --include-internal -l . || ( echo "(run: make vanity-import-fix)"; exit 1 ) | 
					
						
							| 
									
										
										
										
											2022-04-20 11:12:02 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-01 08:38:23 -08:00
										 |  |  | .PHONY: misspell | 
					
						
							| 
									
										
										
										
											2024-04-19 09:02:14 +02:00
										 |  |  | misspell: $(MISSPELL) | 
					
						
							| 
									
										
										
										
											2022-02-15 14:03:38 -08:00
										 |  |  | 	@$(MISSPELL) -w $(ALL_DOCS) | 
					
						
							| 
									
										
										
										
											2020-03-25 14:47:17 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-10 14:13:37 +05:30
										 |  |  | .PHONY: govulncheck | 
					
						
							|  |  |  | govulncheck: $(OTEL_GO_MOD_DIRS:%=govulncheck/%) | 
					
						
							|  |  |  | govulncheck/%: DIR=$* | 
					
						
							| 
									
										
										
										
											2024-04-19 09:02:14 +02:00
										 |  |  | govulncheck/%: $(GOVULNCHECK) | 
					
						
							| 
									
										
										
										
											2023-10-10 14:13:37 +05:30
										 |  |  | 	@echo "govulncheck ./... in $(DIR)" \
 | 
					
						
							|  |  |  | 		&& cd $(DIR) \
 | 
					
						
							|  |  |  | 		&& $(GOVULNCHECK) ./... | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-18 09:06:27 -07:00
										 |  |  | .PHONY: codespell | 
					
						
							| 
									
										
										
										
											2024-04-19 09:02:14 +02:00
										 |  |  | codespell: $(CODESPELL) | 
					
						
							| 
									
										
										
										
											2023-05-18 09:06:27 -07:00
										 |  |  | 	@$(DOCKERPY) $(CODESPELL) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-18 02:33:55 -07:00
										 |  |  | .PHONY: toolchain-check | 
					
						
							|  |  |  | toolchain-check: | 
					
						
							|  |  |  | 	@toolchainRes=$$(for f in $(ALL_GO_MOD_DIRS); do \
 | 
					
						
							|  |  |  | 	           awk '/^toolchain/ { found=1; next } END { if (found) print FILENAME }' $$f/go.mod; \
 | 
					
						
							|  |  |  | 	done); \
 | 
					
						
							|  |  |  | 	if [ -n "$${toolchainRes}" ]; then \
 | 
					
						
							|  |  |  | 			echo "toolchain checking failed:"; echo "$${toolchainRes}"; \
 | 
					
						
							|  |  |  | 			exit 1; \
 | 
					
						
							|  |  |  | 	fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-25 14:47:17 -07:00
										 |  |  | .PHONY: license-check | 
					
						
							|  |  |  | license-check: | 
					
						
							| 
									
										
										
										
											2022-04-29 08:22:10 -07:00
										 |  |  | 	@licRes=$$(for f in $$(find . -type f \( -iname '*.go' -o -iname '*.sh' \) ! -path '**/third_party/*' ! -path './.git/*' ) ; do \
 | 
					
						
							| 
									
										
										
										
											2023-08-02 12:28:35 -07:00
										 |  |  | 	           awk '/Copyright The OpenTelemetry Authors|generated|GENERATED/ && NR<=4 { found=1; next } END { if (!found) print FILENAME }' $$f; \
 | 
					
						
							| 
									
										
										
										
											2020-03-25 14:47:17 -07:00
										 |  |  | 	   done); \
 | 
					
						
							|  |  |  | 	   if [ -n "$${licRes}" ]; then \
 | 
					
						
							|  |  |  | 	           echo "license header checking failed:"; echo "$${licRes}"; \
 | 
					
						
							|  |  |  | 	           exit 1; \
 | 
					
						
							|  |  |  | 	   fi | 
					
						
							| 
									
										
										
										
											2020-08-26 16:34:41 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-01 08:38:23 -08:00
										 |  |  | .PHONY: check-clean-work-tree | 
					
						
							|  |  |  | check-clean-work-tree: | 
					
						
							|  |  |  | 	@if ! git diff --quiet; then \
 | 
					
						
							|  |  |  | 	  echo; \
 | 
					
						
							|  |  |  | 	  echo 'Working tree is not clean, did you forget to run "make precommit"?'; \
 | 
					
						
							|  |  |  | 	  echo; \
 | 
					
						
							|  |  |  | 	  git status; \
 | 
					
						
							|  |  |  | 	  exit 1; \
 | 
					
						
							|  |  |  | 	fi | 
					
						
							| 
									
										
										
										
											2021-10-01 16:20:32 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-31 06:51:07 -08:00
										 |  |  | # The weaver docker image to use for semconv-generate.
 | 
					
						
							|  |  |  | WEAVER_IMAGE := $(shell awk '$$4=="weaver" {print $$2}' $(DEPENDENCIES_DOCKERFILE)) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-12 13:40:43 -07:00
										 |  |  | SEMCONVPKG ?= "semconv/" | 
					
						
							|  |  |  | .PHONY: semconv-generate | 
					
						
							| 
									
										
										
										
											2025-01-31 06:51:07 -08:00
										 |  |  | semconv-generate: $(SEMCONVKIT) | 
					
						
							| 
									
										
										
										
											2023-07-26 17:09:04 +02:00
										 |  |  | 	[ "$(TAG)" ] || ( echo "TAG unset: missing opentelemetry semantic-conventions tag"; exit 1 ) | 
					
						
							| 
									
										
										
										
											2025-01-31 06:51:07 -08:00
										 |  |  | 	# Ensure the target directory for source code is available. | 
					
						
							|  |  |  | 	mkdir -p $(PWD)/$(SEMCONVPKG)/${TAG} | 
					
						
							|  |  |  | 	# Note: We mount a home directory for downloading/storing the semconv repository. | 
					
						
							|  |  |  | 	# Weaver will automatically clean the cache when finished, but the directories will remain. | 
					
						
							|  |  |  | 	mkdir -p ~/.weaver | 
					
						
							|  |  |  | 	docker run --rm \
 | 
					
						
							|  |  |  | 		-u $(DOCKER_USER) \
 | 
					
						
							|  |  |  | 		--env HOME=/tmp/weaver \
 | 
					
						
							| 
									
										
										
										
											2025-07-14 16:24:33 +02:00
										 |  |  | 		--mount 'type=bind,source=$(PWD)/semconv/templates,target=/home/weaver/templates,readonly' \
 | 
					
						
							| 
									
										
										
										
											2025-01-31 06:51:07 -08:00
										 |  |  | 		--mount 'type=bind,source=$(PWD)/semconv/${TAG},target=/home/weaver/target' \
 | 
					
						
							|  |  |  | 		--mount 'type=bind,source=$(HOME)/.weaver,target=/tmp/weaver/.weaver' \
 | 
					
						
							|  |  |  | 		$(WEAVER_IMAGE) registry generate \
 | 
					
						
							| 
									
										
										
										
											2025-02-03 07:57:01 -08:00
										 |  |  | 		--registry=https://github.com/open-telemetry/semantic-conventions/archive/refs/tags/$(TAG).zip[model] \
 | 
					
						
							| 
									
										
										
										
											2025-01-31 06:51:07 -08:00
										 |  |  | 		--templates=/home/weaver/templates \
 | 
					
						
							|  |  |  | 		--param tag=$(TAG) \
 | 
					
						
							|  |  |  | 		go \
 | 
					
						
							|  |  |  | 		/home/weaver/target | 
					
						
							| 
									
										
										
										
											2025-05-28 08:25:12 -07:00
										 |  |  | 	$(SEMCONVKIT) -semconv "$(SEMCONVPKG)" -tag "$(TAG)" | 
					
						
							| 
									
										
										
										
											2022-04-12 13:40:43 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-14 16:42:08 +02:00
										 |  |  | .PHONY: gorelease | 
					
						
							|  |  |  | gorelease: $(OTEL_GO_MOD_DIRS:%=gorelease/%) | 
					
						
							|  |  |  | gorelease/%: DIR=$* | 
					
						
							|  |  |  | gorelease/%:| $(GORELEASE) | 
					
						
							|  |  |  | 	@echo "gorelease in $(DIR):" \
 | 
					
						
							|  |  |  | 		&& cd $(DIR) \
 | 
					
						
							|  |  |  | 		&& $(GORELEASE) \
 | 
					
						
							|  |  |  | 		|| echo "" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-06-24 07:58:21 -07:00
										 |  |  | .PHONY: verify-mods | 
					
						
							|  |  |  | verify-mods: $(MULTIMOD) | 
					
						
							|  |  |  | 	$(MULTIMOD) verify | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-01 16:20:32 -04:00
										 |  |  | .PHONY: prerelease | 
					
						
							| 
									
										
										
										
											2024-06-24 07:58:21 -07:00
										 |  |  | prerelease: verify-mods | 
					
						
							| 
									
										
										
										
											2021-10-01 16:20:32 -04:00
										 |  |  | 	@[ "${MODSET}" ] || ( echo ">> env var MODSET is not set"; exit 1 ) | 
					
						
							| 
									
										
										
										
											2024-06-24 07:58:21 -07:00
										 |  |  | 	$(MULTIMOD) prerelease -m ${MODSET} | 
					
						
							| 
									
										
										
										
											2021-10-01 16:20:32 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | COMMIT ?= "HEAD" | 
					
						
							|  |  |  | .PHONY: add-tags | 
					
						
							| 
									
										
										
										
											2024-06-24 07:58:21 -07:00
										 |  |  | add-tags: verify-mods | 
					
						
							| 
									
										
										
										
											2021-10-01 16:20:32 -04:00
										 |  |  | 	@[ "${MODSET}" ] || ( echo ">> env var MODSET is not set"; exit 1 ) | 
					
						
							| 
									
										
										
										
											2024-06-24 07:58:21 -07:00
										 |  |  | 	$(MULTIMOD) tag -m ${MODSET} -c ${COMMIT} | 
					
						
							| 
									
										
										
										
											2023-11-02 13:30:56 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-02 05:25:24 -04:00
										 |  |  | MARKDOWNIMAGE := $(shell awk '$$4=="markdown" {print $$2}' $(DEPENDENCIES_DOCKERFILE)) | 
					
						
							| 
									
										
										
										
											2023-11-02 13:30:56 -05:00
										 |  |  | .PHONY: lint-markdown | 
					
						
							| 
									
										
										
										
											2024-04-04 14:04:18 -07:00
										 |  |  | lint-markdown: | 
					
						
							| 
									
										
										
										
											2025-04-02 05:25:24 -04:00
										 |  |  | 	docker run --rm -u $(DOCKER_USER) -v "$(CURDIR):$(WORKDIR)" $(MARKDOWNIMAGE) -c $(WORKDIR)/.markdownlint.yaml $(WORKDIR)/**/*.md | 
					
						
							| 
									
										
										
										
											2024-03-26 20:13:54 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | .PHONY: verify-readmes | 
					
						
							| 
									
										
										
										
											2025-04-15 11:01:30 +02:00
										 |  |  | verify-readmes: $(VERIFYREADMES) | 
					
						
							|  |  |  | 	$(VERIFYREADMES) |