tests.yaml 11 KB

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