-
Notifications
You must be signed in to change notification settings - Fork 90
Expand file tree
/
Copy pathMakefile
More file actions
147 lines (129 loc) · 5.87 KB
/
Copy pathMakefile
File metadata and controls
147 lines (129 loc) · 5.87 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
# Delegates rather than repeating the tar invocation: release_prep.sh (release),
# bcr_consumer.yaml and ci.yaml all pack through this one script, so the archive
# you get locally is byte-for-byte the recipe that ships. The inlined copy that
# used to live here had already drifted from it.
# Note: the script lives under .github/, which the archive itself excludes, so
# this target only works in a git checkout -- not inside an extracted release.
.PHONY: release_source_archive
release_source_archive:
.github/workflows/pack_release_archive.sh archives/release.tar.gz
.PHONY: release_deploy_jar
release_deploy_jar:
bazel \
build \
//cli:bazel-diff_deploy.jar \
-c opt
# Builds the same artifact CI publishes, named the same way:
# bazel-bin/release/bazel-diff-rust-<os>-<arch>[.exe].
.PHONY: release_rust_binary
release_rust_binary:
bazel \
build \
//release:bazel-diff-rust \
--config=release
# The published Linux binaries, which are not host-native: they are statically
# linked against musl so they run on any distribution, and cross-compile from a
# glibc Linux host or an Apple Silicon Mac. Same output path and asset name.
.PHONY: release_rust_binary_linux
release_rust_binary_linux:
bazel \
build \
//release:bazel-diff-rust \
--config=release-musl
.PHONY: release_rust_binary_linux_arm64
release_rust_binary_linux_arm64:
bazel \
build \
//release:bazel-diff-rust \
--config=release-musl-arm64
.PHONY: build_rust
build_rust:
bazel build //:bazel-diff-rust -c opt
# Both go through Bazel so they use the same formatters CI gates on. `cargo fmt
# --all` is not equivalent: it only sees the root crate, missing tools/coverage,
# and it uses whatever rustfmt is on PATH rather than the pinned one.
.PHONY: format
format:
bazel run //cli/format
bazel run //cli/format:rustfmt
# Regenerates the per-case e2e test targets from the e2e sources. Run it after
# adding, renaming or removing a `@Test` method under
# cli/src/test/kotlin/com/bazel_diff/e2e/ or a `#[test]` fn under tests/e2e/,
# and commit the result -- `e2e-split-regen` in ci.yaml fails the build if the
# checked-in split is stale. See tools/e2e/README.md.
.PHONY: regen-e2e
regen-e2e:
bazel run //tools/e2e:regen
# What CI runs. Reports staleness; it never rewrites anything.
.PHONY: regen-e2e-check
regen-e2e-check:
bazel test //tools/e2e:regen_check //tools/e2e:split_e2e_tests_test
.PHONY: generate-readme
generate-readme:
bazel run //tools:generate-readme
.PHONY: coverage
coverage:
bazel coverage --combined_report=lcov //cli/... //src:cli_tests //src:rust_tests //tools:coverage_check_test //tools/coverage/... //tools/go/...
bazel run //tools:coverage-check -- bazel-out/_coverage/_coverage_report.dat
bazel run //tools:coverage-check -- --include tools/go/ --threshold 90 bazel-out/_coverage/_coverage_report.dat
.PHONY: coverage-check
coverage-check:
bazel run //tools:coverage-check -- bazel-out/_coverage/_coverage_report.dat
bazel run //tools:coverage-check -- --include tools/go/ --threshold 90 bazel-out/_coverage/_coverage_report.dat
.PHONY: coverage-test
coverage-test:
bazel test //tools:coverage_check_test
.PHONY: coverage-html
coverage-html:
bazel coverage --combined_report=lcov //cli/... //src:cli_tests //src:rust_tests //tools:coverage_check_test //tools/coverage/... //tools/go/...
bazel run //tools:coverage-check -- bazel-out/_coverage/_coverage_report.dat --html coverage-html
@echo "Open coverage-html/index.html in a browser to inspect."
.PHONY: coverage_rust
coverage_rust:
bazel coverage //src:cli_tests //src:rust_tests
.PHONY: benchmark
benchmark:
@test -n "$(WORKSPACE)" || (echo "usage: make benchmark WORKSPACE=/path/to/bazel [BAZEL=/path/to/bazelisk] [HYPERFINE=/path/to/hyperfine] [STREAMED_PROTO=/path/to/targets.pb] [INCLUDE_BAZEL=1] [ITERATIONS=10] [WARMUP=3] [RSS_RUNS=5] [JSON=benchmark.json]" >&2; exit 2)
$(or $(BAZEL),bazel) run -c opt //tools:benchmark -- \
--workspace "$(WORKSPACE)" \
--bazel "$(or $(BAZEL),bazel)" \
--hyperfine "$(or $(HYPERFINE),hyperfine)" \
--iterations "$(or $(ITERATIONS),10)" \
--warmup "$(or $(WARMUP),3)" \
--rss-runs "$(or $(RSS_RUNS),5)" \
$(if $(STREAMED_PROTO),--streamed-proto "$(STREAMED_PROTO)",) \
$(if $(INCLUDE_BAZEL),--include-bazel,) \
$(if $(JSON),--json "$(JSON)",)
# Hermetic Kotlin-vs-Rust performance gate. Unlike `make benchmark` this needs no
# workspace, no Bazel server and no Hyperfine: it generates its own fixtures and fails
# (exit 1) if Rust is not faster than Kotlin on every workload. JSON=... must be an
# absolute path -- `bazel run` executes from the runfiles tree, not the repo root.
.PHONY: perf-gate
perf-gate:
$(or $(BAZEL),bazel) run -c opt //tools:perf-gate -- \
--rounds "$(or $(ROUNDS),5)" \
--warmup-rounds "$(or $(WARMUP),1)" \
--scale "$(or $(SCALE),1)" \
$(if $(WORKLOAD),--workload "$(WORKLOAD)",) \
$(if $(RSS_RUNS),--rss-runs "$(RSS_RUNS)",) \
$(if $(JSON),--json "$(JSON)",)
# The gate against the statically-linked musl binary that actually ships for Linux, not the
# host glibc build `perf-gate` uses. musl's single-arena malloc serializes the parallel proto
# decode, so this exposes allocator-scalability regressions -- but only on a many-core host
# (>= 8 cores); on a 2-core machine there is too little contention and it passes regardless.
# Defaults to the allocator-sensitive workload; override with WORKLOAD= to run others.
.PHONY: perf-gate-musl
perf-gate-musl:
$(or $(BAZEL),bazel) build //cli:bazel-diff -c opt
$(or $(BAZEL),bazel) build //release:bazel-diff-rust --config=release-musl
python3 tools/perf_gate.py \
--kotlin-binary bazel-bin/cli/bazel-diff \
--rust-binary bazel-bin/release/bazel-diff-rust-linux-amd64 \
--workload "$(or $(WORKLOAD),generate-hashes-dense)" \
--rounds "$(or $(ROUNDS),7)" \
--warmup-rounds "$(or $(WARMUP),2)" \
--scale "$(or $(SCALE),1)" \
$(if $(JSON),--json "$(JSON)",)
.PHONY: perf-gate-test
perf-gate-test:
$(or $(BAZEL),bazel) test //tools:perf_gate_test