|
| 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 |
0 commit comments