-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjustfile
More file actions
193 lines (159 loc) · 6.89 KB
/
Copy pathjustfile
File metadata and controls
193 lines (159 loc) · 6.89 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
# See https://github.com/sablier-labs/devkit/blob/main/just/base.just
import "./node_modules/@sablier/devkit/just/base.just"
# ---------------------------------------------------------------------------- #
# DEPENDENCIES #
# ---------------------------------------------------------------------------- #
# Anchor: https://solana.com/docs/intro/installation#install-anchor-cli
anchor := require("anchor")
# Solana: https://solana.com/docs/intro/installation#install-the-solana-cli
solana := require("solana")
# Trident: https://ackee.xyz/trident/docs/latest/basics/installation/
trident := require("trident")
# ---------------------------------------------------------------------------- #
# ENVIRONMENT #
# ---------------------------------------------------------------------------- #
export RUST_LOG := env("RUST_LOG", "off")
# See https://github.com/sablier-labs/solsab/issues/180
export RUSTUP_TOOLCHAIN := "nightly"
# ---------------------------------------------------------------------------- #
# CONSTANTS #
# ---------------------------------------------------------------------------- #
GLOBS_CLEAN := "{.anchor,target}"
GLOBS_PRETTIER := "**/*.{md,yml}"
# ---------------------------------------------------------------------------- #
# RECIPES #
# ---------------------------------------------------------------------------- #
# Default recipe - show available commands
default:
just --list
# Build programs using Anchor
[group("build")]
[script]
build program_name="all":
if [ "{{ program_name }}" = "all" ]; then
cmd="anchor build"
else
cmd="anchor build --program-name {{ program_name }}"
fi
echo "🔨 Building {{ program_name }}..."
# Suppressing the annoying "Compiling" and "Downloaded" messages
# Remove this once this gets implemented: https://github.com/solana-foundation/anchor/issues/3788
$cmd 2>&1 | grep -v "Compiling\|Downloaded"
echo "✅ Successful build\n"
just codegen {{ program_name }}
alias b := build
# Build Lockup program only using Anchor
[group("build")]
build-lockup: (build "sablier_lockup")
alias blk := build-lockup
# Build Merkle Instant program only using Anchor
[group("build")]
build-merkle-instant: (build "sablier_merkle_instant")
alias bmi := build-merkle-instant
# Codegen errors and struct types
@codegen program_name="all":
na run ./scripts/ts/codegen-errors.ts {{ program_name }}
na run ./scripts/ts/codegen-structs.ts {{ program_name }}
# Clean build artifacts
clean globs=GLOBS_CLEAN:
nlx del-cli "{{ globs }}"
# Execute setup script
setup:
bun setup
# ---------------------------------------------------------------------------- #
# CODE CHECKS #
# ---------------------------------------------------------------------------- #
# Run all code checks
full-check:
just _run-with-status codegen
just _run-with-status prettier-check
just _run-with-status biome-check
just _run-with-status tsc-check
just _run-with-status rust-check
just _run-with-status rust-check-trident
# Run all code fixes
full-write:
just _run-with-status prettier-write
just _run-with-status biome-write
just _run-with-status rust-write
just _run-with-status rust-write-trident
# Run Rust checks
# TODO: Remove `--allow deprecated` once mpl-core crate deprecation warnings are resolved upstream.
# This was added for the MPL Core migration (PR #307). Track removal in a GitHub issue.
rust-check:
cargo fmt --check
cargo clippy -- --deny warnings --allow deprecated
alias rc := rust-check
# Format Rust code
rust-write:
cargo fmt
cargo clippy --fix --allow-dirty -- --allow deprecated
alias rw := rust-write
# Run Rust checks on Trident fuzz tests
rust-check-trident:
cargo fmt --check --manifest-path trident-tests/Cargo.toml
cargo clippy --manifest-path trident-tests/Cargo.toml
alias rct := rust-check-trident
# Format Trident fuzz test code
rust-write-trident:
cargo fmt --manifest-path trident-tests/Cargo.toml
cargo clippy --fix --allow-dirty --manifest-path trident-tests/Cargo.toml
alias rwt := rust-write-trident
# ---------------------------------------------------------------------------- #
# TESTING #
# ---------------------------------------------------------------------------- #
# Run all tests (Anchor + Trident)
[group("test")]
test: test-anchor test-trident
alias t := test
# ---------------------------------------------------------------------------- #
# ANCHOR TESTS #
# ---------------------------------------------------------------------------- #
# Run all Anchor tests (lockup + merkle instant)
# To debug the Solana logs, run this as `RUST_LOG=debug just test-anchor`
[group("test")]
test-anchor *args: build _setup-fixtures
na vitest run --hideSkippedTests {{ args }}
alias ta := test-anchor
# Run Anchor tests with UI
[group("test")]
test-anchor-ui *args: build _setup-fixtures
na vitest --hideSkippedTests --ui {{ args }}
alias taui := test-anchor-ui
# Run Anchor Lockup tests only
[group("test")]
test-anchor-lockup *args="tests/lockup": build _setup-fixtures
na vitest run --hideSkippedTests {{ args }}
alias talk := test-anchor-lockup
# Run Anchor Merkle Instant tests only
[group("test")]
test-anchor-merkle-instant *args="tests/merkle-instant": build _setup-fixtures
na vitest run --hideSkippedTests {{ args }}
alias tami := test-anchor-merkle-instant
# ---------------------------------------------------------------------------- #
# TRIDENT TESTS #
# ---------------------------------------------------------------------------- #
# Run all Trident fuzz tests
[group("test")]
test-trident: test-trident-lockup
alias tt := test-trident
# Run Trident Lockup fuzz tests
[group("test")]
test-trident-lockup: build _setup-fixtures
just --justfile trident-tests/justfile test-lockup
alias ttlk := test-trident-lockup
# Download external program fixtures for testing
_setup-fixtures:
#!/usr/bin/env sh
FIXTURES_DIR="tests/fixtures"
mkdir -p "$FIXTURES_DIR"
# MPL Core Program
if [ ! -f "$FIXTURES_DIR/mpl_core_program.so" ]; then
echo "📥 Downloading MPL Core program..."
solana program dump -u m CoREENxT6tW1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d "$FIXTURES_DIR/mpl_core_program.so"
fi
# Chainlink Program
if [ ! -f "$FIXTURES_DIR/chainlink_program.so" ]; then
echo "📥 Downloading Chainlink program..."
solana program dump -u m HEvSKofvBgfaexv23kMabbYqxasxU3mQ4ibBMEmJWHny "$FIXTURES_DIR/chainlink_program.so"
fi