forked from Granola-Team/mina-indexer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Justfile
221 lines (178 loc) · 6.5 KB
/
Justfile
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
# Justfile
#
# The command 'just' will give usage information.
# See https://github.com/casey/just for more.
export TOPLEVEL := `pwd`
export CARGO_HOME := TOPLEVEL + "/.cargo"
export GIT_COMMIT_HASH := `git rev-parse --short=8 HEAD`
IMAGE := "mina-indexer:" + GIT_COMMIT_HASH
alias tu := test-unit-dev
alias t1 := tier1
alias t2 := tier2-dev
alias t3 := tier3-dev
alias dlp := deploy-local-prod-dev
# Ensure rustfmt works in all environments
# Nix environment has rustfmt nightly and won't work with +nightly
# Non-Nix environment needs nightly toolchain installed and requires +nightly
is_rustfmt_nightly := `cd rust && rustfmt --version | grep stable || echo "true"`
nightly_if_required := if is_rustfmt_nightly == "true" { "" } else { "+nightly" }
DEBUG_MODE := TOPLEVEL + "/rust/target/debug/mina-indexer"
PROD_MODE := TOPLEVEL + "/result/bin/mina-indexer"
REGRESSION_TEST := "./ops/regression-test.rb"
DEPLOY := "./ops/deploy.rb"
default:
@just --list --justfile {{justfile()}}
# Check for presence of dev dependencies.
tier1-prereqs:
@echo "--- Checking for tier-1 prereqs"
ruby --version
cd rust && cargo --version
cd rust && cargo nextest --version
cd rust && cargo audit --version
cd rust && cargo clippy --version
cd rust && cargo machete --help 2>&1 >/dev/null
shellcheck --version
tier2-prereqs: tier1-prereqs
@echo "--- Checking for tier-2 prereqs"
jq --version
check-jsonschema --version
hurl --version
audit:
@echo "--- Performing Cargo audit"
cd rust && time cargo audit
lint:
@echo "--- Linting ops scripts"
ruby -cw ops/*.rb
standardrb --no-fix ops/*.rb
shellcheck tests/regression.bash
@echo "--- Linting Rust code"
cd rust && time cargo {{nightly_if_required}} fmt --all --check
cd rust && time cargo clippy --all-targets --all-features -- -D warnings
@echo "--- Linting Nix configs"
[ "$(nixfmt < flake.nix)" == "$(cat flake.nix)" ]
@echo "--- Linting Cargo dependencies"
cd rust && cargo machete Cargo.toml
nix-build:
@echo "--- Performing Nix build"
nom build
clean:
cd rust && cargo clean
rm -f result
@echo "Consider also 'git clean -xdfn'"
clean-dev:
@echo "Cleaning dev directory"
{{REGRESSION_TEST}} clean-dev
clean-prod rev=GIT_COMMIT_HASH:
@echo "Cleaning prod directory"
{{DEPLOY}} prod clean {{rev}}
clean-test rev=GIT_COMMIT_HASH:
@echo "Cleaning test directory"
{{DEPLOY}} test clean {{rev}}
format:
cd rust && cargo {{nightly_if_required}} fmt --all
standardrb --fix ops/*.rb
test-unit test='':
@echo "--- Invoking 'cargo nextest'"
cd rust && time cargo nextest run {{test}}
test-unit-dev: lint test-unit
# Perform a fast verification of whether the source compiles.
check:
@echo "--- Invoking 'cargo check'"
cd rust && time cargo check
test-unit-mina-rs:
@echo "--- Performing long-running mina-rs unit tests"
cd rust && time cargo nextest run --release --features mina_rs
# Perform a debug build
debug-build:
cd rust && cargo build
# Quick debug-build and regression-test
bt subtest='': debug-build
time {{REGRESSION_TEST}} {{DEBUG_MODE}} {{subtest}}
# Quick debug-build and continue regression-test
ct subtest='': debug-build
time {{REGRESSION_TEST}} {{DEBUG_MODE}} continue {{subtest}}
# Quick (debug) unit-test and regression-test
tt subtest='': test-unit
time {{REGRESSION_TEST}} {{DEBUG_MODE}} {{subtest}}
# Build OCI images.
build-image:
@echo "--- Building {{IMAGE}}"
docker --version
time nom build .#dockerImage
time docker load < ./result
docker run --rm -it {{IMAGE}} mina-indexer server start --help
docker image rm {{IMAGE}}
rm result
# Run the 1st tier of tests.
tier1: tier1-prereqs check lint test-unit
@echo "--- Performing tier 1 regression tests"
time {{REGRESSION_TEST}} {{DEBUG_MODE}} \
ipc_is_available_immediately \
clean_shutdown \
clean_kill \
block_copy \
account_balance_cli \
best_chain \
rest_accounts_summary \
reuse_databases \
hurl
# Tier2 nix (release) tests
tier2-load-test:
@echo "--- Performing a simple load test with Nix-built binary"
time {{REGRESSION_TEST}} {{PROD_MODE}} load
tier2-many-blocks-test:
@echo "--- Performing many_blocks regression test with Nix-built binary"
time {{REGRESSION_TEST}} {{PROD_MODE}} many_blocks
tier2-release-test:
@echo "--- Performing release regression test with Nix-built binary"
time {{REGRESSION_TEST}} {{PROD_MODE}} release
tier2-regression-tests:
@echo "--- Performing tier 2 regression tests with Nix-built binary"
time {{REGRESSION_TEST}} {{PROD_MODE}}
# Tier2 dev (debug) tests
tier2-load-test-dev:
@echo "--- Performing a simple load test with debug-built binary"
time {{REGRESSION_TEST}} {{DEBUG_MODE}} load
tier2-many-blocks-test-dev:
@echo "--- Performing many_blocks regression test with debug-built binary"
time {{REGRESSION_TEST}} {{DEBUG_MODE}} many_blocks
tier2-release-test-dev:
@echo "--- Performing release regression test with debug-built binary"
time {{REGRESSION_TEST}} {{DEBUG_MODE}} release
tier2-regression-tests-dev:
@echo "--- Performing tier 2 regression tests with debug-built binary"
time {{REGRESSION_TEST}} {{DEBUG_MODE}}
# Run the 2nd tier of tests with Nix-built binary & build OCI image.
tier2: tier2-prereqs nix-build \
tier2-load-test \
tier2-many-blocks-test \
tier2-release-test \
tier2-regression-tests \
&& build-image
# Run the 2nd tier of with debug build.
tier2-dev: tier2-prereqs debug-build \
tier2-load-test-dev \
tier2-many-blocks-test-dev \
tier2-release-test-dev \
tier2-regression-tests-dev
# Run the 3rd tier of tests with Nix-built binary.
tier3 blocks='5000': nix-build test-unit-mina-rs
@echo "--- Performing tier3 regression tests with Nix-built binary"
time {{DEPLOY}} test nix {{blocks}}
# Run the 3rd tier of tests with debug build & no unit tests.
tier3-dev blocks='5000': debug-build
@echo "--- Performing tier3 regression tests with debug-built binary"
time {{DEPLOY}} test debug {{blocks}}
# Run a server as if in production with the Nix-built binary.
deploy-local-prod blocks='5000' web_port='': nix-build
@echo "--- Deploying to production"
time {{DEPLOY}} prod nix {{blocks}} {{web_port}}
# Run a server as if in production with the debug-built binary.
deploy-local-prod-dev blocks='5000' web_port='': debug-build
@echo "--- Deploying to production dev"
time {{DEPLOY}} prod debug {{blocks}} {{web_port}}
# Shutdown a running local prod indexer.
shutdown rev=GIT_COMMIT_HASH:
@echo "Shutting down prod indexer"
{{DEPLOY}} prod shutdown {{rev}}
@echo "Successfully shutdown. You may also want to do 'just clean-prod'"