anchor.yml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. name: Anchor
  2. on:
  3. schedule:
  4. - cron: "0 0 * * *"
  5. push:
  6. branches:
  7. - main
  8. pull_request:
  9. types: [opened, synchronize, reopened]
  10. branches:
  11. - main
  12. jobs:
  13. build:
  14. runs-on: ubuntu-latest
  15. strategy:
  16. matrix:
  17. node-version: [20.x]
  18. solana-version: [stable, 1.17.25]
  19. anchor-version: [0.30.0]
  20. steps:
  21. - uses: actions/checkout@v4
  22. - name: Use Node.js ${{ matrix.node-version }}
  23. uses: actions/setup-node@v4
  24. with:
  25. node-version: ${{ matrix.node-version }}
  26. check-latest: true
  27. - uses: heyAyushh/setup-solana@v5.1
  28. with:
  29. solana-cli-version: ${{ matrix.solana-version }}
  30. - run: solana block
  31. shell: bash
  32. - name: Install Anchor
  33. run: |
  34. solana -V
  35. rustc -V
  36. cargo install --git https://github.com/coral-xyz/anchor avm --locked --force
  37. avm install ${{ matrix.anchor-version }}
  38. avm use ${{ matrix.anchor-version }}
  39. npm install --global pnpm
  40. - name: Build Anchor programs
  41. run: |
  42. declare -a ProjectDirs=(
  43. "basics/account-data/anchor"
  44. "basics/checking-accounts/anchor"
  45. "basics/close-account/anchor"
  46. "basics/counter/anchor"
  47. "basics/create-account/anchor"
  48. "basics/hello-solana/anchor"
  49. "basics/pda-rent-payer/anchor"
  50. "basics/processing-instructions/anchor"
  51. "basics/program-derived-addresses/anchor"
  52. "basics/realloc/anchor"
  53. "basics/rent/anchor"
  54. "basics/repository-layout/anchor"
  55. "basics/transfer-sol/anchor"
  56. )
  57. for projectDir in "${ProjectDirs[@]}"; do
  58. echo "
  59. ********
  60. Building $projectDir
  61. ********"
  62. cd $projectDir
  63. if anchor build; then
  64. echo "Build succeeded for $projectDir."
  65. else
  66. failed=true
  67. failed_builds+=($projectDir)
  68. echo "Build failed for $projectDir. Continuing with the next program."
  69. fi
  70. cd - > /dev/null
  71. done
  72. if [ "$failed" = true ]; then
  73. echo "Programs that failed building:"
  74. printf "%s\n" "${failed_builds[@]}"
  75. exit 1
  76. else
  77. echo "All programs built successfully."
  78. fi
  79. shell: bash
  80. test:
  81. runs-on: ubuntu-latest
  82. strategy:
  83. matrix:
  84. node-version: [20.x]
  85. solana-version: [1.18.8, beta]
  86. anchor-version: [0.30.0]
  87. steps:
  88. - uses: actions/checkout@v4
  89. - name: Setup Anchor
  90. uses: heyAyushh/setup-anchor@v2.2
  91. with:
  92. anchor-version: ${{ matrix.anchor-version }}
  93. solana-cli-version: ${{ matrix.solana-version }}
  94. node-version: ${{ matrix.node-version }}
  95. - name: Display versions
  96. run: |
  97. solana -V
  98. solana-keygen new --no-bip39-passphrase
  99. rustc -V
  100. anchor -V
  101. npm i -g pnpm
  102. - name: Test anchor programs
  103. run: |
  104. declare -a ProjectDirs=(
  105. "basics/account-data/anchor"
  106. "basics/checking-accounts/anchor"
  107. "basics/close-account/anchor"
  108. "basics/counter/anchor"
  109. "basics/create-account/anchor"
  110. "basics/hello-solana/anchor"
  111. "basics/pda-rent-payer/anchor"
  112. "basics/processing-instructions/anchor"
  113. "basics/program-derived-addresses/anchor"
  114. "basics/realloc/anchor"
  115. "basics/rent/anchor"
  116. "basics/repository-layout/anchor"
  117. "basics/transfer-sol/anchor"
  118. )
  119. for projectDir in "${ProjectDirs[@]}"; do
  120. echo "
  121. ********
  122. Testing $projectDir
  123. ********"
  124. cd $projectDir
  125. pnpm install --frozen-lockfile
  126. if anchor test; then
  127. echo "Tests succeeded for $projectDir."
  128. else
  129. failed=true
  130. failed_tests+=($projectDir)
  131. echo "Tests failed for $val. Continuing with the next program."
  132. fi
  133. cd - > /dev/null
  134. done
  135. if [ "$failed" = true ]; then
  136. echo "*****************************"
  137. echo "Programs that failed testing:"
  138. printf "%s\n" "${failed_tests[@]}"
  139. exit 1
  140. else
  141. echo "All tests passed."
  142. fi
  143. shell: bash