ci: Add locked-in tool; fix violations #3643
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Solana CI | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| - dev | |
| # Cancel in-progress runs on new commits to same PR/branch | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: {} | |
| defaults: | |
| run: | |
| working-directory: ./solana | |
| jobs: | |
| # Linting runs on standard ubuntu runner (no need for tilt-kube-public) | |
| lint: | |
| name: Solana Lint | |
| runs-on: ubuntu-latest | |
| env: | |
| RUSTFLAGS: -Dwarnings | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| persist-credentials: false | |
| - name: Get rust toolchain version | |
| id: toolchain | |
| run: | | |
| RUST_VERSION="$(awk '/channel =/ { print substr($3, 2, length($3)-2) }' rust-toolchain)" | |
| echo "version=${RUST_VERSION}" >> $GITHUB_OUTPUT | |
| - name: Install rust toolchain | |
| uses: dtolnay/rust-toolchain@55c7845fad90d0ae8b2e83715cb900e5e861e8cb # zizmor: ignore[superfluous-actions] | |
| with: | |
| toolchain: ${{ steps.toolchain.outputs.version }} | |
| components: "clippy,rustfmt" | |
| - name: Cache Cargo dependencies | |
| uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2 | |
| with: | |
| workspaces: "solana" | |
| - name: Run `cargo fmt` | |
| run: cargo fmt --check --all --manifest-path Cargo.toml | |
| - name: Run `cargo check` | |
| run: cargo check --workspace --tests --manifest-path Cargo.toml --features mainnet | |
| - name: Run `cargo clippy` | |
| run: cargo clippy --workspace --tests --manifest-path Cargo.toml --features mainnet -- -Dclippy::cast_possible_truncation | |
| # SBF build and tests require Solana tools | |
| # Note: This doesn't need tilt-kube-public - standard ubuntu runner works fine | |
| solana-sbf: | |
| name: Solana Cargo SBF | |
| runs-on: ubuntu-latest | |
| env: | |
| RUSTFLAGS: -Dwarnings | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| persist-credentials: false | |
| - name: Free disk space | |
| run: sudo rm -rf /usr/local/lib/android | |
| - name: Get rust toolchain version | |
| id: toolchain | |
| run: | | |
| RUST_VERSION="$(awk '/channel =/ { print substr($3, 2, length($3)-2) }' rust-toolchain)" | |
| echo "version=${RUST_VERSION}" >> $GITHUB_OUTPUT | |
| - name: Get solana version | |
| id: solana | |
| run: | | |
| SOLANA_VERSION="$(awk '/solana-program =/ { print substr($3, 3, length($3)-3) }' Cargo.toml)" | |
| echo "version=${SOLANA_VERSION}" >> $GITHUB_OUTPUT | |
| - name: Restore cached SBF artifacts | |
| id: cache-sbf | |
| uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 | |
| with: | |
| path: solana/target/deploy | |
| key: solana-sbf-${{ steps.solana.outputs.version }}-${{ hashFiles('solana/Cargo.lock', 'solana/**/Cargo.toml', 'solana/programs/**/*.rs', 'solana/modules/**/*.rs') }} | |
| - name: Verify cache contains .so files | |
| id: verify-cache | |
| run: | | |
| if [ -d "target/deploy" ] && ls target/deploy/*.so 1>/dev/null 2>&1; then | |
| echo "Cache contains valid .so files" | |
| ls -la target/deploy/*.so | |
| echo "valid=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "Cache is empty or missing .so files, will rebuild" | |
| echo "valid=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Install rust toolchain | |
| uses: dtolnay/rust-toolchain@55c7845fad90d0ae8b2e83715cb900e5e861e8cb # zizmor: ignore[superfluous-actions] | |
| with: | |
| toolchain: ${{ steps.toolchain.outputs.version }} | |
| - name: Cache Cargo dependencies | |
| uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2 | |
| with: | |
| workspaces: "solana" | |
| - name: Cache solana tools | |
| id: cache-solana | |
| uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 | |
| env: | |
| cache-name: solana-tools | |
| with: | |
| path: | | |
| ~/.local/share/solana/install/ | |
| ~/.cache/solana/ | |
| key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ steps.solana.outputs.version }} | |
| - name: Install solana tools | |
| if: steps.cache-solana.outputs.cache-hit != 'true' | |
| env: | |
| SOLANA_VERSION: ${{ steps.solana.outputs.version }} | |
| run: | | |
| sh -c "$(curl -sSfL https://release.anza.xyz/v${SOLANA_VERSION}/install)" | |
| ~/.local/share/solana/install/active_release/bin/sdk/sbf/scripts/install.sh | |
| - name: Build SBF programs | |
| if: steps.verify-cache.outputs.valid != 'true' | |
| env: | |
| RUST_BACKTRACE: "1" | |
| run: | | |
| export BPF_OUT_DIR="$(pwd)/target/deploy" | |
| export PATH="${HOME}/.local/share/solana/install/active_release/bin:${PATH}" | |
| mkdir -p "${BPF_OUT_DIR}" | |
| cargo build-sbf --features "mainnet" | |
| - name: Save SBF artifacts to cache | |
| if: steps.verify-cache.outputs.valid != 'true' | |
| uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 | |
| with: | |
| path: solana/target/deploy | |
| key: solana-sbf-${{ steps.solana.outputs.version }}-${{ hashFiles('solana/Cargo.lock', 'solana/**/Cargo.toml', 'solana/programs/**/*.rs', 'solana/modules/**/*.rs') }} | |
| - name: Run tests in parallel | |
| env: | |
| RUST_BACKTRACE: "1" | |
| run: | | |
| export BPF_OUT_DIR="$(pwd)/target/deploy" | |
| export PATH="${HOME}/.local/share/solana/install/active_release/bin:${PATH}" | |
| # Run test-sbf for both packages in parallel, plus native tests | |
| cargo test-sbf -p "example-native-token-transfers" --features "mainnet" & | |
| pid1=$! | |
| cargo test-sbf -p "ntt-transceiver" --features "mainnet,testing" & | |
| pid2=$! | |
| cargo test --features "mainnet" & | |
| pid3=$! | |
| # Wait for all and capture exit codes | |
| wait $pid1 || exit 1 | |
| wait $pid2 || exit 1 | |
| wait $pid3 || exit 1 | |
| check-version: | |
| name: Check version | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| persist-credentials: false | |
| - run: ./scripts/sync-versions --check | |
| shell: bash | |
| anchor-test: | |
| name: Anchor Test | |
| runs-on: ubuntu-latest | |
| env: | |
| node-version: "24" | |
| solana-cli-version: "1.18.26" | |
| anchor-version: "0.29.0" | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| persist-credentials: false | |
| - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 | |
| with: | |
| bun-version: "1.3.4" | |
| - uses: ./.github/actions/setup-anchor | |
| with: | |
| anchor-version: ${{ env.anchor-version }} | |
| solana-cli-version: ${{ env.solana-cli-version }} | |
| node-version: ${{ env.node-version }} | |
| - name: Cache node_modules | |
| uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 | |
| with: | |
| path: ./solana/node_modules/ | |
| key: node-modules-${{ runner.os }}-build-${{ env.node-version }} | |
| - name: Install node_modules | |
| run: make node_modules | |
| shell: bash | |
| - name: Create keypair | |
| run: solana-keygen new --no-bip39-passphrase | |
| shell: bash | |
| - name: Make Anchor.toml compatible with runner | |
| run: sed -i 's:/user/:/runner/:' Anchor.toml | |
| shell: bash | |
| - name: Install Cargo toolchain | |
| uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1 # zizmor: ignore[archived-uses] | |
| with: | |
| toolchain: stable | |
| profile: minimal | |
| components: rustc | |
| - name: Cache Cargo dependencies | |
| uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2 | |
| with: | |
| workspaces: "solana" | |
| - name: Setup SDK | |
| run: make sdk | |
| shell: bash | |
| - name: Check idl | |
| run: | | |
| git diff --exit-code ts/idl | |
| - name: Set default Rust toolchain | |
| run: rustup default stable | |
| shell: bash | |
| - name: Run anchor lint | |
| run: make anchor-lint | |
| shell: bash | |
| - name: Run tests | |
| run: anchor test --skip-build | |
| shell: bash |