Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 108 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: Setup Environment
description: Setup Rust, Solana CLI, and optionally Node.js for testing

inputs:
example:
description: "Example directory path"
required: true
node-version:
description: "Node.js version to install (optional)"
required: false
default: ""
node-version-default:
description: "Default Node.js version for Light CLI"
required: false
default: "22"
solana-cli-version:
description: "Solana CLI version"
required: false
default: "2.3.11"
rust-toolchain:
description: "Rust toolchain version"
required: false
default: "1.90.0"
anchor-version:
description: "Anchor CLI version (for TypeScript tests)"
required: false
default: "0.31.1"
photon-indexer:
description: "Install Photon indexer (required for TypeScript tests)"
required: false
default: "false"

runs:
using: composite
steps:
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ inputs.rust-toolchain }}
cache-workspaces: ${{ inputs.example }}

- name: Setup Node.js
if: inputs.node-version != ''
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}

- name: Setup Node.js (for Light CLI)
if: inputs.node-version == ''
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version-default }}

- name: Cache Solana CLI tools
uses: actions/cache@v4
with:
path: |
~/.cache/solana/
~/.local/share/solana/
key: solana-cli-${{ runner.os }}-build-${{ inputs.solana-cli-version }}

- name: Install Solana CLI tools
shell: bash
run: |
if [[ "${{ inputs.solana-cli-version }}" == 1* ]]; then
cd $HOME
wget -q https://github.com/solana-labs/solana/releases/download/v${{ inputs.solana-cli-version }}/solana-release-x86_64-unknown-linux-gnu.tar.bz2
tar jxf solana-release-x86_64-unknown-linux-gnu.tar.bz2
echo "$HOME/solana-release/bin" >> $GITHUB_PATH
else
sh -c "$(curl -sSfL https://release.anza.xyz/v${{ inputs.solana-cli-version }}/install)"
echo "/home/runner/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
fi

- name: Install Anchor CLI
if: inputs.node-version != ''
shell: bash
run: |
cargo install --git https://github.com/coral-xyz/anchor avm --locked --force
avm install ${{ inputs.anchor-version }}
avm use ${{ inputs.anchor-version }}

- name: Install Light CLI
shell: bash
run: npm install -g @lightprotocol/zk-compression-cli

- name: Install Photon indexer
if: inputs.photon-indexer == 'true'
shell: bash
env:
RUSTFLAGS: "-A dead-code"
run: cargo install --git https://github.com/lightprotocol/photon.git --rev 49b7e7f0d668babbc4d65fe8a0a7236df76f75a8 --locked

- name: Generate keypair
shell: bash
run: solana-keygen new --no-bip39-passphrase

- name: Display versions
shell: bash
run: |
rustc --version
cargo --version
solana --version
light --version
if [ -n "${{ inputs.node-version }}" ]; then
node --version
npm --version
fi
44 changes: 44 additions & 0 deletions .github/workflows/rust-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Rust

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
SOLANA_CLI_VERSION: "2.3.11"
RUST_TOOLCHAIN: "1.90.0"

jobs:
test-rust:
name: ${{ matrix.example }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
example:
- create-and-update
- counter/native
- counter/pinocchio
- account-comparison
steps:
- uses: actions/checkout@v4

- name: Setup environment
uses: ./.github/actions/setup
with:
example: ${{ matrix.example }}
solana-cli-version: ${{ env.SOLANA_CLI_VERSION }}
rust-toolchain: ${{ env.RUST_TOOLCHAIN }}

- name: Build and test
working-directory: ${{ matrix.example }}
run: cargo test-sbf
63 changes: 63 additions & 0 deletions .github/workflows/typescript-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Anchor

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
SOLANA_CLI_VERSION: "2.3.11"
RUST_TOOLCHAIN: "1.90.0"
NODE_VERSION: "22"

jobs:
test-typescript:
name: ${{ matrix.example }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
example:
- counter/anchor
steps:
- uses: actions/checkout@v4

- name: Setup environment
uses: ./.github/actions/setup
with:
example: ${{ matrix.example }}
node-version: ${{ env.NODE_VERSION }}
solana-cli-version: ${{ env.SOLANA_CLI_VERSION }}
rust-toolchain: ${{ env.RUST_TOOLCHAIN }}
photon-indexer: 'true'

- name: Install dependencies
working-directory: ${{ matrix.example }}
run: npm install

- name: Build and sync program ID
working-directory: ${{ matrix.example }}
run: anchor build

- name: Test sbf
working-directory: ${{ matrix.example }}
run: cargo test-sbf

- name: Start test validator
working-directory: ${{ matrix.example }}
run: |
PROGRAM_ID=$(grep -A 1 "\[programs.localnet\]" Anchor.toml | grep "counter" | sed 's/.*"\(.*\)".*/\1/')
light test-validator --sbf-program "$PROGRAM_ID" ./target/deploy/counter.so &
sleep 10

- name: Run TypeScript tests
working-directory: ${{ matrix.example }}
run: anchor test --skip-local-validator --skip-build --skip-deploy
Loading