Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
165 changes: 129 additions & 36 deletions .github/workflows/anchor.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,146 @@
name: Anchor Build
name: Anchor

on:
schedule:
- cron: '0 0 1 * *'
- cron: '0 0 * * *'
push:
branches:
- main
pull_request:
types: [ opened, synchronize, reopened ]
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]
solana-version: [1.17.25]
anchor-version: [0.29.0]
steps:
- uses: actions/checkout@v2

- name: Install dependencies
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
check-latest: true
- uses: metadaoproject/setup-solana@v1.0
with:
solana-cli-version: ${{ matrix.solana-version }}
- run: solana block
shell: bash
- name: Install Anchor
run: |
sh -c "$(curl -sSfL https://release.solana.com/stable/install)"
export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
solana -V
rustc -V
sudo apt-get update && sudo apt-get upgrade && sudo apt-get install -y pkg-config build-essential libudev-dev libssl-dev
cargo install --git https://github.com/coral-xyz/anchor avm --locked --force
avm install latest
avm use latest
avm install ${{ matrix.anchor-version }}
avm use ${{ matrix.anchor-version }}
npm install --global pnpm
- name: Build Anchor programs
run: |
declare -a StringArray=(
"basics/account-data/anchor"
"basics/checking-accounts/anchor"
"basics/close-account/anchor"
"basics/counter/anchor"
"basics/create-account/anchor"
"basics/hello-solana/anchor"
"basics/pda-rent-payer/anchor"
"basics/processing-instructions/anchor"
"basics/program-derived-addresses/anchor"
"basics/realloc/anchor"
"basics/rent/anchor"
"basics/repository-layout/anchor"
"basics/transfer-sol/anchor"
)
for val in "${StringArray[@]}"; do
echo "
********
Building $val
********"
cd $val
if anchor build; then
echo "Build succeeded for $val."
else
failed=true
failed_builds+=($val)
echo "Build failed for $val. Continuing with the next program."
fi
cd - > /dev/null
done
if [ "$failed" = true ]; then
echo "Programs that failed building:"
printf "%s\n" "${failed_builds[@]}"
exit 1
else
echo "All programs built successfully."
fi
shell: bash

test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
solana-version: [1.18.4]
anchor-version: [0.29.0]
steps:
- uses: actions/checkout@v4
- name: Setup Anchor
uses: metadaoproject/setup-anchor@v2
with:
anchor-version: ${{ matrix.anchor-version }}
solana-cli-version: ${{ matrix.solana-version }}
node-version: ${{ matrix.node-version }}
- name: Display versions
run: |
solana -V
solana-keygen new --no-bip39-passphrase
rustc -V
anchor -V
npm i -g pnpm
- name: Test anchor programs
run: |
declare -a StringArray=(
"basics/checking-accounts/anchor"
"basics/close-account/anchor"
"basics/counter/anchor"
"basics/create-account/anchor"
"basics/hello-solana/anchor"
"basics/pda-rent-payer/anchor"
"basics/processing-instructions/anchor"
"basics/program-derived-addresses/anchor"
"basics/realloc/anchor"
"basics/rent/anchor"
"basics/repository-layout/anchor"
"basics/transfer-sol/anchor"
"compression/cnft-vault/anchor"
"oracles/pyth/anchor"
"tokens/create-token/anchor"
"tokens/nft-minter/anchor"
"tokens/pda-mint-authority/anchor"
"tokens/spl-token-minter/anchor"
"tokens/token-2022/basics/anchor"
"tokens/transfer-tokens/anchor"
"basics/account-data/anchor"
"basics/account-data/anchor"
"basics/checking-accounts/anchor"
"basics/close-account/anchor"
"basics/counter/anchor"
"basics/create-account/anchor"
"basics/hello-solana/anchor"
"basics/pda-rent-payer/anchor"
"basics/processing-instructions/anchor"
"basics/program-derived-addresses/anchor"
"basics/realloc/anchor"
"basics/rent/anchor"
"basics/repository-layout/anchor"
"basics/transfer-sol/anchor"
)
for val in "${StringArray[@]}"; do
echo "Building $val..."
cd $val
anchor build
cd - > /dev/null
echo "
********
Testing $val
********"
cd $val
pnpm install --frozen-lockfile
if anchor test; then
echo "Tests succeeded for $val."
else
failed=true
failed_tests+=($val)
echo "Tests failed for $val. Continuing with the next program."
fi
cd - > /dev/null
done
if [ "$failed" = true ]; then
echo "*****************************"
echo "Programs that failed testing:"
printf "%s\n" "${failed_tests[@]}"
exit 1
else
echo "All tests passed."
fi
shell: bash
52 changes: 0 additions & 52 deletions .github/workflows/native.yml

