tests.yaml 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. name: Tests
  2. on:
  3. push:
  4. branches:
  5. - master
  6. pull_request:
  7. branches:
  8. - master
  9. env:
  10. SOLANA_CLI_VERSION: 1.8.0
  11. NODE_VERSION: 17.0.1
  12. jobs:
  13. test-core:
  14. name: Core Tests
  15. runs-on: ubuntu-18.04
  16. steps:
  17. - uses: actions/checkout@v2
  18. - uses: ./.github/actions/setup/
  19. - uses: actions/setup-node@v2
  20. with:
  21. node-version: ${{ env.NODE_VERSION }}
  22. - uses: actions/cache@v2
  23. name: Cache Cargo registry + index
  24. id: cache-cargo-build
  25. with:
  26. path: |
  27. ~/.cargo/bin/
  28. ~/.cargo/registry/index/
  29. ~/.cargo/registry/cache/
  30. ~/.cargo/git/db/
  31. ./target/
  32. key: cargo-${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
  33. - run: cargo build
  34. - run: cargo fmt -- --check
  35. - run: cargo clippy --all-targets -- -D warnings
  36. - run: cargo test
  37. - run: cd ts && yarn
  38. - run: cd ts && yarn test
  39. - run: cd ts && yarn lint
  40. setup-anchor-cli:
  41. name: Setup Anchor cli
  42. runs-on: ubuntu-18.04
  43. steps:
  44. - uses: actions/checkout@v2
  45. - uses: ./.github/actions/setup/
  46. - uses: actions/cache@v2
  47. name: Cache Cargo registry + index
  48. id: cache-anchor
  49. with:
  50. path: |
  51. ~/.cargo/bin/
  52. ~/.cargo/registry/index/
  53. ~/.cargo/registry/cache/
  54. ~/.cargo/git/db/
  55. ./target/
  56. key: cargo-${{ runner.os }}-anchor-${{ hashFiles('**/Cargo.lock') }}
  57. - run: cargo install --path cli anchor-cli --locked --force
  58. - uses: actions/upload-artifact@v2
  59. with:
  60. name: anchor-binary
  61. path: ~/.cargo/bin/anchor
  62. test-examples:
  63. needs: setup-anchor-cli
  64. name: Examples Test
  65. runs-on: ubuntu-18.04
  66. steps:
  67. - uses: actions/checkout@v2
  68. - uses: actions/download-artifact@v2
  69. with:
  70. name: anchor-binary
  71. path: ~/.cargo/bin/
  72. - run: chmod +rwx ~/.cargo/bin/anchor
  73. - uses: ./.github/actions/setup/
  74. - uses: ./.github/actions/setup-solana/
  75. - uses: ./.github/actions/setup-ts/
  76. - uses: actions/cache@v2
  77. name: basic-0 cache
  78. id: cache-basic-0
  79. with:
  80. path: ./examples/tutorial/basic-0/target
  81. key: cargo-${{ runner.os }}-${{ hashFiles('./examples/tutorial/basic-0/**/Cargo.toml') }}
  82. - uses: actions/cache@v2
  83. name: basic-1 cache
  84. id: cache-basic-1
  85. with:
  86. path: ./examples/tutorial/basic-1/target
  87. key: cargo-${{ runner.os }}-${{ hashFiles('./examples/tutorial/basic-1/**/Cargo.toml') }}
  88. - uses: actions/cache@v2
  89. name: basic-2 cache
  90. id: cache-basic-2
  91. with:
  92. path: ./examples/tutorial/basic-2/target
  93. key: cargo-${{ runner.os }}-${{ hashFiles('./examples/tutorial/basic-2/**/Cargo.toml') }}
  94. - uses: actions/cache@v2
  95. name: basic-3 cache
  96. id: cache-basic-3
  97. with:
  98. path: ./examples/tutorial/basic-3/target
  99. key: cargo-${{ runner.os }}-${{ hashFiles('./examples/tutorial/basic-3/**/Cargo.toml') }}
  100. - uses: actions/cache@v2
  101. name: basic-4 cache
  102. id: cache-basic-4
  103. with:
  104. path: ./examples/tutorial/basic-4/target
  105. key: cargo-${{ runner.os }}-${{ hashFiles('./examples/tutorial/basic-4/**/Cargo.toml') }}
  106. - run: cd examples/tutorial && yarn workspaces run test
  107. setup-client-example:
  108. needs: setup-anchor-cli
  109. name: Setup Client Example Test
  110. runs-on: ubuntu-18.04
  111. strategy:
  112. matrix:
  113. node:
  114. - path: tests/events/
  115. name: events.so
  116. - path: examples/tutorial/basic-4/
  117. name: basic_4.so
  118. - path: examples/tutorial/basic-2/
  119. name: basic_2.so
  120. - path: tests/composite/
  121. name: composite.so
  122. steps:
  123. - uses: actions/checkout@v2
  124. - uses: ./.github/actions/setup/
  125. - uses: ./.github/actions/setup-solana/
  126. - uses: actions/download-artifact@v2
  127. with:
  128. name: anchor-binary
  129. path: ~/.cargo/bin/
  130. - run: chmod +rwx ~/.cargo/bin/anchor
  131. - run: cd ${{ matrix.node.path }} && anchor build
  132. - uses: actions/upload-artifact@v2
  133. with:
  134. name: ${{ matrix.node.name }}
  135. path: ${{ matrix.node.path }}target/deploy/${{ matrix.node.name }}
  136. test-client-example:
  137. needs: setup-client-example
  138. name: Client Example Test
  139. runs-on: ubuntu-18.04
  140. steps:
  141. - uses: actions/checkout@v2
  142. - uses: ./.github/actions/setup/
  143. - uses: ./.github/actions/setup-ts/
  144. - uses: actions/download-artifact@v2
  145. with:
  146. name: anchor-binary
  147. path: ~/.cargo/bin/
  148. - uses: actions/download-artifact@v2
  149. with:
  150. name: events.so
  151. path: tests/events/target/deploy/
  152. - uses: actions/download-artifact@v2
  153. with:
  154. name: basic_4.so
  155. path: examples/tutorial/basic-4/target/deploy/
  156. - uses: actions/download-artifact@v2
  157. with:
  158. name: basic_2.so
  159. path: examples/tutorial/basic-2/target/deploy/
  160. - uses: actions/download-artifact@v2
  161. with:
  162. name: composite.so
  163. path: tests/composite/target/deploy/
  164. - uses: actions/cache@v2
  165. name: Cache client/example target
  166. id: cache-test-target
  167. with:
  168. path: client/example/target
  169. key: cargo-${{ runner.os }}-client/example-${{ env.ANCHOR_VERSION }}
  170. - uses: ./.github/actions/setup-solana/
  171. - run: cd client/example && ./run-test.sh
  172. test-programs:
  173. needs: setup-anchor-cli
  174. name: Test ${{ matrix.node.path }}
  175. runs-on: ubuntu-18.04
  176. strategy:
  177. matrix:
  178. node:
  179. - cmd: cd tests/sysvars && anchor test
  180. path: tests/sysvars
  181. - cmd: cd tests/composite && anchor test
  182. path: tests/composite
  183. - cmd: cd tests/errors && anchor test
  184. path: tests/errors
  185. - cmd: cd tests/spl/token-proxy && anchor test
  186. path: spl/token-proxy
  187. - cmd: cd tests/multisig && anchor test
  188. path: tests/multisig
  189. - cmd: cd tests/interface && anchor test
  190. path: tests/interface
  191. - cmd: cd tests/lockup && anchor test
  192. path: tests/lockup
  193. - cmd: cd tests/permissioned-markets/deps/serum-dex/dex && cargo build-bpf && cd ../../../ && anchor test
  194. path: tests/permissioned-markets
  195. - cmd: cd tests/swap/deps/serum-dex/dex && cargo build-bpf && cd ../../../ && anchor test
  196. path: tests/swap
  197. - cmd: cd tests/escrow && anchor test
  198. path: tests/escrow
  199. - cmd: cd tests/pyth && anchor test
  200. path: tests/pyth
  201. - cmd: cd tests/system-accounts && anchor test
  202. path: tests/system-accounts
  203. - cmd: cd tests/misc && anchor test
  204. path: tests/misc
  205. - cmd: cd tests/events && anchor test
  206. path: tests/events
  207. - cmd: cd tests/cashiers-check && anchor test
  208. path: tests/cashiers-check
  209. - cmd: cd tests/typescript && anchor test
  210. path: tests/typescript
  211. - cmd: cd tests/zero-copy && anchor test
  212. path: tests/zero-copy
  213. - cmd: cd tests/chat && anchor test
  214. path: tests/chat
  215. - cmd: cd tests/ido-pool && anchor test
  216. path: tests/ido-pool
  217. - cmd: cd tests/cfo && anchor run test-with-build
  218. path: tests/cfo
  219. steps:
  220. - uses: actions/checkout@v2
  221. - uses: ./.github/actions/setup/
  222. - uses: ./.github/actions/setup-ts/
  223. - uses: ./.github/actions/setup-solana/
  224. - uses: actions/cache@v2
  225. name: Cache Cargo registry + index
  226. id: cache-anchor
  227. with:
  228. path: |
  229. ~/.cargo/bin/
  230. ~/.cargo/registry/index/
  231. ~/.cargo/registry/cache/
  232. ~/.cargo/git/db/
  233. ./target/
  234. key: cargo-${{ runner.os }}-anchor-${{ hashFiles('**/Cargo.lock') }}
  235. - uses: actions/download-artifact@v2
  236. with:
  237. name: anchor-binary
  238. path: ~/.cargo/bin/
  239. - uses: actions/cache@v2
  240. name: Cache ${{ matrix.node.path }} target
  241. id: cache-test-target
  242. with:
  243. path: ${{ matrix.node.path }}/target
  244. key: cargo-${{ runner.os }}-${{ matrix.node.path }}-${{ env.ANCHOR_VERSION }}
  245. - run: ${{ matrix.node.cmd }}
  246. name: ${{ matrix.node.path }} program test