forked from NibiruChain/nibiru
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
250 lines (206 loc) · 6.25 KB
/
justfile
File metadata and controls
250 lines (206 loc) · 6.25 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
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
# Displays available recipes by running `just -l`.
setup:
#!/usr/bin/env bash
just -l
# Locally install the `nibid` binary and build if needed.
install:
go mod tidy
make install
install-clean:
rm -rf temp
just install
install-covtool:
go install github.com/wa
# Build the `nibid` binary.
build:
make build
# Cleans the Go cache, modcache, and testcashe
clean-cache:
go clean -cache -testcache -modcache
# Generate protobuf-based types in Golang
gen-proto:
#!/usr/bin/env bash
make proto-gen
# Generate Solidity artifacts for x/evm/embeds
gen-embeds:
#!/usr/bin/env bash
source contrib/bashlib.sh
embeds_dir="x/evm/embeds"
log_info "Begin to compile Solidity in $embeds_dir"
which_ok yarn
log_info "Using system node version: $(yarn exec -- node -v)"
cd "$embeds_dir" || (log_error "path $embeds_dir not found" && exit 1)
yarn --check-files
yarn hardhat compile && echo "SUCCESS: yarn hardhat compile succeeded" || echo "Run failed"
log_success "Compiled Solidity in $embeds_dir"
go run "gen-abi/main.go"
log_success "Saved ABI JSON files to $embeds_dir/abi for npm publishing"
# Generates CHANGELOG-UNRELEASED.md based on commits and pull requests.
gen-changelog:
#!/usr/bin/env bash
source contrib/bashlib.sh
which_ok cargo
if ! which_ok git-cliff; then
echo "Installing git-cliff with cargo"
cargo install git-cliff
fi
which_ok git-cliff
LAST_VER="v2.9.0"
start_branch="$(git branch --show-current)"
origdir="$(pwd)"
tmpdir="$(mktemp -d)"
cleanup() { rm -rf "$tmpdir"; }
trap cleanup EXIT
# Create a detached worktree at main so we don’t touch the current branch
git fetch -q origin main
git worktree add --detach --quiet "$tmpdir" origin/main
# Run git-cliff in the main worktree but write the file into the original repo
( cd "$tmpdir" && git-cliff "$LAST_VER.." --config="$origdir/cliff.toml" ) > CHANGELOG-UNRELEASED.md
last_exit_code="$?"
if [ "$last_exit_code" -ne 0 ]; then
log_error "changelog generation failed"
exit 1
fi
log_success "Created CHANGELOG-UNRELEASED.md with changes since $LAST_VER"
# Generate the Nibiru Token Registry files
gen-token-registry:
go run token-registry/main/main.go
# Generate protobuf-based types in Rust
gen-proto-rs:
bash proto/buf.gen.rs.sh
# Generate OpenAPI and Swagger files
gen-proto-openapi:
bun run proto/buf-gen-swagger.ts 2>&1 | tee out.txt
lint:
#!/usr/bin/env bash
echo "Running golangci-lint with docker!"
image_version="v2.6.1"
docker run --rm \
-v "$(pwd)":/app \
-v ~/.cache/golangci-lint/$image_version:/root/.cache \
-w /app \
golangci/golangci-lint:$image_version \
golangci-lint run -v --fix 2>&1
# Runs a Nibiru local network. Ex: "just localnet", "just localnet --no-build", "just localnet --features featureA"
localnet *PASS_FLAGS:
make localnet FLAGS="{{PASS_FLAGS}}"
# Runs a Nibiru local network without building and installing. "just localnet --no-build"
localnet-fast:
make localnet FLAGS="--no-build"
# Clears the logs directory
log-clear:
#!/usr/bin/env bash
if [ -d "logs" ] && [ "$(ls -A logs)" ]; then
rm logs/* && echo "Logs cleared successfully."
elif [ ! -d "logs" ]; then
echo "Logs directory does not exist. Nothing to clear."
else
echo "Logs directory is already empty."
fi
# Runs "just localnet" with logging (logs/localnet.txt)
log-localnet:
#!/usr/bin/env bash
mkdir -p logs
just localnet 2>&1 | tee -a logs/localnet.txt
# Runs the EVM E2E test with logging (logs/e2e.txt)
log-e2e:
#!/usr/bin/env bash
just test-e2e 2>&1 | tee -a logs/e2e.txt
# Runs the EVM E2E tests
test-e2e:
#!/usr/bin/env bash
source contrib/bashlib.sh
log_info "Make sure the localnet is running! (just localnet)"
cd evm-e2e
just test
# Test: "localnet.sh" script
test-localnet:
#!/usr/bin/env bash
source contrib/bashlib.sh
just install
bash contrib/scripts/localnet.sh &
log_info "Sleeping for 6 seconds to give network time to spin up and run a few blocks."
sleep 6
kill $(pgrep -x nibid) # Stops network running as background process.
log_success "Spun up localnet"
# Test: "chaosnet.sh" script
test-chaosnet:
#!/usr/bin/env bash
source contrib/bashlib.sh
which_ok nibid
bash contrib/scripts/chaosnet.sh
# Alias for "gen-proto"
proto-gen:
just gen-proto
# Stops any `nibid` processes, even if they're running in the background.
stop:
kill $(pgrep -x nibid) || true
passkey-demo:
#!/usr/bin/env bash
scripts/passkey-demo.sh
# Runs golang formatter (gofumpt)
fmt:
gofumpt -w x app gosdk eth
# Format and lint
tidy:
#!/usr/bin/env bash
go mod tidy
just proto-gen
just lint
just fmt
test-release:
make release-snapshot
release-publish:
make release
# Run Go tests (short mode)
test-unit:
go test ./... -short
# Run Go tests (short mode) + coverage
test-coverage-unit:
make test-coverage-unit
# Heavy tests for the EVM and EVM JSON-RPC
test-cover-g1:
#!/usr/bin/env bash
echo "------------------------------------------------"
echo "Running Group 1 tests..."
echo "Paths: eth, x/evm"
go test ./eth/... ./x/evm/... \
-tags=pebbledb -covermode=atomic -race \
-coverprofile=coverage.group1.out
# Heavy tests for app, cmd, gosdk, token-registry
test-cover-g2:
#!/usr/bin/env bash
echo "------------------------------------------------"
echo "Running Group 2 tests..."
echo "Paths: app, cmd, gosdk, token-registry"
# Group 2
go test ./app/... \
./cmd/... \
./gosdk/... \
./token-registry/... \
-tags=pebbledb -covermode=atomic -race \
-coverprofile=coverage.group2.out
# Heavy tests for all x/* modules besides EVM
test-cover-g3:
#!/usr/bin/env bash
echo "------------------------------------------------"
echo "Running Group 3 tests..."
echo "Paths: (all x/* except evm)"
echo "Reproduce of modules with command: ls x/ | grep -v -E 'evm|README.md' "
go test ./x/bank/... \
./x/nutil/... \
./x/devgas/... \
./x/epochs/... \
./x/genmsg/... \
./x/inflation/... \
./x/oracle/... \
./x/sudo/... \
./x/tokenfactory/... \
-tags=pebbledb -covermode=atomic -race \
-coverprofile=coverage.group3.out
# Run Go tests, including live network tests + coverage
test-cover-heavy:
#!/usr/bin/env bash
just test-cover-g1
just test-cover-g2
just test-cover-g3