solana: Add tilt and docker targets for Anchor testing #43
Workflow file for this run
This file contains 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 | |
jobs: | |
solana-sbf: | |
name: Solana Cargo SBF | |
runs-on: ubuntu-20.04 | |
env: | |
RUSTFLAGS: -Dwarnings | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get rust toolchain version | |
id: toolchain | |
run: | | |
RUST_VERSION="$(awk '/channel =/ { print substr($3, 2, length($3)-2) }' solana/rust-toolchain)" | |
echo "::set-output name=version::${RUST_VERSION}" | |
- name: Get solana version | |
id: solana | |
run: | | |
SOLANA_VERSION="$(awk '/solana-program =/ { print substr($3, 3, length($3)-3) }' solana/Cargo.toml)" | |
echo "::set-output name=version::${SOLANA_VERSION}" | |
- name: Cache rust toolchain | |
uses: actions/cache@v3 | |
env: | |
cache-name: solana-toolchain | |
with: | |
path: | | |
~/.cargo/bin | |
~/.rustup | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ steps.toolchain.outputs.version }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- name: Install rust toolchain | |
uses: dtolnay/rust-toolchain@55c7845fad90d0ae8b2e83715cb900e5e861e8cb | |
with: | |
toolchain: ${{ steps.toolchain.outputs.version }} | |
components: "clippy,rustfmt" | |
- name: Cache rust packages / build cache | |
uses: actions/cache@v3 | |
env: | |
cache-name: solana-rust-packages | |
with: | |
path: | | |
~/.cargo/bin | |
~/.cargo/registry | |
~/.cargo/git/db | |
solana/target | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('solana/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- name: Run `cargo fmt` | |
run: cargo fmt --check --all --manifest-path solana/Cargo.toml | |
- name: Run `cargo check` | |
run: cargo check --workspace --tests --manifest-path solana/Cargo.toml | |
- name: Run `cargo clippy` | |
run: cargo clippy --workspace --tests --manifest-path solana/Cargo.toml | |
- name: Cache solana tools | |
id: cache-solana | |
uses: actions/cache@v3 | |
env: | |
cache-name: solana-tools | |
with: | |
path: | | |
~/.local/share/solana/install/ | |
~/.cache/solana/ | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ steps.solana.outputs.version }} | |
- if: ${{ steps.cache-solana.outputs.cache-hit != 'true' }} | |
name: Install solana tools | |
env: | |
SOLANA_VERSION: ${{ steps.solana.outputs.version }} | |
run: | | |
sh -c "$(curl -sSfL https://release.solana.com/v${SOLANA_VERSION}/install)" | |
~/.local/share/solana/install/active_release/bin/sdk/sbf/scripts/install.sh | |
- name: cargo build-sbf && cargo test-sbf | |
env: | |
RUST_BACKTRACE: "1" | |
run: | | |
cd solana | |
export BPF_OUT_DIR="$(pwd)/target/deploy" | |
export PATH="${HOME}/.local/share/solana/install/active_release/bin:${PATH}" | |
mkdir -p "${BPF_OUT_DIR}" | |
BPF_PACKAGES=( | |
programs/example-native-token-transfers/Cargo.toml | |
programs/wormhole-governance/Cargo.toml | |
) | |
for p in "${BPF_PACKAGES[@]}"; do | |
cargo build-sbf --manifest-path "${p}" | |
done | |
for p in "${BPF_PACKAGES[@]}"; do | |
cargo test-sbf --manifest-path "${p}" | |
done | |
anchor-test: | |
name: Anchor Test | |
runs-on: ubuntu-latest | |
# Anchor Docker image: https://www.anchor-lang.com/docs/verifiable-builds#images | |
container: backpackapp/build:v0.29.0 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set default Rust toolchain | |
run: rustup default stable | |
working-directory: ./solana | |
- name: anchor test --arch sbf | |
run: make anchor-test | |
working-directory: ./solana |