Skip to content

larpy dev for issue #5 #31

larpy dev for issue #5

larpy dev for issue #5 #31

Workflow file for this run

name: build
on:
push:
branches: ['*']
tags: ['v[0-9]+.[0-9]+.[0-9]+']
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install dependencies
run: bun install
# Rust setup and build with explicit update to latest version
- name: Install and Update Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Update Cargo to latest stable
run: |
# Update to the latest stable Rust toolchain
rustup update stable
rustup default stable
# Check Cargo version explicitly
cargo --version
echo "Using Cargo from: $(which cargo)"
# Ensure we can handle Cargo.lock version 4
CARGO_VERSION=$(cargo --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
echo "Cargo version: $CARGO_VERSION"
# Check if Cargo version is new enough for lock file version 4
MAJOR=$(echo "$CARGO_VERSION" | cut -d'.' -f1)
MINOR=$(echo "$CARGO_VERSION" | cut -d'.' -f2)
if [ "$MAJOR" -lt 1 ] || ([ "$MAJOR" -eq 1 ] && [ "$MINOR" -lt 70 ]); then
echo "Warning: Cargo version $CARGO_VERSION may not fully support Cargo.lock version 4 format"
echo "Attempting to update Cargo again"
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable --profile minimal
source "$HOME/.cargo/env"
cargo --version
else
echo "Cargo $CARGO_VERSION supports Cargo.lock version 4 format"
fi
- name: Regenerate Cargo.lock
run: |
# Remove any existing Cargo.lock
if [ -f Cargo.lock ]; then
echo "Removing existing Cargo.lock"
rm Cargo.lock
fi
# Regenerate Cargo.lock with the latest Cargo version
echo "Regenerating Cargo.lock"
cargo generate-lockfile
echo "Cargo.lock regenerated successfully"
# Verify the Cargo.lock format
if [ -f Cargo.lock ]; then
echo "Checking Cargo.lock format..."
# Quick check to see if it's a version 4 format (contains version = 4)
if grep -q 'version = 4' Cargo.lock; then
echo "Confirmed: Cargo.lock is using version 4 format"
else
echo "Warning: Cargo.lock may not be using version 4 format"
# For debugging purposes, show the first few lines
head -5 Cargo.lock
fi
else
echo "Error: Cargo.lock was not generated!"
exit 1
fi
- name: Install Solana CLI
run: |
# Install Solana CLI tools
sh -c "$(curl -sSfL https://release.solana.com/v1.16.0/install)"
# Add Solana to PATH for this job
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
# Also add to PATH for current shell session
export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
# Verify installation
solana --version
- name: Build Solana program
run: |
# Ensure Solana binaries are in PATH
export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
# Try the newer cargo build-sbf command first, fall back to cargo build-bpf if not available
# First check if the commands are directly available
if cargo build-sbf --help &> /dev/null; then
echo "Using cargo build-sbf"
cargo build-sbf
elif cargo build-bpf --help &> /dev/null; then
echo "Using cargo build-bpf"
cargo build-bpf
else
echo "Installing Solana BPF/SBF tools..."
solana-install update
# Add Solana's .cargo/bin to PATH (where cargo-build-bpf is installed)
export PATH="$HOME/.cargo/bin:$PATH"
# Try again after update
if cargo build-sbf --help &> /dev/null; then
echo "Using cargo build-sbf after update"
cargo build-sbf
else
echo "Using cargo build-bpf after update"
cargo build-bpf
fi
fi
- name: Run Solana tests
run: |
# Ensure Solana binaries are in PATH
export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
export PATH="$HOME/.cargo/bin:$PATH"
# Try the newer cargo test-sbf command first, fall back to cargo test-bpf if not available
if cargo test-sbf --help &> /dev/null; then
echo "Using cargo test-sbf"
cargo test-sbf
elif cargo test-bpf --help &> /dev/null; then
echo "Using cargo test-bpf"
cargo test-bpf
else
echo "Installing Solana BPF/SBF tools..."
solana-install update
# Add Solana's .cargo/bin to PATH (where cargo-test-bpf is installed)
export PATH="$HOME/.cargo/bin:$PATH"
# Try again after update
if cargo test-sbf --help &> /dev/null; then
echo "Using cargo test-sbf after update"
cargo test-sbf
else
echo "Using cargo test-bpf after update"
cargo test-bpf
fi
fi
- name: Run Cargo Clippy
run: cargo clippy -- -D warnings
- name: Build client
run: cd client && bun install
- name: Run client tests
run: cd client && bun test