mirror of
https://github.com/SigNoz/signoz.git
synced 2026-08-06 05:00:42 +01:00
* perf(tests): cache go and pnpm stores across integration image builds Add BuildKit cache mounts for GOCACHE/GOMODCACHE and the pnpm store to the integration Dockerfiles, and build the image via the docker CLI (docker-py, used by testcontainers' DockerImage, does not support BuildKit). Embed the go build command directly so Makefile changes do not invalidate the build layer, and pin HOME/GOCACHE/GOMODCACHE/PNPM_HOME explicitly so cache-mount targets match tool defaults by contract. The with-web node stage fetches dependencies from the lockfile before the source copy, so frontend edits only re-run the offline install and build. * feat(tests): add --clean flag to prune buildkit cache mounts The go and pnpm caches introduced for the integration image build survive --teardown since they belong to the docker builder, not to any container. --clean runs docker builder prune with a type=exec.cachemount filter at session start, forcing the next image build to start cold. Documented in the integration testing guide. * feat(tests): add --rebuild flag to refresh the signoz container under --reuse --reuse keeps the running signoz container, so backend source changes are never picked up without tearing down the whole stack. --rebuild deletes the cached signoz container and recreates it from the current sources (an incremental image build), while databases, mocks and migrations stay reused. Requires --reuse; combining with --teardown or --clean is a usage error. * chore(tests): prune comments to non-obvious constraints * docs(tests): make py-test-setup rebuild signoz and audit the integration guide py-test-setup now passes --rebuild so re-running it after backend changes transparently swaps in a signoz container built from the current sources. The integration guide documents the iteration loop and fixes stale content: option defaults (clickhouse 25.12.5, schema migrator v0.144.6), the nonexistent --zookeeper-version option, Zookeeper vs ClickHouse Keeper, the e2e doc path, and the lint toolchain (ruff). * docs(tests): wire --rebuild into the e2e setup flow The e2e bootstrap shares the signoz fixture, so --rebuild already applies; with --with-web it also picks up frontend changes since the image bakes the built frontend in. The setup command now passes --rebuild, and the guide documents the iteration loop, the --rebuild/--clean flags, ClickHouse Keeper instead of Zookeeper, and the corrected integration doc path. * docs(tests): qualify --rebuild workflow for suites with custom signoz variants make py-test-setup only rebuilds the default signoz instance; suites that create their own via create_signoz(cache_key=...) keep a separately cached container. Passing --rebuild on the suite run itself rebuilds every variant that run instantiates. * docs(tests): describe --clean behaviour instead of its exact command Keeps the docs from drifting if the prune invocation behind --clean changes.
240 lines
11 KiB
Makefile
240 lines
11 KiB
Makefile
##############################################################
|
|
# variables
|
|
##############################################################
|
|
SHELL := /bin/bash
|
|
SRC ?= $(shell pwd)
|
|
NAME ?= signoz
|
|
OS ?= $(shell uname -s | tr '[A-Z]' '[a-z]')
|
|
ARCH ?= $(shell uname -m | sed 's/x86_64/amd64/g' | sed 's/aarch64/arm64/g')
|
|
COMMIT_SHORT_SHA ?= $(shell git rev-parse --short HEAD)
|
|
BRANCH_NAME ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD))
|
|
VERSION ?= $(BRANCH_NAME)-$(COMMIT_SHORT_SHA)
|
|
TIMESTAMP ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
|
|
ARCHS ?= amd64 arm64
|
|
TARGET_DIR ?= $(shell pwd)/target
|
|
|
|
ZEUS_URL ?= https://api.signoz.cloud
|
|
GO_BUILD_LDFLAG_ZEUS_URL = -X github.com/SigNoz/signoz/ee/zeus.url=$(ZEUS_URL)
|
|
LICENSE_URL ?= https://license.signoz.io
|
|
GO_BUILD_LDFLAG_LICENSE_SIGNOZ_IO = -X github.com/SigNoz/signoz/ee/zeus.deprecatedURL=$(LICENSE_URL)
|
|
|
|
GO_BUILD_VERSION_LDFLAGS = -X github.com/SigNoz/signoz/pkg/version.version=$(VERSION) -X github.com/SigNoz/signoz/pkg/version.hash=$(COMMIT_SHORT_SHA) -X github.com/SigNoz/signoz/pkg/version.time=$(TIMESTAMP) -X github.com/SigNoz/signoz/pkg/version.branch=$(BRANCH_NAME)
|
|
GO_BUILD_ARCHS_COMMUNITY = $(addprefix go-build-community-,$(ARCHS))
|
|
GO_BUILD_CONTEXT_COMMUNITY = $(SRC)/cmd/community
|
|
GO_BUILD_LDFLAGS_COMMUNITY = $(GO_BUILD_VERSION_LDFLAGS) -X github.com/SigNoz/signoz/pkg/version.variant=community
|
|
GO_BUILD_ARCHS_ENTERPRISE = $(addprefix go-build-enterprise-,$(ARCHS))
|
|
GO_BUILD_ARCHS_ENTERPRISE_RACE = $(addprefix go-build-enterprise-race-,$(ARCHS))
|
|
GO_BUILD_CONTEXT_ENTERPRISE = $(SRC)/cmd/enterprise
|
|
GO_BUILD_LDFLAGS_ENTERPRISE = $(GO_BUILD_VERSION_LDFLAGS) -X github.com/SigNoz/signoz/pkg/version.variant=enterprise $(GO_BUILD_LDFLAG_ZEUS_URL) $(GO_BUILD_LDFLAG_LICENSE_SIGNOZ_IO)
|
|
|
|
DOCKER_BUILD_ARCHS_COMMUNITY = $(addprefix docker-build-community-,$(ARCHS))
|
|
DOCKERFILE_COMMUNITY = $(SRC)/cmd/community/Dockerfile
|
|
DOCKER_REGISTRY_COMMUNITY ?= docker.io/signoz/signoz-community
|
|
DOCKER_BUILD_ARCHS_ENTERPRISE = $(addprefix docker-build-enterprise-,$(ARCHS))
|
|
DOCKERFILE_ENTERPRISE = $(SRC)/cmd/enterprise/Dockerfile
|
|
DOCKER_REGISTRY_ENTERPRISE ?= docker.io/signoz/signoz
|
|
JS_BUILD_CONTEXT = $(SRC)/frontend
|
|
|
|
##############################################################
|
|
# directories
|
|
##############################################################
|
|
$(TARGET_DIR):
|
|
mkdir -p $(TARGET_DIR)
|
|
|
|
##############################################################
|
|
# common commands
|
|
##############################################################
|
|
.PHONY: help
|
|
help: ## Displays help.
|
|
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} /^[a-z0-9A-Z_-]+:.*?##/ { printf " \033[36m%-40s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
|
|
|
|
##############################################################
|
|
# devenv commands
|
|
##############################################################
|
|
.PHONY: devenv-clickhouse
|
|
devenv-clickhouse: ## Run clickhouse in devenv
|
|
@cd .devenv/docker/clickhouse; \
|
|
docker compose -f compose.yaml up -d
|
|
|
|
.PHONY: devenv-postgres
|
|
devenv-postgres: ## Run postgres in devenv
|
|
@cd .devenv/docker/postgres; \
|
|
docker compose -f compose.yaml up -d
|
|
|
|
.PHONY: devenv-signoz-otel-collector
|
|
devenv-signoz-otel-collector: ## Run signoz-otel-collector in devenv (requires clickhouse to be running)
|
|
@cd .devenv/docker/signoz-otel-collector; \
|
|
docker compose -f compose.yaml up -d
|
|
|
|
.PHONY: devenv-up
|
|
devenv-up: devenv-clickhouse devenv-signoz-otel-collector ## Start both clickhouse and signoz-otel-collector for local development
|
|
@echo "Development environment is ready!"
|
|
@echo " - ClickHouse: http://localhost:8123"
|
|
@echo " - Signoz OTel Collector: grpc://localhost:4317, http://localhost:4318"
|
|
|
|
.PHONY: devenv-clickhouse-clean
|
|
devenv-clickhouse-clean: ## Clean all ClickHouse data from filesystem
|
|
@echo "Removing ClickHouse data..."
|
|
@rm -rf .devenv/docker/clickhouse/fs/tmp/*
|
|
@echo "ClickHouse data cleaned!"
|
|
|
|
##############################################################
|
|
# go commands
|
|
##############################################################
|
|
.PHONY: go-run-enterprise
|
|
go-run-enterprise: ## Runs the enterprise go backend server
|
|
@SIGNOZ_INSTRUMENTATION_LOGS_LEVEL=debug \
|
|
SIGNOZ_SQLSTORE_SQLITE_PATH=signoz.db \
|
|
SIGNOZ_WEB_ENABLED=false \
|
|
SIGNOZ_TOKENIZER_JWT_SECRET=secret \
|
|
SIGNOZ_ALERTMANAGER_PROVIDER=signoz \
|
|
SIGNOZ_TELEMETRYSTORE_PROVIDER=clickhouse \
|
|
SIGNOZ_TELEMETRYSTORE_CLICKHOUSE_DSN=tcp://127.0.0.1:9000 \
|
|
SIGNOZ_TELEMETRYSTORE_CLICKHOUSE_CLUSTER=cluster \
|
|
go run -race \
|
|
$(GO_BUILD_CONTEXT_ENTERPRISE)/*.go server
|
|
|
|
.PHONY: go-test
|
|
go-test: ## Runs go unit tests
|
|
@go test -race ./...
|
|
|
|
.PHONY: go-run-community
|
|
go-run-community: ## Runs the community go backend server
|
|
@SIGNOZ_INSTRUMENTATION_LOGS_LEVEL=debug \
|
|
SIGNOZ_SQLSTORE_SQLITE_PATH=signoz.db \
|
|
SIGNOZ_WEB_ENABLED=false \
|
|
SIGNOZ_TOKENIZER_JWT_SECRET=secret \
|
|
SIGNOZ_ALERTMANAGER_PROVIDER=signoz \
|
|
SIGNOZ_TELEMETRYSTORE_PROVIDER=clickhouse \
|
|
SIGNOZ_TELEMETRYSTORE_CLICKHOUSE_DSN=tcp://127.0.0.1:9000 \
|
|
SIGNOZ_TELEMETRYSTORE_CLICKHOUSE_CLUSTER=cluster \
|
|
go run -race \
|
|
$(GO_BUILD_CONTEXT_COMMUNITY)/*.go server
|
|
|
|
.PHONY: go-build-community $(GO_BUILD_ARCHS_COMMUNITY)
|
|
go-build-community: ## Builds the go backend server for community
|
|
go-build-community: $(GO_BUILD_ARCHS_COMMUNITY)
|
|
$(GO_BUILD_ARCHS_COMMUNITY): go-build-community-%: $(TARGET_DIR)
|
|
@mkdir -p $(TARGET_DIR)/$(OS)-$*
|
|
@echo ">> building binary $(TARGET_DIR)/$(OS)-$*/$(NAME)-community"
|
|
@if [ $* = "arm64" ]; then \
|
|
GOARCH=$* GOOS=$(OS) go build -C $(GO_BUILD_CONTEXT_COMMUNITY) -tags timetzdata -o $(TARGET_DIR)/$(OS)-$*/$(NAME)-community -ldflags "-s -w $(GO_BUILD_LDFLAGS_COMMUNITY)"; \
|
|
else \
|
|
GOARCH=$* GOOS=$(OS) go build -C $(GO_BUILD_CONTEXT_COMMUNITY) -tags timetzdata -o $(TARGET_DIR)/$(OS)-$*/$(NAME)-community -ldflags "-s -w $(GO_BUILD_LDFLAGS_COMMUNITY)"; \
|
|
fi
|
|
|
|
|
|
.PHONY: go-build-enterprise $(GO_BUILD_ARCHS_ENTERPRISE)
|
|
go-build-enterprise: ## Builds the go backend server for enterprise
|
|
go-build-enterprise: $(GO_BUILD_ARCHS_ENTERPRISE)
|
|
$(GO_BUILD_ARCHS_ENTERPRISE): go-build-enterprise-%: $(TARGET_DIR)
|
|
@mkdir -p $(TARGET_DIR)/$(OS)-$*
|
|
@echo ">> building binary $(TARGET_DIR)/$(OS)-$*/$(NAME)"
|
|
@if [ $* = "arm64" ]; then \
|
|
GOARCH=$* GOOS=$(OS) go build -C $(GO_BUILD_CONTEXT_ENTERPRISE) -tags timetzdata -o $(TARGET_DIR)/$(OS)-$*/$(NAME) -ldflags "-s -w $(GO_BUILD_LDFLAGS_ENTERPRISE)"; \
|
|
else \
|
|
GOARCH=$* GOOS=$(OS) go build -C $(GO_BUILD_CONTEXT_ENTERPRISE) -tags timetzdata -o $(TARGET_DIR)/$(OS)-$*/$(NAME) -ldflags "-s -w $(GO_BUILD_LDFLAGS_ENTERPRISE)"; \
|
|
fi
|
|
|
|
.PHONY: go-build-enterprise-race $(GO_BUILD_ARCHS_ENTERPRISE_RACE)
|
|
go-build-enterprise-race: ## Builds the go backend server for enterprise with race
|
|
go-build-enterprise-race: $(GO_BUILD_ARCHS_ENTERPRISE_RACE)
|
|
$(GO_BUILD_ARCHS_ENTERPRISE_RACE): go-build-enterprise-race-%: $(TARGET_DIR)
|
|
@mkdir -p $(TARGET_DIR)/$(OS)-$*
|
|
@echo ">> building binary $(TARGET_DIR)/$(OS)-$*/$(NAME)"
|
|
@if [ $* = "arm64" ]; then \
|
|
GOARCH=$* GOOS=$(OS) go build -C $(GO_BUILD_CONTEXT_ENTERPRISE) -race -tags timetzdata -o $(TARGET_DIR)/$(OS)-$*/$(NAME) -ldflags "-s -w $(GO_BUILD_LDFLAGS_ENTERPRISE)"; \
|
|
else \
|
|
GOARCH=$* GOOS=$(OS) go build -C $(GO_BUILD_CONTEXT_ENTERPRISE) -race -tags timetzdata -o $(TARGET_DIR)/$(OS)-$*/$(NAME) -ldflags "-s -w $(GO_BUILD_LDFLAGS_ENTERPRISE)"; \
|
|
fi
|
|
|
|
##############################################################
|
|
# js commands
|
|
##############################################################
|
|
.PHONY: js-build
|
|
js-build: ## Builds the js frontend
|
|
@echo ">> building js frontend"
|
|
@cd $(JS_BUILD_CONTEXT) && CI=1 pnpm install && pnpm build
|
|
|
|
##############################################################
|
|
# docker commands
|
|
##############################################################
|
|
.PHONY: docker-build-community $(DOCKER_BUILD_ARCHS_COMMUNITY)
|
|
docker-build-community: ## Builds the docker image for community
|
|
docker-build-community: $(DOCKER_BUILD_ARCHS_COMMUNITY)
|
|
$(DOCKER_BUILD_ARCHS_COMMUNITY): docker-build-community-%: go-build-community-% js-build
|
|
@echo ">> building docker image for $(NAME)-community"
|
|
@docker build -t "$(DOCKER_REGISTRY_COMMUNITY):$(VERSION)-$*" \
|
|
--build-arg TARGETARCH="$*" \
|
|
-f $(DOCKERFILE_COMMUNITY) $(SRC)
|
|
|
|
.PHONY: docker-buildx-community
|
|
docker-buildx-community: ## Builds the docker image for community using buildx
|
|
docker-buildx-community: go-build-community js-build
|
|
@echo ">> building docker image for $(NAME)-community"
|
|
@docker buildx build --file $(DOCKERFILE_COMMUNITY) \
|
|
--progress plain \
|
|
--platform linux/arm64,linux/amd64 \
|
|
--push \
|
|
--tag $(DOCKER_REGISTRY_COMMUNITY):$(VERSION) $(SRC)
|
|
|
|
.PHONY: docker-build-enterprise $(DOCKER_BUILD_ARCHS_ENTERPRISE)
|
|
docker-build-enterprise: ## Builds the docker image for enterprise
|
|
docker-build-enterprise: $(DOCKER_BUILD_ARCHS_ENTERPRISE)
|
|
$(DOCKER_BUILD_ARCHS_ENTERPRISE): docker-build-enterprise-%: go-build-enterprise-% js-build
|
|
@echo ">> building docker image for $(NAME)"
|
|
@docker build -t "$(DOCKER_REGISTRY_ENTERPRISE):$(VERSION)-$*" \
|
|
--build-arg TARGETARCH="$*" \
|
|
-f $(DOCKERFILE_ENTERPRISE) $(SRC)
|
|
|
|
.PHONY: docker-buildx-enterprise
|
|
docker-buildx-enterprise: ## Builds the docker image for enterprise using buildx
|
|
docker-buildx-enterprise: go-build-enterprise js-build
|
|
@echo ">> building docker image for $(NAME)"
|
|
@docker buildx build --file $(DOCKERFILE_ENTERPRISE) \
|
|
--progress plain \
|
|
--platform linux/arm64,linux/amd64 \
|
|
--push \
|
|
--tag $(DOCKER_REGISTRY_ENTERPRISE):$(VERSION) $(SRC)
|
|
|
|
##############################################################
|
|
# python commands
|
|
##############################################################
|
|
.PHONY: py-fmt
|
|
py-fmt: ## Run ruff format across the shared tests project
|
|
@cd tests && uv run ruff format .
|
|
|
|
.PHONY: py-lint
|
|
py-lint: ## Run ruff check across the shared tests project
|
|
@cd tests && uv run ruff check --fix .
|
|
|
|
.PHONY: py-test-setup
|
|
py-test-setup: ## Bring up the shared SigNoz backend used by integration and e2e tests, rebuilding signoz from the current sources
|
|
@cd tests && uv run pytest --basetemp=./tmp/ -vv --reuse --rebuild --capture=no integration/bootstrap/setup.py::test_setup
|
|
|
|
.PHONY: py-test-teardown
|
|
py-test-teardown: ## Tear down the shared SigNoz backend
|
|
@cd tests && uv run pytest --basetemp=./tmp/ -vv --teardown --capture=no integration/bootstrap/setup.py::test_teardown
|
|
|
|
.PHONY: py-test
|
|
py-test: ## Runs integration tests
|
|
@cd tests && uv run pytest --basetemp=./tmp/ -vv --capture=no integration/tests/
|
|
|
|
.PHONY: py-clean
|
|
py-clean: ## Clear all pycache and pytest cache from tests directory recursively
|
|
@echo ">> cleaning python cache files from tests directory"
|
|
@find tests -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
|
|
@find tests -type d -name .pytest_cache -exec rm -rf {} + 2>/dev/null || true
|
|
@find tests -type f -name "*.pyc" -delete 2>/dev/null || true
|
|
@find tests -type f -name "*.pyo" -delete 2>/dev/null || true
|
|
@echo ">> python cache cleaned"
|
|
|
|
|
|
##############################################################
|
|
# generate commands
|
|
##############################################################
|
|
.PHONY: gen-mocks
|
|
gen-mocks:
|
|
@echo ">> Generating mocks"
|
|
@mockery --config .mockery.yml
|