diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 24ff438..d64f2de 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,48 +2,35 @@ name: Nirvana CI on: push: - branches: [ "main" ] + branches: ["main"] pull_request: - branches: [ "main" ] + branches: ["main"] jobs: build: runs-on: ubuntu-latest steps: - # 1. Checkout repository - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - # 2. Install Rust Stable (Kembali ke stable agar tidak konflik flag nightly) - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true + uses: dtolnay/rust-toolchain@stable - # 3. Install Solana CLI - name: Install Solana CLI run: | - set -e - wget https://github.com/solana-labs/solana/releases/download/v1.18.15/solana-release-x86_64-unknown-linux-gnu.tar.bz2 - tar -xjf solana-release-x86_64-unknown-linux-gnu.tar.bz2 - echo "$PWD/solana-release/bin" >> $GITHUB_PATH - export PATH="$PWD/solana-release/bin:$PATH" + sh -c "$(curl -sSfL https://release.anza.xyz/v3.1.14/install)" + echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH - # 4. Install Anchor CLI - name: Install Anchor CLI run: | - cargo install --force anchor-cli --version 0.29.0 --no-default-features + cargo install --git https://github.com/coral-xyz/anchor anchor-cli --tag v1.0.0 --locked --force - # 5. Build Program dengan Force Clean - - name: Build Program + - name: Build program run: | - # Hapus semua Cargo.lock yang mungkin tersisa di folder manapun - find . -name "Cargo.lock" -type f -delete - - # Hapus cache cargo jika ada - cargo clean - - # Jalankan build murni tanpa membawa sisa-sisa lockfile dari lokal - anchor build \ No newline at end of file + CARGO_TARGET_DIR="$PWD/target" ANCHOR_IGNORE_KEYS=1 anchor build --ignore-keys + + - name: Verify artifacts + run: | + test -f target/deploy/nirvana.so + test -f target/idl/nirvana_protocol.json diff --git a/run-tests.sh b/run-tests.sh index e2225dc..3586990 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -1,12 +1,12 @@ #!/bin/bash set -e -# Use default Solana wallet -WALLET="/home/cokoo/.config/solana/id.json" +PROGRAM_ID="FxPnV48rg9KkK6huUimjcjL9H4xssM8n7j3uva8k9tmc" +WALLET="${ANCHOR_WALLET:-$HOME/.config/solana/id.json}" # Node 20+/26 treats yargs' extensionless CJS file as ESM because yargs ships # "type":"module", crashing mocha at startup ("require is not defined in ES -# module scope"). Dropping that field makes .js/extensionless load as CJS while +# module scope). Dropping that field makes .js/extensionless load as CJS while # .mjs stays ESM. Idempotent; re-applies after any `npm install`. YARGS_PKG="node_modules/yargs/package.json" if [ -f "$YARGS_PKG" ] && grep -q '"type": "module"' "$YARGS_PKG"; then @@ -17,17 +17,17 @@ fi pkill -f solana-test-validator 2>/dev/null || true sleep 2 -# Start validator -solana-test-validator --reset --quiet & +# Load program at the declared ID (keypair in target/deploy may not match declare_id). +solana-test-validator --reset --quiet \ + --bpf-program "$PROGRAM_ID" target/deploy/nirvana.so & VALIDATOR_PID=$! sleep 6 # Configure solana config set --url localhost --keypair "$WALLET" 2>/dev/null -# Fund and deploy +# Fund wallet for tx fees solana airdrop 100 2>/dev/null -solana program deploy target/deploy/nirvana.so --program-id target/deploy/nirvana-keypair.json 2>/dev/null # Run tests. Node 23+/26 strips TS types natively and runs .ts as ESM, which # bypasses ts-node and breaks type-only imports + __dirname. Disabling it routes