Anchor #115
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: Anchor | |
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.8, beta] | |
anchor-version: [0.30.0] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
check-latest: true | |
- uses: heyAyushh/[email protected] | |
with: | |
solana-cli-version: ${{ matrix.solana-version }} | |
- run: solana block | |
shell: bash | |
- name: Install Anchor | |
run: | | |
solana -V | |
rustc -V | |
cargo install --git https://github.com/coral-xyz/anchor avm --locked --force | |
avm install ${{ matrix.anchor-version }} | |
avm use ${{ matrix.anchor-version }} | |
npm install --global pnpm | |
- name: Build Anchor programs | |
run: | | |
declare -a ProjectDirs=( | |
"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" | |
"tokens/token-2022/basics/anchor" | |
"tokens/token-2022/cpi-guard/anchor" | |
"tokens/token-2022/default-account-state/anchor" | |
"tokens/token-2022/group/anchor" | |
"tokens/token-2022/immutable-owner/anchor" | |
"tokens/token-2022/interest-bearing/anchor" | |
"tokens/token-2022/memo-transfer/anchor" | |
"tokens/token-2022/metadata/anchor" | |
"tokens/token-2022/mint-close-authority/anchor" | |
"tokens/token-2022/non-transferable/anchor" | |
"tokens/token-2022/permanent-delegate/anchor" | |
"tokens/token-2022/transfer-fee/anchor" | |
"tokens/token-2022/transfer-hook/anchor/TransferHookCounter" | |
"tokens/token-2022/transfer-hook/anchor/TransferHookHelloWorld" | |
"tokens/token-2022/transfer-hook/anchor/TransferHookTransferCost" | |
"tokens/token-2022/transfer-hook/anchor/TransferHookWhitelist" | |
) | |
for projectDir in "${ProjectDirs[@]}"; do | |
echo " | |
******** | |
Building $projectDir | |
********" | |
cd $projectDir | |
if anchor build; then | |
echo "Build succeeded for $projectDir." | |
rm -rf target | |
else | |
failed=true | |
failed_builds+=($projectDir) | |
echo "Build failed for $projectDir. 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.8, beta] | |
anchor-version: [0.30.0] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Anchor | |
uses: heyAyushh/[email protected] | |
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 ProjectDirs=( | |
"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" | |
"tokens/token-2022/basics/anchor" | |
"tokens/token-2022/cpi-guard/anchor" | |
"tokens/token-2022/default-account-state/anchor" | |
"tokens/token-2022/group/anchor" | |
"tokens/token-2022/immutable-owner/anchor" | |
"tokens/token-2022/interest-bearing/anchor" | |
"tokens/token-2022/memo-transfer/anchor" | |
"tokens/token-2022/metadata/anchor" | |
"tokens/token-2022/mint-close-authority/anchor" | |
"tokens/token-2022/non-transferable/anchor" | |
"tokens/token-2022/permanent-delegate/anchor" | |
"tokens/token-2022/transfer-fee/anchor" | |
"tokens/token-2022/transfer-hook/anchor/TransferHookCounter" | |
"tokens/token-2022/transfer-hook/anchor/TransferHookHelloWorld" | |
"tokens/token-2022/transfer-hook/anchor/TransferHookTransferCost" | |
"tokens/token-2022/transfer-hook/anchor/TransferHookWhitelist" | |
) | |
for projectDir in "${ProjectDirs[@]}"; do | |
echo " | |
******** | |
Testing $projectDir | |
********" | |
cd $projectDir | |
pnpm install --frozen-lockfile | |
if anchor test; then | |
echo "Tests succeeded for $projectDir." | |
rm -rf target node_modules | |
else | |
failed=true | |
failed_tests+=($projectDir) | |
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 |