This file was deleted.

140 changes: 140 additions & 0 deletions .github/workflows/solana-native.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: Native

on:
schedule:
- cron: '0 0 * * *'
push:
branches:
- main
pull_request:
types: [ opened, synchronize, reopened ]
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
solana-version: ['1.18.4']
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
check-latest: true
- uses: metadaoproject/setup-solana@v1.0
with:
solana-cli-version: ${{ matrix.solana-version }}
- run: solana block
shell: bash
- name: Install pnpm
run: |
npm install --global pnpm
- name: Build Native programs
run: |
declare -a StringArray=(
"basics/account-data/native/program"
"basics/checking-accounts/native/program"
"basics/close-account/native/program"
"basics/counter/native/program"
"basics/create-account/native/program"
"basics/hello-solana/native/program"
"basics/pda-rent-payer/native/program"
"basics/processing-instructions/native/program"
"basics/program-derived-addresses/native/program"
"basics/realloc/native/program"
"basics/rent/native/program"
"basics/repository-layout/native/program"
"basics/transfer-sol/native/program"
)
for val in "${StringArray[@]}"; do
echo "
********
Building $val
********"
cd $val
if cargo-build-sbf --verbose; then
echo "Build succeeded for $val."
else
failed=true
failed_builds+=($val)
echo "Build failed for $val. Continuing with the next program."
fi
cd - > /dev/null
done
if [ "$failed" = true ]; then
echo "Programs that failed building:"
printf "%s\n" "${failed_builds[@]}"
exit 1
else
echo "All programs built successfully."
fi
shell: bash

test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
solana-version: ['1.18.4']
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
check-latest: true
- uses: metadaoproject/setup-solana@v1.0
with:
solana-cli-version: ${{ matrix.solana-version }}
- run: solana block
shell: bash
- name: Install pnpm
run: |
npm install --global pnpm
- name: Test solana native programs
run: |
solana -V
rustc -V
declare -a StringArray=(
"basics/account-data/native/"
"basics/checking-accounts/native/"
"basics/close-account/native/"
"basics/counter/native/"
"basics/create-account/native/"
"basics/hello-solana/native/"
"basics/pda-rent-payer/native/"
"basics/processing-instructions/native/"
"basics/program-derived-addresses/native/"
"basics/rent/native/"
"basics/repository-layout/native/"
"basics/transfer-sol/native/"
)
for val in "${StringArray[@]}"; do
echo "
********
Testing $val
********"
cd $val
pnpm install --frozen-lockfile
if (cargo build-sbf --manifest-path=./program/Cargo.toml --sbf-out-dir=./tests/fixtures && pnpm test); then
echo "Tests succeeded for $val."
else
failed=true
failed_tests+=($val)
echo "Tests failed for $val. Continuing with the next program."
fi
cd - > /dev/null
done
if [ "$failed" = true ]; then
echo "*****************************"
echo "Programs that failed testing:"
printf "%s\n" "${failed_tests[@]}"
# exit 1
else
echo "All tests passed."
fi
shell: bash
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ test-ledger/
**/*/.anchor
**/*/.DS_Store
**/*/target
**/*/tests/fixtures
**/*.rs.bk
**/*/test-ledger
**/*/yarn.lock
Expand Down
Loading