forked from GitoxideLabs/gitoxide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
324 lines (265 loc) · 15.1 KB
/
Makefile
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
always:
##@ Publishing & Versioning
try-publish-all: ## Dry-run publish all crates in the currently set version if they are not published yet.
cargo run --package cargo-smart-release --bin cargo-smart-release -- smart-release gitoxide
try-bump-minor-version: ## Show how updating the minor version of PACKAGE=<name> would look like.
cargo run --package cargo-smart-release --bin cargo-smart-release -- smart-release --update-crates-index --bump minor --no-dependencies --no-publish --no-tag --no-push -v $(PACKAGE)
bump-minor-version: ## Similar to try-bump-minor-version, but actually performs the operation on PACKAGE=<name>
cargo run --package cargo-smart-release --bin cargo-smart-release -- smart-release --update-crates-index --bump minor --no-dependencies --skip-publish --skip-tag --skip-push -v $(PACKAGE) --execute
##@ Release Builds
release-all: release release-lean release-small ## all release builds
release: always ## the default build, big but pretty (builds in ~2min 35s)
cargo build --release
release-lean: always ## lean and fast, with line renderer (builds in ~1min 30s)
cargo build --release --no-default-features --features lean
release-small: always ## minimal dependencies, at cost of performance (builds in ~46s)
cargo build --release --no-default-features --features small
##@ Debug Builds
debug: always ## the default build, big but pretty
cargo build
debug-lean: always ## lean and fast, with line renderer
cargo build --no-default-features --features lean
debug-small: always ## minimal dependencies, at cost of performance
cargo build --no-default-features --features small
##@ Development
target/release/gix: always
cargo build --release --no-default-features --features small
nix-shell-macos: ## Enter a nix-shell able to build on macos
nix-shell -p pkg-config openssl libiconv darwin.apple_sdk.frameworks.Security darwin.apple_sdk.frameworks.SystemConfiguration
##@ Testing
tests: clippy check doc unit-tests journey-tests-small journey-tests-async journey-tests journey-tests-smart-release ## run all tests, including journey tests, try building docs
audit: ## run various auditing tools to assure we are legal and safe
cargo deny check advisories bans licenses sources
doc: ## Run cargo doc on all crates
cargo doc
cargo doc --features=max,lean,small
clippy: ## Run cargo clippy on all crates
cargo clippy --all --tests
cargo clippy --all --no-default-features --features small
cargo clippy --all --no-default-features --features lean-async --tests
check-msrv: ## run cargo msrv to validate the current msrv requirements, similar to what CI does
cd git-repository && cargo +1.54.0 check --package git-repository --no-default-features --features async-network-client,unstable,local-time-support,max-performance
check-win: ## see that windows compiles, provided the x86_64-pc-windows-msvc target and cargo-xwin are present.
cargo xwin build --target x86_64-pc-windows-msvc --no-default-features --features small
check: ## Build all code in suitable configurations
cargo check --all
cargo check --no-default-features --features small
if cargo check --features lean-async 2>/dev/null; then false; else true; fi
cargo check --no-default-features --features lean
cargo check --no-default-features --features lean-async
cargo check --no-default-features --features max
cd git-actor && cargo check \
&& cargo check --features local-time-support
cd gitoxide-core && cargo check \
&& cargo check --features blocking-client \
&& cargo check --features async-client \
&& cargo check --features local-time-support
cd gitoxide-core && if cargo check --all-features 2>/dev/null; then false; else true; fi
cd git-hash && cargo check --all-features \
&& cargo check
cd git-object && cargo check --all-features \
&& cargo check --features verbose-object-parsing-errors
cd git-index && cargo check --features serde1
cd git-credentials && cargo check --features serde1
cd git-sec && cargo check --features serde1
cd git-revision && cargo check --features serde1
cd git-attributes && cargo check --features serde1
cd git-glob && cargo check --features serde1
cd git-mailmap && cargo check --features serde1
cd git-worktree && cargo check --features serde1
cd git-actor && cargo check --features serde1
cd git-pack && cargo check --features serde1 \
&& cargo check --features pack-cache-lru-static \
&& cargo check --features pack-cache-lru-dynamic \
&& cargo check --features object-cache-dynamic \
&& cargo check
cd git-packetline && cargo check \
&& cargo check --features blocking-io \
&& cargo check --features async-io
cd git-packetline && if cargo check --all-features 2>/dev/null; then false; else true; fi
cd git-url && cargo check --all-features \
&& cargo check
cd git-features && cargo check --all-features \
&& cargo check --features parallel \
&& cargo check --features rustsha1 \
&& cargo check --features fast-sha1 \
&& cargo check --features progress \
&& cargo check --features time \
&& cargo check --features io-pipe \
&& cargo check --features crc32 \
&& cargo check --features zlib \
&& cargo check --features zlib,zlib-ng-compat \
&& cargo check --features cache-efficiency-debug
cd git-commitgraph && cargo check --all-features \
&& cargo check
cd git-config && cargo check --all-features \
&& cargo check
cd git-transport && cargo check \
&& cargo check --features blocking-client \
&& cargo check --features async-client \
&& cargo check --features http-client-curl
cd git-transport && if cargo check --all-features 2>/dev/null; then false; else true; fi
cd git-protocol && cargo check \
&& cargo check --features blocking-client \
&& cargo check --features async-client
cd git-protocol && if cargo check --all-features 2>/dev/null; then false; else true; fi
cd git-repository && cargo check --no-default-features --features local \
&& cargo check --no-default-features --features async-network-client \
&& cargo check --no-default-features --features blocking-network-client \
&& cargo check --no-default-features --features blocking-network-client,blocking-http-transport \
&& cargo check --no-default-features --features one-stop-shop \
&& cargo check --no-default-features --features max-performance \
&& cargo check --no-default-features
cd git-odb && cargo check --features serde1
cd cargo-smart-release && cargo check --all
cd experiments/object-access && cargo check
cd experiments/diffing && cargo check
cd experiments/traversal && cargo check
unit-tests: ## run all unit tests
cargo test --all
cd git-features && cargo test && cargo test --all-features
cd git-ref && cargo test --all-features
cd git-odb && cargo test && cargo test --all-features
cd git-object && cargo test && cargo test --features verbose-object-parsing-errors
cd git-pack && cargo test --features internal-testing-to-avoid-being-run-by-cargo-test-all \
&& cargo test --features "internal-testing-git-features-parallel"
cd git-index && cargo test --features internal-testing-to-avoid-being-run-by-cargo-test-all \
&& cargo test --features "internal-testing-git-features-parallel"
cd git-worktree && cargo test --features internal-testing-to-avoid-being-run-by-cargo-test-all \
&& cargo test --features "internal-testing-git-features-parallel"
cd git-packetline && cargo test \
&& cargo test --features blocking-io,maybe-async/is_sync --test blocking-packetline \
&& cargo test --features "async-io" --test async-packetline
cd git-transport && cargo test \
&& cargo test --features http-client-curl,maybe-async/is_sync \
&& cargo test --features async-client
cd git-protocol && cargo test --features blocking-client \
&& cargo test --features async-client \
&& cargo test
cd gitoxide-core && cargo test --lib
continuous-unit-tests: ## run all unit tests whenever something changes
watchexec -w src $(MAKE) unit-tests
jtt = target/debug/jtt
journey-tests: always ## run journey tests (max)
cargo build
cargo build --package git-testtools --bin jtt
./tests/journey.sh target/debug/ein target/debug/gix $(jtt) max
journey-tests-small: always ## run journey tests (lean-cli)
cargo build --no-default-features --features small
cd tests/tools && cargo build
./tests/journey.sh target/debug/ein target/debug/gix $(jtt) small
journey-tests-async: always ## run journey tests (lean-async)
cargo build --no-default-features --features lean-async
cd tests/tools && cargo build
./tests/journey.sh target/debug/ein target/debug/gix $(jtt) async
journey-tests-smart-release:
cargo build --package cargo-smart-release
cd cargo-smart-release && ./tests/journey.sh ../target/debug/cargo-smart-release
continuous-journey-tests: ## run stateless journey tests whenever something changes
watchexec $(MAKE) journey-tests
clear-cache: ## Remove persisted results of test-repositories, they regenerate automatically
-find . -path "*fixtures/generated" -type d -exec rm -Rf \{\} \;
rust_repo = tests/fixtures/repos/rust.git
$(rust_repo):
mkdir -p $@
cd $@ && git init --bare && git remote add origin https://github.com/rust-lang/rust && git fetch
linux_repo = tests/fixtures/repos/linux.git
$(linux_repo):
mkdir -p $@
cd $@ && git init --bare && git remote add origin https://github.com/torvalds/linux && git fetch
test_many_commits_1m_repo = tests/fixtures/repos/test-many-commits-1m.git
$(test_many_commits_1m_repo):
mkdir -p $@
cd $@ && git init --bare && git remote add origin https://github.com/cirosantilli/test-many-commits-1m.git && git fetch
## get all non-rc tags up to v5.8, oldest tag first (should have 78 tags)
## -> convert to commit ids
## -> write a new incremental commit-graph file for each commit id
tests/fixtures/commit-graphs/linux/long-chain: $(linux_repo)
mkdir -p $@
rm -rf $(linux_repo)/objects/info/*graph*
set -x && cd $(linux_repo) && \
for tag in $$(git tag --list --merged v5.8 --sort=version:refname | grep -Fv -- -rc); do \
git show-ref -s "$$tag" | git commit-graph write --split=no-merge --stdin-commits; \
done
mv -f $(linux_repo)/objects/info/*graphs* $@
actual=$$(ls -1 $@/commit-graphs/*.graph | wc -l); \
if [ $$actual -ne 78 ]; then echo expected 78 commit-graph files, got $$actual; exit 1; fi
tests/fixtures/commit-graphs/linux/single-file: $(linux_repo)
mkdir -p $@
rm -rf $(linux_repo)/objects/info/*graph*
cd $(linux_repo) && git show-ref -s v5.8 | git commit-graph write --stdin-commits
mv -f $(linux_repo)/objects/info/*graph* $@
tests/fixtures/commit-graphs/rust/single-file: $(rust_repo)
mkdir -p $@
rm -rf $(rust_repo)/objects/info/*graph*
cd $(rust_repo) && git fetch --tags && git show-ref -s 1.47.0 | git commit-graph write --stdin-commits
mv -f $(rust_repo)/objects/info/*graph* $@
tests/fixtures/commit-graphs/test-many-commits-1m/single-file: $(test_many_commits_1m_repo)
mkdir -p $@
rm -rf $(test_many_commits_1m_repo)/objects/info/*graph*
cd $(test_many_commits_1m_repo) \
&& echo f4d21576c13d917e1464d9bc1323a560a5b8595d | git commit-graph write --stdin-commits
mv -f $(test_many_commits_1m_repo)/objects/info/*graph* $@
commit_graphs = \
tests/fixtures/commit-graphs/linux/long-chain \
tests/fixtures/commit-graphs/linux/single-file \
tests/fixtures/commit-graphs/rust/single-file \
tests/fixtures/commit-graphs/test-many-commits-1m/single-file
##@ on CI
stress: ## Run various algorithms on big repositories
$(MAKE) -j3 $(linux_repo) $(rust_repo) release-lean
time ./target/release/gix --verbose pack verify --re-encode $(linux_repo)/objects/pack/*.idx
time ./target/release/gix --verbose pack multi-index -i $(linux_repo)/objects/pack/multi-pack-index create $(linux_repo)/objects/pack/*.idx
time ./target/release/gix --verbose pack verify $(linux_repo)/objects/pack/multi-pack-index
rm -Rf out; mkdir out && time ./target/release/gix --verbose pack index create -p $(linux_repo)/objects/pack/*.pack out/
time ./target/release/gix --verbose pack verify out/*.idx
time ./target/release/gix --verbose pack verify --statistics $(rust_repo)/objects/pack/*.idx
time ./target/release/gix --verbose pack verify --algorithm less-memory $(rust_repo)/objects/pack/*.idx
time ./target/release/gix --verbose pack verify --re-encode $(rust_repo)/objects/pack/*.idx
# We must ensure there is exactly one pack file for the pack-explode *.idx globs to work.
git repack -Ad
time ./target/release/gix --verbose pack explode .git/objects/pack/*.idx
rm -Rf delme; mkdir delme && time ./target/release/gix --verbose pack explode .git/objects/pack/*.idx delme/
$(MAKE) stress-commitgraph
$(MAKE) bench-git-config
.PHONY: stress-commitgraph
stress-commitgraph: release-lean $(commit_graphs)
set -x; for path in $(wordlist 2, 999, $^); do \
time ./target/release/gix --verbose commit-graph verify $$path; \
done
.PHONY: bench-git-config
bench-git-config:
cd git-config && cargo bench
check-msrv-on-ci: ## Check the minimal support rust version for currently installed Rust version
rustc --version
cargo check --package git-repository
cargo check --package git-repository --no-default-features --features async-network-client,unstable,local-time-support,max-performance
##@ Maintenance
baseline_asset_dir = git-repository/src/assets/baseline-init
baseline_asset_fixture = tests/fixtures/baseline-init
$(baseline_asset_fixture):
mkdir -p $@
cd "$@" && git init --bare && \
sed -i '' -E '/bare = true|ignorecase = true|precomposeunicode = true|filemode = true/d' config && \
sed -i '' 's/master/main/g' $$(find . -type f)
transport_fixtures = git-transport/tests/fixtures
base_url = https://github.com/Byron/gitoxide.git
update-curl-fixtures: ## use curl to fetch raw fixtures for use in unit test. Changes there might break them
curl -D - -L "$(base_url)/info/refs?service=git-upload-pack" > $(transport_fixtures)/v1/http-handshake.response
curl -D - -H 'Git-Protocol: version=2' -L "$(base_url)/info/refs?service=git-upload-pack" > $(transport_fixtures)/v2/http-handshake.response
curl -H 'User-Agent: git/oxide-0.1.0' -D - -H 'Git-Protocol: version=1' -L "https://github.com/Byron/foo/info/refs?service=git-upload-pack" > $(transport_fixtures)/http-401.response
curl -D - -H 'Git-Protocol: version=1' -L "https://github.com/Byron/gitoxide/info/refs?service=git-upload-pack" > $(transport_fixtures)/http-404.response
update-assets: $(baseline_asset_fixture) ## refresh assets compiled into the binaries from their source
-rm -Rf $(baseline_asset_dir)
mkdir -p $(dir $(baseline_asset_dir))
cp -R $< $(baseline_asset_dir)
force-update-assets: ## As update-assets, but will run git to update the baseline as well
-rm -Rf $(baseline_asset_fixture)
$(MAKE) update-assets
check-size: ## Run cargo-diet on all crates to see that they are still in bound
./etc/check-package-size.sh
fmt: ## run nightly rustfmt for its extra features, but check that it won't upset stable rustfmt
cargo +nightly fmt --all -- --config-path rustfmt-nightly.toml
cargo +stable fmt --all -- --check