tests.yaml 11 KB

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