-
Notifications
You must be signed in to change notification settings - Fork 9
/
justfile
171 lines (134 loc) · 4.65 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
# Define the path to your docker-compose.yml file
DOCKER_COMPOSE_FILE := "ci/docker-compose.yml"
celestia-up:
#!/usr/bin/env bash
set -euo pipefail
echo "Cleaning up any existing Docker resources..."
docker-compose -f {{DOCKER_COMPOSE_FILE}} down -v --remove-orphans
echo "Building Docker images..."
docker-compose -f {{DOCKER_COMPOSE_FILE}} build
echo "Spinning up a fresh Docker Compose stack..."
docker-compose -f {{DOCKER_COMPOSE_FILE}} up -d --force-recreate --renew-anon-volumes
echo "Waiting for services to be ready..."
timeout=120
start_time=$(date +%s)
light_node_ready=false
bridge_node_ready=false
while true; do
logs=$(docker-compose -f {{DOCKER_COMPOSE_FILE}} logs)
if [[ $logs == *"Configuration finished. Running a light node"* ]]; then
light_node_ready=true
echo "Light node is ready!"
fi
if [[ $logs == *"Configuration finished. Running a bridge node"* ]]; then
bridge_node_ready=true
echo "Bridge node is ready!"
fi
if $light_node_ready && $bridge_node_ready; then
echo "All services are ready!"
break
fi
current_time=$(date +%s)
elapsed=$((current_time - start_time))
if [ $elapsed -ge $timeout ]; then
echo "Timeout waiting for services to be ready. Check the logs for more information."
docker-compose -f {{DOCKER_COMPOSE_FILE}} logs
exit 1
fi
echo "Still waiting... (${elapsed}s elapsed)"
sleep 5
done
echo "Celestia stack is up and running!"
celestia-down:
docker-compose -f {{DOCKER_COMPOSE_FILE}} down -v --remove-orphans
celestia-logs:
docker-compose -f {{DOCKER_COMPOSE_FILE}} logs -f
# Command to run integration tests with a fresh Docker setup
integration-test:
#!/usr/bin/env bash
set -euo pipefail
just celestia-up
echo "Running integration tests..."
if ! cargo test -p prism-tests --lib --release --features mock_prover; then
echo "Integration tests failed."
fi
just celestia-down
check:
@echo "Running cargo udeps..."
cargo +nightly udeps --all-features --all-targets
@echo "Running clippy..."
cargo clippy --all --all-targets -- -D warnings
build:
@echo "Building the project..."
cargo build --release
@echo "Building SP1..."
cd crates/zk/sp1 && cargo prove build
unit-test:
@echo "Running unit tests..."
cargo test --lib --release --features "mock_prover" -- --skip test_light_client_prover_talking
coverage:
#!/usr/bin/env bash
set -euo pipefail
just celestia-up
echo "Generating coverage report..."
if ! cargo llvm-cov nextest --html --output-dir coverage_report --lib --features "mock_prover" --release --workspace --exclude prism-cli --exclude-from-report prism-sp1 --ignore-filename-regex sp1; then
echo "Coverage report generation failed."
else
echo "Coverage report generated in 'coverage_report' directory"
fi
just celestia-down
install-deps:
#!/usr/bin/env bash
set -euo pipefail
echo "Installing project dependencies..."
unameOut="$(uname -s)" && \
case "${unameOut}" in \
Linux*) OS=Linux ;; \
Darwin*) OS=Mac ;; \
*) OS="UNKNOWN:${unameOut}" ;; \
esac
if [ "$OS" = "UNKNOWN:${unameOut}" ]; then \
echo "Unsupported operating system. This script only supports Linux and macOS. Please install dependencies manually."; \
exit 1; \
fi
# Install Redis if not present
if ! command -v redis-server > /dev/null; then \
echo "Installing Redis..."; \
if [ "$OS" = "Mac" ]; then \
if ! command -v brew > /dev/null; then \
echo "Homebrew is not installed. Please install Homebrew first."; \
exit 1; \
fi; \
brew install redis; \
elif [ "$OS" = "Linux" ]; then \
sudo apt update; \
sudo apt install redis-server -y; \
fi; \
echo "Redis installation complete!"; \
else \
echo "Redis is already installed."; \
fi
if ! command -v cargo prove > /dev/null; then \
echo "Installing SP1..."
curl -L https://sp1.succinct.xyz | bash; \
source ~/.bashrc || source ~/.bash_profile || source ~/.zshrc; \
echo "Running sp1up to install SP1 toolchain..."
sp1up
if command -v cargo prove > /dev/null; then \
echo "SP1 installation successful!"; \
cargo prove --version; \
else \
echo "SP1 installation may have failed. Please check and install manually if needed."; \
fi
else \
echo "SP1 is already installed."; \
fi
for tool in cargo-udeps cargo-llvm-cov cargo-nextest; do \
if ! command -v $tool > /dev/null; then \
echo "Installing $tool..."; \
cargo install $tool; \
else \
echo "$tool is already installed."; \
fi; \
done
echo "All dependencies installed successfully!"