-
Notifications
You must be signed in to change notification settings - Fork 319
Expand file tree
/
Copy pathMakefile
More file actions
123 lines (105 loc) · 3.16 KB
/
Copy pathMakefile
File metadata and controls
123 lines (105 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#
# Copyright 2025 New Relic Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
#
# The top level Makefile
#
SHELL = /bin/bash
GIT ?= git
# Default go invocation command
GO := go
# module path
GO_MODULE := github.com/newrelic/go-agent/v3/newrelic
BASEDIR := $(PWD)
MODULE_DIR:= ./v3
BENCHTIME := 1ms
# Include the secrets file if it exists, but if it doesn't, that's OK too.
-include secrets.mk
# Include the manifests for the integration and core tests
include integration-tests.mk
include core-tests.mk
# Test targets
.PHONY: tidy
tidy:
@cd $(MODULE_DIR); $(GO) mod edit -replace github.com/newrelic/go-agent/v3="$(BASEDIR)/$(MODULE_DIR)"; $(GO) mod tidy
.PHONY: core-test
core-test:
@echo; echo "# TEST=$(TEST), COVERAGE=$(COVERAGE)"; \
cd $(MODULE_DIR)/$(TEST); \
$(GO) mod edit -replace github.com/newrelic/go-agent/v3="$(BASEDIR)/$(MODULE_DIR)"; \
$(GO) mod tidy; \
if [ "$(COVERAGE)" == "1" ]; then \
$(GO) test -coverprofile=coverage.txt || exit 1; \
else \
$(GO) test || exit 1; \
fi; \
echo "# TEST=$(TEST)"; \
cd $(BASEDIR);
.PHONY: core-suite
core-suite:
@for TEST in $(GO_CORE_TESTS); do \
$(MAKE) core-test TEST=$${TEST} COVERAGE=$(COVERAGE); \
done
.PHONY: integration-test
integration-test:
@echo; echo "# TEST=$(TEST), COVERAGE=$(COVERAGE)"; \
cd $(MODULE_DIR)/integrations/$(TEST); \
WD=$(shell pwd); \
$(GO) mod edit -replace github.com/newrelic/go-agent/v3="$${WD}/${MODULE_DIR}";\
$(GO) mod tidy; \
if [ "$(COVERAGE)" == "1" ]; then \
$(GO) test -coverprofile=coverage.txt -race -benchtime=$(BENCHTIME) -bench=. ./ || exit 1; \
else \
$(GO) test -race -benchtime=$(BENCHTIME) -bench=. ./ || exit 1; \
fi; \
$(GO) vet ./... || exit 1; \
echo "# TEST=$(TEST)"; \
cd $(BASEDIR);
.PHONY: integration-suite
integration-suite:
@for TEST in $(GO_INTEGRATION_TESTS); do \
$(MAKE) integration-test TEST=$${TEST} COVERAGE=$(COVERAGE); \
done
test-services-start:
@if [ ! -z $(PROFILE) ]; then \
docker compose --profile test --profile $(PROFILE) pull $(SERVICES); \
docker compose --profile test --profile $(PROFILE) up --wait --remove-orphans -d $(SERVICES); \
else \
docker compose --profile test pull $(SERVICES); \
docker compose --profile test up --wait --remove-orphans -d $(SERVICES); \
fi;
test-services-stop:
@if [ ! -z $(PROFILE) ]; then \
docker compose --profile test --profile $(PROFILE) stop; \
else \
docker compose --profile test stop; \
fi;
# Developer targets
devenv-image:
@docker compose --profile dev build devenv
dev-shell: devenv-image
docker compose --profile dev up --pull missing --remove-orphans -d
docker compose exec -it devenv bash -c "bash"
dev-stop:
docker compose --profile dev stop
# Utility targets
.PHONY: integration-to-json
integration-to-json:
@TESTS="$(shell echo $(GO_INTEGRATION_TESTS))"; \
echo $$TESTS | jq -R 'split(" ")' | sed "s/ //g" | tr -d '\n';
.PHONY: core-to-json
core-to-json:
@TESTS="$(shell echo $(GO_CORE_TESTS))"; \
echo $$TESTS | jq -R 'split(" ")' | sed "s/ //g" | tr -d '\n';
.PHONY: info
info:
@echo
@echo "$$(go version)"
@echo
@echo "Integration Tests:"
@echo $(GO_INTEGRATION_TESTS)
@echo
@echo "Core Tests:"
@echo $(GO_CORE_TESTS)
@echo