Skip to content

Commit db3c2f1

Browse files
committed
added initial justfile config together with readme
1 parent 5cc2d6c commit db3c2f1

File tree

2 files changed

+146
-0
lines changed

2 files changed

+146
-0
lines changed

examples/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,31 @@
11
# How to run
22

3+
## Quick Test with Just (Recommended) ⚡
4+
5+
The easiest way to test the complete PAPI workflow:
6+
7+
```bash
8+
# Install just (if not already installed)
9+
brew install just
10+
11+
# Run the complete test workflow (builds everything, starts all services, runs example)
12+
just
13+
14+
# Cleanup when done
15+
just cleanup
16+
```
17+
18+
**That's it!** This single `just` command handles everything:
19+
- ✅ Builds the bulletin chain
20+
- ✅ Installs npm dependencies
21+
- ✅ Starts IPFS daemon
22+
- ✅ Starts zombienet with bulletin chain
23+
- ✅ Connects IPFS to bulletin nodes
24+
- ✅ Generates PAPI descriptors
25+
- ✅ Runs the authorize and store example
26+
27+
## Manual Setup
28+
329
### Build Bulletin
430
```
531
git clone https://github.com/paritytech/polkadot-bulletin-chain.git

justfile

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# Polkadot Bulletin Chain - Just Commands
2+
# Install just: brew install just
3+
# Run `just --list` to see all available commands
4+
5+
# Default recipe - run the complete PAPI workflow test
6+
default: test-papi-flow
7+
8+
# Build the bulletin chain node in release mode
9+
build:
10+
cargo build --release -p polkadot-bulletin-chain
11+
12+
# Install JavaScript dependencies
13+
npm-install:
14+
npm install
15+
16+
# Clean build artifacts
17+
clean:
18+
cargo clean
19+
20+
# Test the complete PAPI workflow (builds, starts services, runs example)
21+
test-papi-flow: build npm-install
22+
#!/usr/bin/env bash
23+
set -e
24+
25+
echo "🚀 Starting complete PAPI workflow test..."
26+
echo ""
27+
28+
# Check if IPFS is available
29+
if ! command -v ipfs &> /dev/null; then
30+
echo "❌ IPFS not found. Using local kubo binary..."
31+
IPFS_CMD="./kubo/ipfs"
32+
if [ ! -f "$IPFS_CMD" ]; then
33+
echo "❌ Error: Neither system IPFS nor ./kubo/ipfs found."
34+
echo "Please install IPFS or download kubo to ./kubo/"
35+
exit 1
36+
fi
37+
else
38+
IPFS_CMD="ipfs"
39+
fi
40+
41+
# Initialize IPFS if needed
42+
if [ ! -d ~/.ipfs ]; then
43+
echo "📦 Initializing IPFS..."
44+
$IPFS_CMD init
45+
fi
46+
47+
# Start IPFS daemon in background
48+
echo "📡 Starting IPFS daemon..."
49+
$IPFS_CMD daemon > /tmp/ipfs-daemon.log 2>&1 &
50+
IPFS_PID=$!
51+
echo " IPFS PID: $IPFS_PID"
52+
sleep 3
53+
54+
# Start zombienet in background
55+
echo "⚡ Starting Bulletin chain with zombienet..."
56+
POLKADOT_BULLETIN_BINARY_PATH=./target/release/polkadot-bulletin-chain ./zombienet-macos-arm64 -p native spawn ./zombienet/bulletin-polkadot-local.toml > /tmp/zombienet.log 2>&1 &
57+
ZOMBIENET_PID=$!
58+
echo " Zombienet PID: $ZOMBIENET_PID"
59+
echo " Waiting for chain to start (15 seconds)..."
60+
sleep 15
61+
62+
# Start IPFS reconnect script in background
63+
echo "🔄 Starting IPFS reconnect script..."
64+
./scripts/ipfs-reconnect-solo.sh > /tmp/ipfs-reconnect.log 2>&1 &
65+
RECONNECT_PID=$!
66+
echo " Reconnect PID: $RECONNECT_PID"
67+
sleep 2
68+
69+
# Generate PAPI descriptors
70+
echo "🔧 Generating PAPI descriptors..."
71+
npm run papi:generate
72+
73+
# Run the example
74+
echo ""
75+
echo "🎯 Running authorize_and_store_papi.js example..."
76+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
77+
cd examples && node authorize_and_store_papi.js
78+
EXAMPLE_EXIT=$?
79+
80+
echo ""
81+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
82+
if [ $EXAMPLE_EXIT -eq 0 ]; then
83+
echo "✅ Example completed successfully!"
84+
else
85+
echo "❌ Example failed with exit code $EXAMPLE_EXIT"
86+
fi
87+
88+
echo ""
89+
echo "📋 Background processes:"
90+
echo " IPFS daemon: PID $IPFS_PID"
91+
echo " Zombienet: PID $ZOMBIENET_PID"
92+
echo " IPFS reconnect: PID $RECONNECT_PID"
93+
echo ""
94+
echo "🧹 To cleanup, run:"
95+
echo " kill $IPFS_PID $ZOMBIENET_PID $RECONNECT_PID"
96+
echo " or: just cleanup"
97+
echo ""
98+
echo "📝 Logs available at:"
99+
echo " /tmp/ipfs-daemon.log"
100+
echo " /tmp/zombienet.log"
101+
echo " /tmp/ipfs-reconnect.log"
102+
103+
# Save PIDs to file for cleanup
104+
echo "$IPFS_PID $ZOMBIENET_PID $RECONNECT_PID" > /tmp/bulletin-test-pids.txt
105+
106+
exit $EXAMPLE_EXIT
107+
108+
# Cleanup background processes from test-papi-flow
109+
cleanup:
110+
#!/usr/bin/env bash
111+
if [ -f /tmp/bulletin-test-pids.txt ]; then
112+
PIDS=$(cat /tmp/bulletin-test-pids.txt)
113+
echo "🧹 Stopping background processes: $PIDS"
114+
kill $PIDS 2>/dev/null || true
115+
rm /tmp/bulletin-test-pids.txt
116+
echo "✅ Cleanup complete!"
117+
else
118+
echo "⚠️ No saved PIDs found. Processes may still be running."
119+
echo "Check with: ps aux | grep -E 'ipfs|zombienet|ipfs-reconnect'"
120+
fi

0 commit comments

Comments
 (0)