tests.yaml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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.5
  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: rustup toolchain install nightly --profile minimal --component clippy
  37. - run: cargo +nightly clippy --all-targets -- -D warnings
  38. - run: cargo test
  39. - run: cd ts && yarn
  40. - run: cd ts && yarn test
  41. - run: cd ts && yarn lint
  42. setup-anchor-cli:
  43. name: Setup Anchor cli
  44. runs-on: ubuntu-18.04
  45. steps:
  46. - uses: actions/checkout@v2
  47. - uses: ./.github/actions/setup/
  48. - uses: actions/cache@v2
  49. name: Cache Cargo registry + index
  50. id: cache-anchor
  51. with:
  52. path: |
  53. ~/.cargo/bin/
  54. ~/.cargo/registry/index/
  55. ~/.cargo/registry/cache/
  56. ~/.cargo/git/db/
  57. ./target/
  58. key: cargo-${{ runner.os }}-anchor-${{ hashFiles('**/Cargo.lock') }}
  59. - run: cargo install --path cli anchor-cli --locked --force
  60. - uses: actions/upload-artifact@v2
  61. with:
  62. name: anchor-binary
  63. path: ~/.cargo/bin/anchor
  64. test-examples:
  65. needs: setup-anchor-cli
  66. name: Examples Test
  67. runs-on: ubuntu-18.04
  68. steps:
  69. - uses: actions/checkout@v2
  70. - uses: actions/download-artifact@v2
  71. with:
  72. name: anchor-binary
  73. path: ~/.cargo/bin/
  74. - run: chmod +rwx ~/.cargo/bin/anchor
  75. - uses: ./.github/actions/setup/
  76. - uses: ./.github/actions/setup-solana/
  77. - uses: ./.github/actions/setup-ts/
  78. - uses: actions/cache@v2
  79. name: basic-0 cache
  80. id: cache-basic-0
  81. with:
  82. path: ./examples/tutorial/basic-0/target
  83. key: cargo-${{ runner.os }}-${{ hashFiles('./examples/tutorial/basic-0/**/Cargo.toml') }}
  84. - uses: actions/cache@v2
  85. name: basic-1 cache
  86. id: cache-basic-1
  87. with:
  88. path: ./examples/tutorial/basic-1/target
  89. key: cargo-${{ runner.os }}-${{ hashFiles('./examples/tutorial/basic-1/**/Cargo.toml') }}
  90. - uses: actions/cache@v2
  91. name: basic-2 cache
  92. id: cache-basic-2
  93. with:
  94. path: ./examples/tutorial/basic-2/target
  95. key: cargo-${{ runner.os }}-${{ hashFiles('./examples/tutorial/basic-2/**/Cargo.toml') }}
  96. - uses: actions/cache@v2
  97. name: basic-3 cache
  98. id: cache-basic-3
  99. with:
  100. path: ./examples/tutorial/basic-3/target
  101. key: cargo-${{ runner.os }}-${{ hashFiles('./examples/tutorial/basic-3/**/Cargo.toml') }}
  102. - uses: actions/cache@v2
  103. name: basic-4 cache
  104. id: cache-basic-4
  105. with:
  106. path: ./examples/tutorial/basic-4/target
  107. key: cargo-${{ runner.os }}-${{ hashFiles('./examples/tutorial/basic-4/**/Cargo.toml') }}
  108. - run: cd examples/tutorial && yarn workspaces run test
  109. setup-client-example:
  110. needs: setup-anchor-cli
  111. name: Setup Client Example Test
  112. runs-on: ubuntu-18.04
  113. strategy:
  114. matrix:
  115. node:
  116. - path: tests/events/
  117. name: events.so
  118. - path: examples/tutorial/basic-4/
  119. name: basic_4.so
  120. - path: examples/tutorial/basic-2/
  121. name: basic_2.so
  122. - path: tests/composite/
  123. name: composite.so
  124. steps:
  125. - uses: actions/checkout@v2
  126. - uses: ./.github/actions/setup/
  127. - uses: ./.github/actions/setup-solana/
  128. - uses: actions/download-artifact@v2
  129. with:
  130. name: anchor-binary
  131. path: ~/.cargo/bin/
  132. - run: chmod +rwx ~/.cargo/bin/anchor
  133. - run: cd ${{ matrix.node.path }} && anchor build
  134. - uses: actions/upload-artifact@v2
  135. with:
  136. name: ${{ matrix.node.name }}
  137. path: ${{ matrix.node.path }}target/deploy/${{ matrix.node.name }}
  138. test-client-example:
  139. needs: setup-client-example
  140. name: Client Example Test
  141. runs-on: ubuntu-18.04
  142. steps:
  143. - uses: actions/checkout@v2
  144. - uses: ./.github/actions/setup/
  145. - uses: ./.github/actions/setup-ts/
  146. - uses: actions/download-artifact@v2
  147. with:
  148. name: anchor-binary
  149. path: ~/.cargo/bin/
  150. - uses: actions/download-artifact@v2
  151. with:
  152. name: events.so
  153. path: tests/events/target/deploy/
  154. - uses: actions/download-artifact@v2
  155. with:
  156. name: basic_4.so
  157. path: examples/tutorial/basic-4/target/deploy/
  158. - uses: actions/download-artifact@v2
  159. with:
  160. name: basic_2.so
  161. path: examples/tutorial/basic-2/target/deploy/
  162. - uses: actions/download-artifact@v2
  163. with:
  164. name: composite.so
  165. path: tests/composite/target/deploy/
  166. - uses: actions/cache@v2
  167. name: Cache client/example target
  168. id: cache-test-target
  169. with:
  170. path: client/example/target
  171. key: cargo-${{ runner.os }}-client/example-${{ env.ANCHOR_VERSION }}
  172. - uses: ./.github/actions/setup-solana/
  173. - run: cd client/example && ./run-test.sh
  174. test-bpf-upgradeable-state:
  175. needs: setup-anchor-cli
  176. name: Test tests/bpf-upgradeable-state
  177. runs-on: ubuntu-18.04
  178. steps:
  179. - uses: actions/checkout@v2
  180. - uses: ./.github/actions/setup/
  181. - uses: ./.github/actions/setup-ts/
  182. - uses: ./.github/actions/setup-solana/
  183. - uses: actions/cache@v2
  184. name: Cache Cargo registry + index
  185. id: cache-anchor
  186. with:
  187. path: |
  188. ~/.cargo/bin/
  189. ~/.cargo/registry/index/
  190. ~/.cargo/registry/cache/
  191. ~/.cargo/git/db/
  192. ./target/
  193. key: cargo-${{ runner.os }}-anchor-${{ hashFiles('**/Cargo.lock') }}
  194. - uses: actions/download-artifact@v2
  195. with:
  196. name: anchor-binary
  197. path: ~/.cargo/bin/
  198. - uses: actions/cache@v2
  199. name: Cache tests/bpf-upgradeable-state target
  200. id: cache-test-target
  201. with:
  202. path: tests/bpf-upgradeable-state/target
  203. key: cargo-${{ runner.os }}-tests/bpf-upgradeable-state-${{ env.ANCHOR_VERSION }}
  204. - run: solana-test-validator -r --quiet &
  205. name: start validator
  206. - run: cd tests/bpf-upgradeable-state && yarn
  207. - run: cd tests/bpf-upgradeable-state && yarn link @project-serum/anchor
  208. - run: cd tests/bpf-upgradeable-state && anchor build
  209. - run: cd tests/bpf-upgradeable-state && solana program deploy --program-id program_with_different_programdata.json target/deploy/bpf_upgradeable_state.so
  210. - 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
  211. test-programs:
  212. needs: setup-anchor-cli
  213. name: Test ${{ matrix.node.path }}
  214. runs-on: ubuntu-18.04
  215. strategy:
  216. matrix:
  217. node:
  218. - cmd: cd tests/sysvars && anchor test
  219. path: tests/sysvars
  220. - cmd: cd tests/composite && anchor test
  221. path: tests/composite
  222. - cmd: cd tests/errors && anchor test
  223. path: tests/errors
  224. - cmd: cd tests/spl/token-proxy && anchor test
  225. path: spl/token-proxy
  226. - cmd: cd tests/multisig && anchor test
  227. path: tests/multisig
  228. - cmd: cd tests/interface && anchor test
  229. path: tests/interface
  230. - cmd: cd tests/lockup && anchor test
  231. path: tests/lockup
  232. - cmd: cd tests/swap/deps/serum-dex/dex && cargo build-bpf && cd ../../../ && anchor test
  233. path: tests/swap
  234. - cmd: cd tests/escrow && anchor test
  235. path: tests/escrow
  236. - cmd: cd tests/pyth && anchor test
  237. path: tests/pyth
  238. - cmd: cd tests/system-accounts && anchor test
  239. path: tests/system-accounts
  240. - cmd: cd tests/misc && anchor test
  241. path: tests/misc
  242. - cmd: cd tests/events && anchor test
  243. path: tests/events
  244. - cmd: cd tests/cashiers-check && anchor test
  245. path: tests/cashiers-check
  246. - cmd: cd tests/typescript && anchor test
  247. path: tests/typescript
  248. - cmd: cd tests/zero-copy && anchor test && cd programs/zero-copy && cargo test-bpf
  249. path: tests/zero-copy
  250. - cmd: cd tests/chat && anchor test
  251. path: tests/chat
  252. - cmd: cd tests/ido-pool && anchor test
  253. path: tests/ido-pool
  254. - cmd: cd tests/cfo && anchor run test-with-build
  255. path: tests/cfo
  256. steps:
  257. - uses: actions/checkout@v2
  258. - uses: ./.github/actions/setup/
  259. - uses: ./.github/actions/setup-ts/
  260. - uses: ./.github/actions/setup-solana/
  261. - uses: actions/cache@v2
  262. name: Cache Cargo registry + index
  263. id: cache-anchor
  264. with:
  265. path: |
  266. ~/.cargo/bin/
  267. ~/.cargo/registry/index/
  268. ~/.cargo/registry/cache/
  269. ~/.cargo/git/db/
  270. ./target/
  271. key: cargo-${{ runner.os }}-anchor-${{ hashFiles('**/Cargo.lock') }}
  272. - uses: actions/download-artifact@v2
  273. with:
  274. name: anchor-binary
  275. path: ~/.cargo/bin/
  276. - uses: actions/cache@v2
  277. name: Cache ${{ matrix.node.path }} target
  278. id: cache-test-target
  279. with:
  280. path: ${{ matrix.node.path }}/target
  281. key: cargo-${{ runner.os }}-${{ matrix.node.path }}-${{ env.ANCHOR_VERSION }}
  282. - run: ${{ matrix.node.cmd }}
  283. name: ${{ matrix.node.path }} program test