tests.yaml 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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-bpf-upgradeable-state:
  173. needs: setup-anchor-cli
  174. name: Test tests/bpf-upgradeable-state
  175. runs-on: ubuntu-18.04
  176. steps:
  177. - uses: actions/checkout@v2
  178. - uses: ./.github/actions/setup/
  179. - uses: ./.github/actions/setup-ts/
  180. - uses: ./.github/actions/setup-solana/
  181. - uses: actions/cache@v2
  182. name: Cache Cargo registry + index
  183. id: cache-anchor
  184. with:
  185. path: |
  186. ~/.cargo/bin/
  187. ~/.cargo/registry/index/
  188. ~/.cargo/registry/cache/
  189. ~/.cargo/git/db/
  190. ./target/
  191. key: cargo-${{ runner.os }}-anchor-${{ hashFiles('**/Cargo.lock') }}
  192. - uses: actions/download-artifact@v2
  193. with:
  194. name: anchor-binary
  195. path: ~/.cargo/bin/
  196. - uses: actions/cache@v2
  197. name: Cache tests/bpf-upgradeable-state target
  198. id: cache-test-target
  199. with:
  200. path: tests/bpf-upgradeable-state/target
  201. key: cargo-${{ runner.os }}-tests/bpf-upgradeable-state-${{ env.ANCHOR_VERSION }}
  202. - run: solana-test-validator -r --quiet &
  203. name: start validator
  204. - run: cd tests/bpf-upgradeable-state && yarn
  205. - run: cd tests/bpf-upgradeable-state && yarn link @project-serum/anchor
  206. - run: cd tests/bpf-upgradeable-state && anchor build
  207. - run: cd tests/bpf-upgradeable-state && solana program deploy --program-id program_with_different_programdata.json target/deploy/bpf_upgradeable_state.so
  208. - run: cd tests/bpf-upgradeable-state && cp bpf_upgradeable_state-keypair.json target/deploy/bpf_upgradeable_state-keypair.json && anchor deploy && anchor test --skip-deploy --skip-build
  209. test-programs:
  210. needs: setup-anchor-cli
  211. name: Test ${{ matrix.node.path }}
  212. runs-on: ubuntu-18.04
  213. strategy:
  214. matrix:
  215. node:
  216. - cmd: cd tests/sysvars && anchor test
  217. path: tests/sysvars
  218. - cmd: cd tests/composite && anchor test
  219. path: tests/composite
  220. - cmd: cd tests/errors && anchor test
  221. path: tests/errors
  222. - cmd: cd tests/spl/token-proxy && anchor test
  223. path: spl/token-proxy
  224. - cmd: cd tests/multisig && anchor test
  225. path: tests/multisig
  226. - cmd: cd tests/interface && anchor test
  227. path: tests/interface
  228. - cmd: cd tests/lockup && anchor test
  229. path: tests/lockup
  230. - cmd: cd tests/swap/deps/serum-dex/dex && cargo build-bpf && cd ../../../ && anchor test
  231. path: tests/swap
  232. - cmd: cd tests/escrow && anchor test
  233. path: tests/escrow
  234. - cmd: cd tests/pyth && anchor test
  235. path: tests/pyth
  236. - cmd: cd tests/system-accounts && anchor test
  237. path: tests/system-accounts
  238. - cmd: cd tests/misc && anchor test
  239. path: tests/misc
  240. - cmd: cd tests/events && anchor test
  241. path: tests/events
  242. - cmd: cd tests/cashiers-check && anchor test
  243. path: tests/cashiers-check
  244. - cmd: cd tests/typescript && anchor test
  245. path: tests/typescript
  246. - cmd: cd tests/zero-copy && anchor test
  247. path: tests/zero-copy
  248. - cmd: cd tests/chat && anchor test
  249. path: tests/chat
  250. - cmd: cd tests/ido-pool && anchor test
  251. path: tests/ido-pool
  252. - cmd: cd tests/cfo && anchor run test-with-build
  253. path: tests/cfo
  254. steps:
  255. - uses: actions/checkout@v2
  256. - uses: ./.github/actions/setup/
  257. - uses: ./.github/actions/setup-ts/
  258. - uses: ./.github/actions/setup-solana/
  259. - uses: actions/cache@v2
  260. name: Cache Cargo registry + index
  261. id: cache-anchor
  262. with:
  263. path: |
  264. ~/.cargo/bin/
  265. ~/.cargo/registry/index/
  266. ~/.cargo/registry/cache/
  267. ~/.cargo/git/db/
  268. ./target/
  269. key: cargo-${{ runner.os }}-anchor-${{ hashFiles('**/Cargo.lock') }}
  270. - uses: actions/download-artifact@v2
  271. with:
  272. name: anchor-binary
  273. path: ~/.cargo/bin/
  274. - uses: actions/cache@v2
  275. name: Cache ${{ matrix.node.path }} target
  276. id: cache-test-target
  277. with:
  278. path: ${{ matrix.node.path }}/target
  279. key: cargo-${{ runner.os }}-${{ matrix.node.path }}-${{ env.ANCHOR_VERSION }}
  280. - run: ${{ matrix.node.cmd }}
  281. name: ${{ matrix.node.path }} program test