Skip to content

Commit 365ed41

Browse files
committed
Fix Solana CLI path in GitHub Actions workflows
1 parent 85707c8 commit 365ed41

File tree

5 files changed

+156
-8
lines changed

5 files changed

+156
-8
lines changed

.github/workflows/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,23 @@
2626
- **Rust:** Primary language for the Solana program
2727
- **Solana CLI:** For building and testing Solana programs
2828

29+
### Solana CLI Installation
30+
31+
The workflow automatically installs the Solana CLI using the following process:
32+
33+
```bash
34+
# Install Solana CLI tools
35+
sh -c "$(curl -sSfL https://release.solana.com/v1.16.0/install)"
36+
37+
# Add to GitHub Actions PATH
38+
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
39+
40+
# Also add to current shell session
41+
export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
42+
```
43+
44+
This ensures that the Solana binaries are available for all steps in the workflow that require them.
45+
2946
## Testnet Transaction Metrics Workflow
3047

3148
This workflow automates the process of running Tornado-SVM privacy solution transactions on Solana testnet and generating comprehensive metrics reports.
@@ -92,3 +109,18 @@ To manually trigger the workflow with custom parameters:
92109
4. Enter your desired parameters (denomination, Merkle tree height, RPC URL)
93110
5. Click "Run workflow"
94111
6. Once completed, download the artifacts from the workflow run
112+
113+
### Troubleshooting
114+
115+
#### Solana CLI Not Found
116+
117+
If you encounter the error `solana: command not found`, check the following:
118+
119+
1. Verify that the Solana CLI installation step completed successfully
120+
2. Check that the PATH is correctly set in each step that uses Solana commands
121+
3. The workflow now explicitly adds the Solana binaries to PATH in each step using:
122+
```bash
123+
export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
124+
```
125+
4. The transaction script has been enhanced to provide detailed diagnostic information when Solana is not found
126+
5. If problems persist, try using the `SOLANA_PATH` environment variable in the workflow step

.github/workflows/build.yml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,38 @@ jobs:
2727
with:
2828
components: rustfmt, clippy
2929

30-
- name: Install Solana tools
30+
- name: Install Solana CLI
3131
run: |
32+
# Install Solana CLI tools
3233
sh -c "$(curl -sSfL https://release.solana.com/v1.16.0/install)"
34+
# Add Solana to PATH for this job
3335
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
36+
# Also add to PATH for current shell session
37+
export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
38+
# Verify installation
3439
solana --version
3540
3641
- name: Build Solana program
37-
run: cargo build-bpf
42+
run: |
43+
# Ensure Solana binaries are in PATH
44+
export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
45+
# Try the newer cargo build-sbf command first, fall back to cargo build-bpf if not available
46+
if command -v cargo build-sbf &> /dev/null; then
47+
cargo build-sbf
48+
else
49+
cargo build-bpf
50+
fi
3851
3952
- name: Run Solana tests
40-
run: cargo test-bpf
53+
run: |
54+
# Ensure Solana binaries are in PATH
55+
export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
56+
# Try the newer cargo test-sbf command first, fall back to cargo test-bpf if not available
57+
if command -v cargo test-sbf &> /dev/null; then
58+
cargo test-sbf
59+
else
60+
cargo test-bpf
61+
fi
4162
4263
- name: Run Cargo Clippy
4364
run: cargo clippy -- -D warnings

