Add a cargo-build-bpf right before anchor build #37
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
# From https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs#using-the-nodejs-starter-workflow | |
name: Node.js CI | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js 20.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows | |
# "On a cache miss, the action automatically creates a new cache if the job completes successfully." | |
# From Rust example at https://github.com/actions/cache/tree/main | |
- name: Restore Rust dependencies from Cache if possible | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo | |
target/ | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Install Rust | |
# https://stackoverflow.com/questions/57251508/run-rustups-curl-fetched-installer-script-non-interactively | |
run: | | |
curl https://sh.rustup.rs -sSf | sh -s -- -y | |
- name: Install Solana CLI (beta, required to fix 'ahash' issue) | |
run: | | |
sh -c "$(curl -sSfL https://release.solana.com/beta/install)" | |
echo "/home/runner/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH | |
# Remove '--force Force overwriting existing crates or binaries' | |
# As we want to use the cache if possible | |
- name: Install Anchor | |
run: | | |
cargo install --git https://github.com/coral-xyz/anchor avm --locked | |
avm install latest | |
avm use latest | |
echo "~/.avm/bin" >> $GITHUB_PATH | |
# git will keep outputting: | |
# hint: Using 'master' as the name for the initial branch. This default branch name | |
# hint: is subject to change. | |
# Unless we set this. | |
- name: Set a default branch name for git | |
run: | | |
git config --global init.defaultBranch main | |
# TODO: add | |
# cargo build-sbf --version | |
# but that is missing for some reason | |
- name: Check versions | |
run: | | |
echo $PATH | tr ':' '\n' | sort | |
solana -V | |
rustc -V | |
anchor -V | |
cargo --list --verbose | |
cargo search cargo-build-sbf | |
cargo install --list | |
ls -la /home/runner/.local/share/solana/install/active_release/bin | |
lsb_release -a | |
- name: Create a blank Anchor project | |
run: | | |
anchor init project | |
- name: Fix missing license warning | |
run: | | |
cd project | |
jq '.LICENSE = "UNLICENSED"' package.json > fixed-package.json | |
mv fixed-package.json package.json | |
- name: Fix unused variable warning | |
run: | | |
cd project | |
sed -i 's/ctx/_context/' programs/project/src/lib.rs | |
- name: Run anchor build | |
run: | | |
cd project | |
echo $PATH | tr ':' '\n' | sort | |
ls -la /home/runner/.local/share/solana/install/active_release/bin | |
cargo --list --verbose | |
cargo-build-bpf | |
anchor build | |
- name: Run anchor test | |
run: | | |
cd project | |
anchor test >> log.txt | |
- name: Check log for errors | |
run: | | |
cd project | |
cat log.txt | |
cat deleteme.txt| grep -qEv 'error|warn' |