Skip to content

Commit 22d388c

Browse files
authored
chore: bump dep v0.15.0, add ci (#8)
* chore: bump deps * chore: add ci * make tests serial
1 parent 576da0e commit 22d388c

File tree

21 files changed

+8028
-3468
lines changed

21 files changed

+8028
-3468
lines changed

.github/actions/setup/action.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Setup Environment
2+
description: Setup Rust, Solana CLI, and optionally Node.js for testing
3+
4+
inputs:
5+
example:
6+
description: "Example directory path"
7+
required: true
8+
node-version:
9+
description: "Node.js version to install (optional)"
10+
required: false
11+
default: ""
12+
node-version-default:
13+
description: "Default Node.js version for Light CLI"
14+
required: false
15+
default: "22"
16+
solana-cli-version:
17+
description: "Solana CLI version"
18+
required: false
19+
default: "2.3.11"
20+
rust-toolchain:
21+
description: "Rust toolchain version"
22+
required: false
23+
default: "1.90.0"
24+
anchor-version:
25+
description: "Anchor CLI version (for TypeScript tests)"
26+
required: false
27+
default: "0.31.1"
28+
photon-indexer:
29+
description: "Install Photon indexer (required for TypeScript tests)"
30+
required: false
31+
default: "false"
32+
33+
runs:
34+
using: composite
35+
steps:
36+
- name: Install Rust toolchain
37+
uses: actions-rust-lang/setup-rust-toolchain@v1
38+
with:
39+
toolchain: ${{ inputs.rust-toolchain }}
40+
cache-workspaces: ${{ inputs.example }}
41+
42+
- name: Setup Node.js
43+
if: inputs.node-version != ''
44+
uses: actions/setup-node@v4
45+
with:
46+
node-version: ${{ inputs.node-version }}
47+
48+
- name: Setup Node.js (for Light CLI)
49+
if: inputs.node-version == ''
50+
uses: actions/setup-node@v4
51+
with:
52+
node-version: ${{ inputs.node-version-default }}
53+
54+
- name: Cache Solana CLI tools
55+
uses: actions/cache@v4
56+
with:
57+
path: |
58+
~/.cache/solana/
59+
~/.local/share/solana/
60+
key: solana-cli-${{ runner.os }}-build-${{ inputs.solana-cli-version }}
61+
62+
- name: Install Solana CLI tools
63+
shell: bash
64+
run: |
65+
if [[ "${{ inputs.solana-cli-version }}" == 1* ]]; then
66+
cd $HOME
67+
wget -q https://github.com/solana-labs/solana/releases/download/v${{ inputs.solana-cli-version }}/solana-release-x86_64-unknown-linux-gnu.tar.bz2
68+
tar jxf solana-release-x86_64-unknown-linux-gnu.tar.bz2
69+
echo "$HOME/solana-release/bin" >> $GITHUB_PATH
70+
else
71+
sh -c "$(curl -sSfL https://release.anza.xyz/v${{ inputs.solana-cli-version }}/install)"
72+
echo "/home/runner/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
73+
fi
74+
75+
- name: Install Anchor CLI
76+
if: inputs.node-version != ''
77+
shell: bash
78+
run: |
79+
cargo install --git https://github.com/coral-xyz/anchor avm --locked --force
80+
avm install ${{ inputs.anchor-version }}
81+
avm use ${{ inputs.anchor-version }}
82+
83+
- name: Install Light CLI
84+
shell: bash
85+
run: npm install -g @lightprotocol/zk-compression-cli
86+
87+
- name: Install Photon indexer
88+
if: inputs.photon-indexer == 'true'
89+
shell: bash
90+
env:
91+
RUSTFLAGS: "-A dead-code"
92+
run: cargo install --git https://github.com/lightprotocol/photon.git --rev 49b7e7f0d668babbc4d65fe8a0a7236df76f75a8 --locked
93+
94+
- name: Generate keypair
95+
shell: bash
96+
run: solana-keygen new --no-bip39-passphrase
97+
98+
- name: Display versions
99+
shell: bash
100+
run: |
101+
rustc --version
102+
cargo --version
103+
solana --version
104+
light --version
105+
if [ -n "${{ inputs.node-version }}" ]; then
106+
node --version
107+
npm --version
108+
fi

.github/workflows/rust-tests.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Rust
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types: [opened, synchronize, reopened]
9+
branches:
10+
- main
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
env:
17+
SOLANA_CLI_VERSION: "2.3.11"
18+
RUST_TOOLCHAIN: "1.90.0"
19+
20+
jobs:
21+
test-rust:
22+
name: ${{ matrix.example }}
23+
runs-on: ubuntu-latest
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
example:
28+
- create-and-update
29+
- counter/native
30+
- counter/pinocchio
31+
- account-comparison
32+
steps:
33+
- uses: actions/checkout@v4
34+
35+
- name: Setup environment
36+
uses: ./.github/actions/setup
37+
with:
38+
example: ${{ matrix.example }}
39+
solana-cli-version: ${{ env.SOLANA_CLI_VERSION }}
40+
rust-toolchain: ${{ env.RUST_TOOLCHAIN }}
41+
42+
- name: Build and test
43+
working-directory: ${{ matrix.example }}
44+
run: cargo test-sbf
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Anchor
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types: [opened, synchronize, reopened]
9+
branches:
10+
- main
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
env:
17+
SOLANA_CLI_VERSION: "2.3.11"
18+
RUST_TOOLCHAIN: "1.90.0"
19+
NODE_VERSION: "22"
20+
21+
jobs:
22+
test-typescript:
23+
name: ${{ matrix.example }}
24+
runs-on: ubuntu-latest
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
example:
29+
- counter/anchor
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- name: Setup environment
34+
uses: ./.github/actions/setup
35+
with:
36+
example: ${{ matrix.example }}
37+
node-version: ${{ env.NODE_VERSION }}
38+
solana-cli-version: ${{ env.SOLANA_CLI_VERSION }}
39+
rust-toolchain: ${{ env.RUST_TOOLCHAIN }}
40+
photon-indexer: 'true'
41+
42+
- name: Install dependencies
43+
working-directory: ${{ matrix.example }}
44+
run: npm install
45+
46+
- name: Build and sync program ID
47+
working-directory: ${{ matrix.example }}
48+
run: anchor build
49+
50+
- name: Test sbf
51+
working-directory: ${{ matrix.example }}
52+
run: cargo test-sbf
53+
54+
- name: Start test validator
55+
working-directory: ${{ matrix.example }}
56+
run: |
57+
PROGRAM_ID=$(grep -A 1 "\[programs.localnet\]" Anchor.toml | grep "counter" | sed 's/.*"\(.*\)".*/\1/')
58+
light test-validator --sbf-program "$PROGRAM_ID" ./target/deploy/counter.so &
59+
sleep 10
60+
61+
- name: Run TypeScript tests
62+
working-directory: ${{ matrix.example }}
63+
run: anchor test --skip-local-validator --skip-build --skip-deploy

0 commit comments

Comments
 (0)