.github/workflows/tornado_testnet_transaction.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,15 @@ jobs:
5050
sudo apt-get update
5151
sudo apt-get install -y libudev-dev libusb-1.0-0-dev pkg-config
5252
53-
- name: Install Solana Tool Suite
53+
- name: Install Solana CLI
5454
run: |
55+
# Install Solana CLI tools
5556
sh -c "$(curl -sSfL https://release.solana.com/v1.16.0/install)"
57+
# Add Solana to PATH for this job
5658
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
59+
# Also add to PATH for current shell session
60+
export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
61+
# Verify installation
5762
solana --version
5863
5964
- name: Install Rust
@@ -70,6 +75,8 @@ jobs:
7075
7176
- name: Generate keypair for testing
7277
run: |
78+
# Ensure Solana binaries are in PATH
79+
export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
7380
solana-keygen new --no-bip39-passphrase -o ~/.config/solana/id.json
7481
solana config set --url ${{ github.event.inputs.rpc_url || 'https://api.testnet.solana.com' }}
7582
echo "# Tornado SVM Testnet Transaction Report" > reports/transaction_report.md
@@ -87,6 +94,8 @@ jobs:
8794
8895
- name: Request airdrop
8996
run: |
97+
# Ensure Solana binaries are in PATH
98+
export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
9099
echo "## Solana Testnet Airdrop" >> reports/transaction_report.md
91100
echo "Requesting airdrop..." | tee -a reports/transaction_report.md
92101
solana airdrop 1 $(solana address) || true
@@ -122,12 +131,15 @@ jobs:
122131
123132
- name: Run Tornado transaction script with metrics
124133
run: |
134+
# Ensure Solana binaries are in PATH
135+
export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
125136
echo "## Transaction Log" >> reports/transaction_report.md
126137
echo "\`\`\`" >> reports/transaction_report.md
127138
cd scripts
128139
# Explicitly disabling telegram-related environment variables before running script
129140
export TELEGRAM_BOT_TOKEN=disabled TELEGRAM_CHAT_ID=disabled SKIP_TELEGRAM_NOTIFICATIONS=true
130-
./run_tornado_transaction_metrics.sh 2>&1 | tee -a ../reports/transaction_log.txt
141+
# Pass the Solana PATH to the script
142+
SOLANA_PATH="$HOME/.local/share/solana/install/active_release/bin" ./run_tornado_transaction_metrics.sh 2>&1 | tee -a ../reports/transaction_log.txt
131143
cat ../reports/transaction_log.txt >> ../reports/transaction_report.md
132144
echo "\`\`\`" >> reports/transaction_report.md
133145
env:
@@ -243,6 +255,8 @@ jobs:
243255
TELEGRAM_CHAT_ID: 'disabled'
244256
SKIP_TELEGRAM_NOTIFICATIONS: 'true'
245257
run: |
258+
# Ensure Solana binaries are in PATH
259+
export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
246260
echo "## Solana Network Metrics" >> reports/transaction_report.md
247261
echo "### Transaction Count" >> reports/transaction_report.md
248262
echo "\`\`\`" >> reports/transaction_report.md

docs/github_actions.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ This workflow handles the building, testing, and validation of the Tornado-SVM c
2929
- Uses the latest Rust toolchain for Solana program development
3030
- Uses Solana CLI tools for program building and testing
3131

32+
**Solana Environment Setup:**
33+
- The workflow automatically installs the Solana CLI tools version 1.16.0
34+
- Adds the Solana binary path to GitHub's PATH environment variable
35+
- Ensures each step that requires Solana commands has the proper PATH setting
36+
- Provides enhanced error reporting when Solana tools are not found
37+
3238
### Tornado Testnet Transaction Test
3339

3440
**File:** `.github/workflows/tornado_testnet_transaction.yml`
@@ -114,3 +120,43 @@ The workflow uses several custom scripts for capturing and analyzing metrics, ex
114120
- `format_report.js`: Formats metrics into a readable report
115121

116122
Developers can modify these scripts to capture additional metrics or change how they're presented in the report.
123+
124+
## Troubleshooting
125+
126+
### Common Issues
127+
128+
#### Solana CLI Not Found
129+
130+
If your workflow fails with the error `solana: command not found`, check the following:
131+
132+
1. **Verify installation:** Make sure the Solana CLI installation step completed successfully in the logs
133+
134+
2. **Check PATH configuration:** Each step that uses Solana commands should include:
135+
```bash
136+
export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
137+
```
138+
139+
3. **Installation log:** Look for output from the Solana installation command:
140+
```
141+
sh -c "$(curl -sSfL https://release.solana.com/v1.16.0/install)"
142+
```
143+
144+
4. **Enhanced diagnostics:** The `run_tornado_transaction.sh` script now includes enhanced diagnostics when Solana is not found, including checking common installation locations
145+
146+
5. **Fix:** If needed, you can pass the `SOLANA_PATH` environment variable to the script execution step
147+
148+
#### Solana Build Command Not Found
149+
150+
If you encounter issues with Solana build commands (either `cargo build-bpf` or `cargo build-sbf`), check that:
151+
152+
1. The workflow tries both the newer `build-sbf` and older `build-bpf` commands
153+
2. The Rust toolchain is properly installed
154+
3. Solana build tools are in the PATH
155+
156+
#### Transaction Failures
157+
158+
If transactions on testnet fail, common causes include:
159+
160+
1. **Airdrop limits:** Testnet has airdrop limits; check if the airdrop succeeded
161+
2. **Testnet stability:** Testnet can occasionally be unstable; try re-running the workflow
162+
3. **RPC errors:** If using a custom RPC URL, verify it's working correctly

