-
Notifications
You must be signed in to change notification settings - Fork 4
Added justfile #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added justfile #111
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| # Polkadot Bulletin Chain - Just Commands | ||
| # Install just: brew install just | ||
| # Run `just --list` to see all available commands | ||
|
|
||
| # Default recipe - run the complete PAPI workflow test | ||
| default: authorize-and-store | ||
|
|
||
| # Build the bulletin chain node in release mode | ||
| build: | ||
| cargo build --release -p polkadot-bulletin-chain | ||
|
|
||
| # Install JavaScript dependencies | ||
| npm-install: | ||
| npm install | ||
|
|
||
| # Test the complete workflow (builds, starts services, runs example, shuts down services) | ||
| # Parameters: api=[papi|pjs] - choose between Polkadot API (papi) or Polkadot JS (pjs) | ||
| authorize-and-store api="papi": build npm-install | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think if we want to use this command in README we'd have to refactor that README significantly |
||
| #!/usr/bin/env bash | ||
| set -e | ||
|
|
||
| API_TYPE="{{ api }}" | ||
|
|
||
| if [[ "$API_TYPE" != "papi" && "$API_TYPE" != "pjs" ]]; then | ||
| echo "❌ Error: api parameter must be 'papi' or 'pjs'" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "🚀 Starting $API_TYPE workflow test..." | ||
| echo "" | ||
|
|
||
| # Check if IPFS is available | ||
| if ! command -v ipfs &> /dev/null; then | ||
| echo "❌ IPFS not found. Using local kubo binary..." | ||
| IPFS_CMD="./kubo/ipfs" | ||
| if [ ! -f "$IPFS_CMD" ]; then | ||
| echo "❌ Error: Neither system IPFS nor ./kubo/ipfs found." | ||
| echo "Please install IPFS or download kubo to ./kubo/" | ||
| exit 1 | ||
| fi | ||
| else | ||
| IPFS_CMD="ipfs" | ||
| fi | ||
|
|
||
| # Initialize IPFS if needed | ||
| if [ ! -d ~/.ipfs ]; then | ||
| echo "📦 Initializing IPFS..." | ||
| $IPFS_CMD init | ||
| fi | ||
|
|
||
| # Start IPFS daemon in background | ||
| echo "📡 Starting IPFS daemon..." | ||
| $IPFS_CMD daemon > /tmp/ipfs-daemon.log 2>&1 & | ||
| IPFS_PID=$! | ||
| echo " IPFS PID: $IPFS_PID" | ||
| sleep 2 | ||
|
|
||
| # Start zombienet in background | ||
| echo "⚡ Starting Bulletin chain with zombienet..." | ||
| POLKADOT_BULLETIN_BINARY_PATH=../target/release/polkadot-bulletin-chain ./$(ls zombienet-*-*) -p native spawn ./zombienet/bulletin-polkadot-local.toml > /tmp/zombienet.log 2>&1 & | ||
| ZOMBIENET_PID=$! | ||
| echo " Zombienet PID: $ZOMBIENET_PID" | ||
| echo " Waiting for chain to start (15 seconds)..." | ||
| sleep 15 | ||
|
|
||
| # Start IPFS reconnect script in background | ||
| echo "🔄 Starting IPFS reconnect script..." | ||
| ./scripts/ipfs-reconnect-solo.sh > /tmp/ipfs-reconnect.log 2>&1 & | ||
| RECONNECT_PID=$! | ||
| echo " Reconnect PID: $RECONNECT_PID" | ||
| sleep 2 | ||
|
|
||
| # Generate PAPI descriptors (only for papi) | ||
| if [ "$API_TYPE" == "papi" ]; then | ||
| echo "🔧 Generating PAPI descriptors..." | ||
| npm run papi:generate | ||
| fi | ||
|
|
||
| # Determine which example to run | ||
| if [ "$API_TYPE" == "papi" ]; then | ||
| EXAMPLE_FILE="authorize_and_store_papi.js" | ||
| else | ||
| EXAMPLE_FILE="authorize_and_store.js" | ||
| fi | ||
|
|
||
| # Run the example | ||
| echo "" | ||
| echo "🎯 Running $EXAMPLE_FILE example..." | ||
| echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" | ||
| node $EXAMPLE_FILE | ||
| EXAMPLE_EXIT=$? | ||
|
|
||
| echo "" | ||
| echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" | ||
| if [ $EXAMPLE_EXIT -eq 0 ]; then | ||
| echo "✅ Example completed successfully!" | ||
| else | ||
| echo "❌ Example failed with exit code $EXAMPLE_EXIT" | ||
| fi | ||
|
|
||
| echo "" | ||
| echo "📝 Logs available at:" | ||
| echo " /tmp/ipfs-daemon.log" | ||
| echo " /tmp/zombienet.log" | ||
| echo " /tmp/ipfs-reconnect.log" | ||
|
|
||
| # Clean up background processes | ||
| echo "🧹 Cleaning up background processes..." | ||
| kill $IPFS_PID $ZOMBIENET_PID $RECONNECT_PID 2>/dev/null || true | ||
|
|
||
|
|
||
| exit $EXAMPLE_EXIT | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. jfyi: newline is not needed here. I cross-checked with |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@x3c41a I am missing here some README.md update how to run/use this justfile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I thought the description would be enough.
Generally it's is as simple as
just <command>, e.g.just authorize-and-store.let me make a PR really quick...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#125