solana-native.yml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. name: Native
  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.18.4]
  19. steps:
  20. - uses: actions/checkout@v4
  21. - name: Use Node.js ${{ matrix.node-version }}
  22. uses: actions/setup-node@v3
  23. with:
  24. node-version: ${{ matrix.node-version }}
  25. check-latest: true
  26. - uses: heyAyushh/setup-solana@v5.1
  27. with:
  28. solana-cli-version: ${{ matrix.solana-version }}
  29. - run: solana block
  30. shell: bash
  31. - name: Install pnpm
  32. run: |
  33. npm install --global pnpm
  34. - name: Build Native programs
  35. run: |
  36. declare -a ProjectDirs=(
  37. "basics/account-data/native/program"
  38. "basics/checking-accounts/native/program"
  39. "basics/close-account/native/program"
  40. "basics/counter/native/program"
  41. "basics/create-account/native/program"
  42. "basics/hello-solana/native/program"
  43. "basics/pda-rent-payer/native/program"
  44. "basics/processing-instructions/native/program"
  45. "basics/program-derived-addresses/native/program"
  46. "basics/realloc/native/program"
  47. "basics/rent/native/program"
  48. "basics/repository-layout/native/program"
  49. "basics/transfer-sol/native/program"
  50. )
  51. for projectDir in "${ProjectDirs[@]}"; do
  52. echo "
  53. ********
  54. Building $projectDir
  55. ********"
  56. cd $projectDir
  57. if cargo-build-sbf --verbose; then
  58. echo "Build succeeded for $projectDir."
  59. else
  60. failed=true
  61. failed_builds+=($projectDir)
  62. echo "Build failed for $projectDir. Continuing with the next program."
  63. fi
  64. cd - > /dev/null
  65. done
  66. if [ "$failed" = true ]; then
  67. echo "Programs that failed building:"
  68. printf "%s\n" "${failed_builds[@]}"
  69. exit 1
  70. else
  71. echo "All programs built successfully."
  72. fi
  73. shell: bash
  74. test:
  75. runs-on: ubuntu-latest
  76. strategy:
  77. matrix:
  78. node-version: [20.x]
  79. solana-version: [stable, 1.18.4]
  80. steps:
  81. - uses: actions/checkout@v4
  82. - name: Use Node.js ${{ matrix.node-version }}
  83. uses: actions/setup-node@v3
  84. with:
  85. node-version: ${{ matrix.node-version }}
  86. check-latest: true
  87. - uses: heyAyushh/setup-solana@v5.1
  88. with:
  89. solana-cli-version: ${{ matrix.solana-version }}
  90. - run: solana block
  91. shell: bash
  92. - name: Install pnpm
  93. run: |
  94. npm install --global pnpm
  95. - name: Test solana native programs
  96. run: |
  97. solana -V
  98. rustc -V
  99. declare -a ProjectDirs=(
  100. "basics/account-data/native/"
  101. "basics/checking-accounts/native/"
  102. "basics/close-account/native/"
  103. "basics/counter/native/"
  104. "basics/create-account/native/"
  105. "basics/hello-solana/native/"
  106. "basics/pda-rent-payer/native/"
  107. "basics/processing-instructions/native/"
  108. "basics/program-derived-addresses/native/"
  109. "basics/rent/native/"
  110. "basics/repository-layout/native/"
  111. "basics/transfer-sol/native/"
  112. )
  113. for projectDir in "${ProjectDirs[@]}"; do
  114. echo "
  115. ********
  116. Testing $projectDir
  117. ********"
  118. cd $projectDir
  119. pnpm install --frozen-lockfile
  120. if (cargo build-sbf --manifest-path=./program/Cargo.toml --sbf-out-dir=./tests/fixtures && pnpm test); then
  121. echo "Tests succeeded for $projectDir."
  122. else
  123. failed=true
  124. failed_tests+=($projectDir)
  125. echo "Tests failed for $projectDir. Continuing with the next program."
  126. fi
  127. cd - > /dev/null
  128. done
  129. if [ "$failed" = true ]; then
  130. echo "*****************************"
  131. echo "Programs that failed testing:"
  132. printf "%s\n" "${failed_tests[@]}"
  133. # exit 1
  134. else
  135. echo "All tests passed."
  136. fi
  137. shell: bash