main.yml.njk 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. name: Main
  2. on:
  3. push:
  4. branches: [main]
  5. pull_request:
  6. branches: [main]
  7. env:
  8. NODE_VERSION: 18
  9. SOLANA_VERSION: {{ solanaVersion }}
  10. {% if programFramework === 'anchor' %}
  11. ANCHOR_VERSION: {{ anchorVersion }}
  12. {% endif %}
  13. jobs:
  14. format_and_lint_programs:
  15. name: Format & Lint Programs
  16. runs-on: ubuntu-latest
  17. steps:
  18. - name: Git Checkout
  19. uses: actions/checkout@v4
  20. - name: Setup Environment
  21. uses: ./.github/actions/setup
  22. with:
  23. clippy: true
  24. node: {% raw %}${{ env.NODE_VERSION }}{% endraw %}
  25. rustfmt: true
  26. - name: Format Programs
  27. run: pnpm programs:format
  28. - name: Lint Programs
  29. run: pnpm programs:lint
  30. {% if jsClient %}
  31. format_and_lint_client_js:
  32. name: Format & Lint Client JS
  33. runs-on: ubuntu-latest
  34. steps:
  35. - name: Git Checkout
  36. uses: actions/checkout@v4
  37. - name: Setup Environment
  38. uses: ./.github/actions/setup
  39. with:
  40. node: {% raw %}${{ env.NODE_VERSION }}{% endraw %}
  41. - name: Format Client JS
  42. run: pnpm clients:js:format
  43. - name: Lint Client JS
  44. run: pnpm clients:js:lint
  45. {% endif %}
  46. {% if rustClient %}
  47. format_and_lint_client_rust:
  48. name: Format & Lint Client Rust
  49. runs-on: ubuntu-latest
  50. steps:
  51. - name: Git Checkout
  52. uses: actions/checkout@v4
  53. - name: Setup Environment
  54. uses: ./.github/actions/setup
  55. with:
  56. clippy: true
  57. node: {% raw %}${{ env.NODE_VERSION }}{% endraw %}
  58. rustfmt: true
  59. - name: Format Client Rust
  60. run: pnpm clients:rust:format
  61. - name: Lint Client Rust
  62. run: pnpm clients:rust:lint
  63. {% endif %}
  64. build_programs:
  65. name: Build programs
  66. runs-on: ubuntu-latest
  67. needs: format_and_lint_programs
  68. steps:
  69. - name: Git Checkout
  70. uses: actions/checkout@v4
  71. - name: Setup Environment
  72. uses: ./.github/actions/setup
  73. with:
  74. cargo-cache-key: cargo-programs
  75. node: {% raw %}${{ env.NODE_VERSION }}{% endraw %}
  76. solana: {% raw %}${{ env.SOLANA_VERSION }}{% endraw %}
  77. {% if programFramework === 'anchor' %}
  78. anchor: {% raw %}${{ env.ANCHOR_VERSION }}{% endraw %}
  79. {% endif %}
  80. - name: Build Programs
  81. run: pnpm programs:build
  82. - name: Upload Program Builds
  83. uses: actions/upload-artifact@v4
  84. with:
  85. name: program-builds
  86. path: ./target/deploy/*.so
  87. if-no-files-found: error
  88. - name: Save Program Builds For Client Jobs
  89. uses: actions/cache/save@v4
  90. with:
  91. path: ./**/*.so
  92. key: {% raw %}${{ runner.os }}-builds-${{ github.sha }}{% endraw %}
  93. test_programs:
  94. name: Test Progams
  95. runs-on: ubuntu-latest
  96. needs: format_and_lint_programs
  97. steps:
  98. - name: Git Checkout
  99. uses: actions/checkout@v4
  100. - name: Setup Environment
  101. uses: ./.github/actions/setup
  102. with:
  103. cargo-cache-key: cargo-program-tests
  104. cargo-cache-fallback-key: cargo-programs
  105. node: {% raw %}${{ env.NODE_VERSION }}{% endraw %}
  106. solana: {% raw %}${{ env.SOLANA_VERSION }}{% endraw %}
  107. {% if programFramework === 'anchor' %}
  108. anchor: {% raw %}${{ env.ANCHOR_VERSION }}{% endraw %}
  109. {% endif %}
  110. - name: Test Programs
  111. run: pnpm programs:test
  112. generate_idls:
  113. name: Check IDL Generation
  114. runs-on: ubuntu-latest
  115. needs: format_and_lint_programs
  116. steps:
  117. - name: Git Checkout
  118. uses: actions/checkout@v4
  119. - name: Setup Environment
  120. uses: ./.github/actions/setup
  121. with:
  122. cargo-cache-key: cargo-programs
  123. cargo-cache-local-key: cargo-local
  124. node: {% raw %}${{ env.NODE_VERSION }}{% endraw %}
  125. {% if programFramework === 'anchor' %}
  126. anchor: {% raw %}${{ env.ANCHOR_VERSION }}{% endraw %}
  127. {% endif %}
  128. - name: Generate IDLs
  129. run: pnpm generate:idls
  130. - name: Check Working Directory
  131. run: |
  132. git status --porcelain
  133. test -z "$(git status --porcelain)"
  134. {% if clients.length > 0 %}
  135. generate_clients:
  136. name: Check Client Generation
  137. runs-on: ubuntu-latest
  138. needs: format_and_lint_programs
  139. steps:
  140. - name: Git Checkout
  141. uses: actions/checkout@v4
  142. - name: Setup Environment
  143. uses: ./.github/actions/setup
  144. with:
  145. node: {% raw %}${{ env.NODE_VERSION }}{% endraw %}
  146. rustfmt: true
  147. - name: Generate Clients
  148. run: pnpm generate:clients
  149. - name: Check Working Directory
  150. run: |
  151. git status --porcelain
  152. test -z "$(git status --porcelain)"
  153. {% endif %}
  154. {% if jsClient %}
  155. test_client_js:
  156. name: Test Client JS
  157. runs-on: ubuntu-latest
  158. needs: build_programs
  159. steps:
  160. - name: Git Checkout
  161. uses: actions/checkout@v4
  162. - name: Setup Environment
  163. uses: ./.github/actions/setup
  164. with:
  165. node: {% raw %}${{ env.NODE_VERSION }}{% endraw %}
  166. solana: {% raw %}${{ env.SOLANA_VERSION }}{% endraw %}
  167. - name: Restore Program Builds
  168. uses: actions/cache/restore@v4
  169. with:
  170. path: ./**/*.so
  171. key: {% raw %}${{ runner.os }}-builds-${{ github.sha }}{% endraw %}
  172. - name: Test Client JS
  173. run: pnpm clients:js:test
  174. {% endif %}
  175. {% if rustClient %}
  176. test_client_rust:
  177. name: Test Client Rust
  178. runs-on: ubuntu-latest
  179. needs: build_programs
  180. steps:
  181. - name: Git Checkout
  182. uses: actions/checkout@v4
  183. - name: Setup Environment
  184. uses: ./.github/actions/setup
  185. with:
  186. cargo-cache-key: cargo-rust-client
  187. node: {% raw %}${{ env.NODE_VERSION }}{% endraw %}
  188. solana: {% raw %}${{ env.SOLANA_VERSION }}{% endraw %}
  189. - name: Restore Program Builds
  190. uses: actions/cache/restore@v4
  191. with:
  192. path: ./**/*.so
  193. key: {% raw %}${{ runner.os }}-builds-${{ github.sha }}{% endraw %}
  194. - name: Test Client Rust
  195. run: pnpm clients:rust:test
  196. {% endif %}