Add the ability to update the favorites, and a test! #96
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 and Solana CI | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
# See https://github.com/metaDAOproject/setup-anchor for docs | |
- uses: metadaoproject/[email protected] | |
with: | |
anchor-version: "latest" | |
# Install Solana CLI (beta, required to fix 'ahash' issue) | |
solana-cli-version: "1.18.5" | |
node-version: "20.12.2" | |
# 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 | |
- name: Print versions and debugging info | |
run: | | |
echo Linux version: | |
lsb_release -a | |
echo Solana version: | |
solana -V | |
echo Anchor version: | |
anchor -V | |
echo build-sbf version: | |
cargo build-sbf --version | |
echo Path: | |
echo $PATH | tr ':' '\n' | sort | |
# Fixes: | |
# Error: Unable to read keypair file | |
# during 'anchor test' | |
- name: Make a default keypair | |
run: | | |
solana-keygen new --no-bip39-passphrase | |
# Fix: | |
# warning: tool `rust-analyzer` is already installed, remove it from `/home/runner/.cargo/bin`, then run `rustup update` to have rustup manage this tool. | |
# warning: tool `rustfmt` is already installed, remove it from `/home/runner/.cargo/bin`, then run `rustup update` to have rustup manage this tool. | |
# warning: tool `cargo-fmt` is already installed, remove it from `/home/runner/.cargo/bin`, then run `rustup update` to have rustup manage this tool. | |
- name: Fix already installed tools | |
run: | | |
rm /home/runner/.cargo/bin/rust-analyzer /home/runner/.cargo/bin/rustfmt /home/runner/.cargo/bin/cargo-fmt | |
rustup update | |
- name: Create a blank Anchor project, apply fixes, build and test it | |
# TODO: fixes the following warning: | |
# warning: package `project v0.1.0 (/home/runner/work/project/project)` does not have a license | |
# Ideally 'npm config get init-license' should be used to set the license for new projects | |
# | |
# TODO: Fix unused variable warning | |
# | |
# TODO: fixes: | |
# error: package `solana-program v1.18.11` cannot be built because it requires rustc 1.75.0 or newer, while the currently active rustc version is 1.72.0-dev | |
# should not be necessary | |
run: | | |
anchor init project | |
cd project | |
echo "----------------------------------------" | |
echo "Fixing package.json..." | |
jq '.license = "UNLICENSED"' package.json > fixed-package.json | |
mv fixed-package.json package.json | |
cat package.json | |
echo "----------------------------------------" | |
echo "Fixing solana-program crate not using semver issue..." | |
sed -i 's/ctx/_context/' programs/project/src/lib.rs | |
cargo add solana-program@"=1.18.5" | |
echo "----------------------------------------" | |
echo "Installing packages..." | |
npm i | |
echo "----------------------------------------" | |
echo "Running 'anchor test'..." | |
anchor test 2>&1 | tee -a build.log | |
echo "----------------------------------------" | |
echo "build.log..." | |
cat build.log | |
echo "----------------------------------------" | |
echo "Checking for errors or warnings in build.log..." | |
grep -qiEvz 'error:|warning:|failed' build.log | |
echo $? | |
- name: Test the Favorites project builds and tests pass | |
run: | | |
cd labs/favorites | |
echo "----------------------------------------" | |
echo "Creating a keypair..." | |
solana-keygen new --no-bip39-passphrase -s -o deleteme.json | |
echo SECRET_KEY="$(cat deleteme.json)"> .env | |
cat .env | |
echo "----------------------------------------" | |
echo "Installing packages..." | |
npm i | |
echo "----------------------------------------" | |
echo "Running 'anchor test'..." | |
anchor test 2>&1 | tee -a build.log | |
echo "----------------------------------------" | |
echo "build.log..." | |
cat build.log | |
echo "----------------------------------------" | |
echo "Checking for errors or warnings in build.log..." | |
grep -qiEvz 'error:|warning:|failed' build.log | |
echo $? |