scripts/run_tornado_transaction.sh

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/bin/bash
22
set -e
33

4+
# If SOLANA_PATH is set, add it to PATH
5+
if [ -n "$SOLANA_PATH" ]; then
6+
echo "Adding Solana binaries to PATH: $SOLANA_PATH"
7+
export PATH="$SOLANA_PATH:$PATH"
8+
fi
9+
410
# Colors for output
511
GREEN='\033[0;32m'
612
YELLOW='\033[1;33m'
@@ -9,12 +15,25 @@ NC='\033[0m' # No Color
915

1016
echo -e "${GREEN}Starting Tornado Cash Privacy Solution Transaction Script${NC}"
1117

12-
# Check if solana is installed
18+
# Check if solana is installed and print more debugging information if not found
1319
if ! command -v solana &> /dev/null; then
14-
echo "Error: Solana CLI is not installed. Please install it first."
20+
echo "Error: Solana CLI is not installed or not in PATH."
21+
echo "Current PATH: $PATH"
22+
echo "Please install Solana CLI or ensure it's in your PATH."
23+
24+
# Check for common Solana CLI locations
25+
for dir in "$HOME/.local/share/solana/install/active_release/bin" "/usr/local/bin" "/usr/bin"; do
26+
if [ -f "$dir/solana" ]; then
27+
echo "Found solana in $dir but it's not in PATH. Try adding: export PATH=\"$dir:\$PATH\""
28+
fi
29+
done
30+
1531
exit 1
1632
fi
1733

34+
# Print Solana version for debugging
35+
echo "Using Solana version: $(solana --version)"
36+
1837
# Check if the tornado-cli.js exists
1938
if [ ! -f "../client/tornado-cli.js" ]; then
2039
echo "Error: tornado-cli.js not found. Make sure you're running this script from the scripts directory."
@@ -56,14 +75,30 @@ cd ../scripts
5675
echo -e "${YELLOW}Step 3: Building and deploying the program...${NC}"
5776
cd ..
5877
echo "Building the program..."
78+
79+
# Print Rust and cargo info for debugging
80+
echo "Rust version: $(rustc --version)"
81+
echo "Cargo version: $(cargo --version)"
82+
83+
# Check for Solana BPF tools
84+
echo "Checking for Solana BPF/SBF tools..."
85+
for cmd in "cargo build-sbf" "cargo build-bpf"; do
86+
if command -v $cmd &> /dev/null; then
87+
echo "Found $cmd"
88+
fi
89+
done
90+
5991
# Try the newer cargo build-sbf command first, fall back to cargo build-bpf if not available
6092
if command -v cargo build-sbf &> /dev/null; then
93+
echo "Using cargo build-sbf..."
6194
cargo build-sbf || { echo -e "${RED}Error: Failed to build the program.${NC}"; exit 1; }
6295
else
96+
echo "Using cargo build-bpf..."
6397
cargo build-bpf || { echo -e "${RED}Error: Failed to build the program.${NC}"; exit 1; }
6498
fi
6599

66100
echo "Deploying the program..."
101+
echo "Using solana from: $(which solana)"
67102
DEPLOY_OUTPUT=$(solana program deploy target/deploy/tornado_svm.so)
68103
PROGRAM_ID=$(echo "$DEPLOY_OUTPUT" | grep "Program Id:" | awk '{print $3}')
69104

@@ -224,4 +259,4 @@ echo "Recipient balance: $RECIPIENT_BALANCE SOL"
224259
echo -e "${YELLOW}Cleaning up...${NC}"
225260
echo "No cleanup needed for testnet"
226261

227-
echo -e "${GREEN}Script completed!${NC}"
262+
echo -e "${GREEN}Script completed!${NC}"

0 commit comments

Comments
 (0)