solana-native.yml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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, beta]
  19. steps:
  20. - uses: actions/checkout@v4
  21. - name: Use Node.js ${{ matrix.node-version }}
  22. uses: actions/setup-node@v4
  23. with:
  24. node-version: ${{ matrix.node-version }}
  25. check-latest: true
  26. - uses: heyAyushh/setup-solana@v5.2
  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=($(find . -type d -name "native"| grep -v -f <(grep . .github/.ghaignore | grep -v '^$')))
  37. echo "Projects to Build:"
  38. printf "%s\n" "${ProjectDirs[@]}"
  39. for projectDir in "${ProjectDirs[@]}"; do
  40. echo "
  41. ********
  42. Building $projectDir
  43. ********"
  44. cd $projectDir
  45. if pnpm build; then
  46. echo "Build succeeded for $projectDir."
  47. else
  48. failed=true
  49. failed_builds+=($projectDir)
  50. echo "Build failed for $projectDir. Continuing with the next program."
  51. fi
  52. cd - > /dev/null
  53. done
  54. if [ "$failed" = true ]; then
  55. echo "Programs that failed building:"
  56. printf "%s\n" "${failed_builds[@]}"
  57. exit 1
  58. else
  59. echo "All programs built successfully."
  60. fi
  61. shell: bash
  62. test:
  63. runs-on: ubuntu-latest
  64. strategy:
  65. matrix:
  66. node-version: [20.x]
  67. solana-version: [1.17.25, stable, beta]
  68. steps:
  69. - uses: actions/checkout@v4
  70. - name: Use Node.js ${{ matrix.node-version }}
  71. uses: actions/setup-node@v4
  72. with:
  73. node-version: ${{ matrix.node-version }}
  74. check-latest: true
  75. - uses: heyAyushh/setup-solana@v5.2
  76. with:
  77. solana-cli-version: ${{ matrix.solana-version }}
  78. - run: solana block
  79. shell: bash
  80. - name: Install pnpm
  81. run: |
  82. npm install --global pnpm
  83. - name: Test solana native programs
  84. run: |
  85. solana -V
  86. rustc -V
  87. declare -a ProjectDirs=($(find . -type d -name "native"| grep -v -f <(grep . .github/.ghaignore | grep -v '^$')))
  88. echo "Projects to Test:"
  89. printf "%s\n" "${ProjectDirs[@]}"
  90. for projectDir in "${ProjectDirs[@]}"; do
  91. echo "
  92. ********
  93. Testing $projectDir
  94. ********"
  95. cd $projectDir
  96. pnpm install --frozen-lockfile
  97. if pnpm build-and-test; then
  98. echo "Tests succeeded for $projectDir."
  99. else
  100. failed=true
  101. failed_tests+=($projectDir)
  102. echo "Tests failed for $projectDir. Continuing with the next program."
  103. fi
  104. cd - > /dev/null
  105. done
  106. if [ "$failed" = true ]; then
  107. echo "*****************************"
  108. echo "Programs that failed testing:"
  109. printf "%s\n" "${failed_tests[@]}"
  110. exit 1
  111. else
  112. echo "All tests passed."
  113. fi
  114. shell: bash