-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
156 lines (140 loc) · 5.47 KB
/
Copy pathMakefile
File metadata and controls
156 lines (140 loc) · 5.47 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
.PHONY: build cover test test-integration bench lint proto gazelle clean clean-proto run-server run-client-get-graph run-client-changed-targets version help
# Bazel wrapper
BAZEL = ./tools/bazel
# Build everything in the project using Bazel
build:
@echo "Building all targets with Bazel..."
@$(BAZEL) build //...
@echo "Build complete!"
# Run all tests using Bazel
test:
@echo "Running all tests..."
@$(BAZEL) test //...
@echo "All tests passed!"
# Run integration tests (requires bazel; may take several minutes)
test-integration:
@echo "Running integration tests..."
@$(BAZEL) test //integration:integration_test --test_output=errors --test_env=TANGO_REPO_REMOTE=$$(git rev-parse --show-toplevel) --test_env=HOME=$$HOME
@echo "Integration tests passed!"
# Run GetChangedTargets benchmarks against fixed, checked-in commit pairs.
# Measurement only: not part of `make test` / `make test-integration` and not
# run in CI, so a slow benchmark never fails the build.
bench:
@echo "Running benchmarks..."
@$(BAZEL) test //integration:integration_test \
--test_output=all \
--test_arg=-test.run=^$$ \
--test_arg=-test.bench=. \
--test_arg=-test.benchtime=15x \
--test_env=TANGO_REPO_REMOTE=$$(git rev-parse --show-toplevel) \
--test_env=HOME=$$HOME
@echo "Benchmarks complete!"
lint: ## Run golangci-lint
@echo "Running golangci-lint..."
@golangci-lint run ./...
@echo "Lint passed!"
# Generate protobuf files using protoc
proto:
@echo "Generating protobuf files with protoc..."
@protoc --gogoslick_out=tangopb \
--yarpc-go_out=tangopb --yarpc-go_opt=paths=source_relative \
--proto_path=proto proto/tango.proto
@echo "Protobuf files generated successfully!"
# Generate/update BUILD.bazel files using Gazelle
gazelle:
@echo "Running Gazelle to update BUILD files..."
@$(BAZEL) run //:gazelle
@echo "BUILD files updated!"
# Run tests with coverage and generate cover.out
cover: ## Run tests with coverage
@echo "Running tests with coverage..."
@$(BAZEL) coverage --combined_report=lcov //...
@rm -f cover.out
@cp bazel-out/_coverage/_coverage_report.dat cover.out
@echo "Coverage report written to cover.out"
# Clean generated files and binaries
clean:
@echo "Cleaning with Bazel..."
@$(BAZEL) clean
@echo "Clean complete!"
# Clean generated proto files (normally not needed as they are checked in)
clean-proto:
@echo "Cleaning generated proto files..."
@rm -rf tangopb/*.pb.go
@echo "Proto clean complete!"
# Run the Tango server
run-server:
@echo "Running Tango server on port 8081..."
@$(BAZEL) run //example:example
# Run get-target-graph via the Tango client
run-client-get-graph:
@$(BAZEL) run //example/client:client -- \
-addr $(or $(SERVER_ADDR),127.0.0.1:8081) \
-method $(or $(METHOD),get-target-graph) \
-remote "$(or $(REMOTE),)" \
-base-sha "$(or $(BASE_SHA),)" \
-request-urls "$(or $(REQUEST_URLS),)" \
-include-hashes=$(or $(INCLUDE_HASHES),false) \
-include-tags=$(or $(INCLUDE_TAGS),false) \
-include-attributes=$(or $(INCLUDE_ATTRIBUTES),false)
# Run get-changed-targets via the Tango client
run-client-changed-targets:
@$(BAZEL) run //example/client:client -- \
-addr $(or $(SERVER_ADDR),127.0.0.1:8081) \
-method get-changed-targets \
-remote "$(or $(REMOTE),)" \
-base-sha "$(or $(BASE_SHA),)" \
-request-urls "$(or $(REQUEST_URLS),)" \
-new-base-sha "$(or $(NEW_BASE_SHA),)" \
-new-request-urls "$(or $(NEW_REQUEST_URLS),)" \
-include-hashes=$(or $(INCLUDE_HASHES),false) \
-include-tags=$(or $(INCLUDE_TAGS),false) \
-include-attributes=$(or $(INCLUDE_ATTRIBUTES),false)
# Show Bazel version
version:
@$(BAZEL) version
# Help
help:
@echo "Available targets:"
@echo ""
@echo "Build & Test:"
@echo " make build - Build all targets"
@echo " make test - Run all tests"
@echo " make test-integration - Run integration tests (slow)"
@echo " make bench - Run GetChangedTargets benchs (measurement only, not in CI)"
@echo " make lint - Run golangci-lint"
@echo " make gazelle - Update BUILD.bazel files"
@echo " make clean - Clean generated files and binaries"
@echo ""
@echo "Protobuf:"
@echo " make proto - Generate protobuf files (gogoslick, grpc, yarpc)"
@echo " make clean-proto - Clean generated proto files"
@echo ""
@echo "Run Server & Client:"
@echo " make run-server - Run the Tango server (port 8081)"
@echo " make run-client-get-graph - Run get-target-graph via the Tango client"
@echo " make run-client-changed-targets - Run get-changed-targets via the Tango client"
@echo ""
@echo "Other:"
@echo " make version - Show Bazel version"
@echo " make help - Show this help message"
@echo ""
@echo "Examples:"
@echo " # Build and test everything"
@echo " make build && make test"
@echo ""
@echo " # Update BUILD files and build"
@echo " make gazelle && make build"
@echo ""
@echo " # Regenerate proto files"
@echo " make clean-proto && make proto"
@echo ""
@echo " # Run the Tango server"
@echo " make run-server"
@echo ""
@echo " # Run client with custom parameters"
@echo " make run-client-get-graph REMOTE=org/repo BASE_SHA=abc123"
@echo " # Run get-changed-targets via the Tango client"
@echo " make run-client-changed-targets REMOTE=org/repo BASE_SHA=abc123 NEW_BASE_SHA=abc123~"
@echo " # Opt into per-target fields (default false per proto3)"
@echo " make run-client-changed-targets REMOTE=org/repo BASE_SHA=abc123 NEW_BASE_SHA=abc123~ INCLUDE_TAGS=true INCLUDE_HASHES=true INCLUDE_ATTRIBUTES=true"