tests.yaml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  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.14
  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: cargo test
  38. - run: cd ts && yarn --frozen-lockfile
  39. - run: cd ts && yarn test
  40. - run: cd ts && yarn lint
  41. - run: cd examples/tutorial && yarn --frozen-lockfile
  42. - run: cd examples/tutorial && yarn lint
  43. - run: cd tests && yarn --frozen-lockfile
  44. - run: cd tests && yarn lint
  45. - uses: ./.github/actions/git-diff/
  46. setup-anchor-cli:
  47. name: Setup Anchor cli
  48. runs-on: ubuntu-18.04
  49. timeout-minutes: 30
  50. steps:
  51. - uses: actions/checkout@v2
  52. - uses: ./.github/actions/setup/
  53. - uses: actions/cache@v2
  54. name: Cache Cargo registry + index
  55. id: cache-anchor
  56. with:
  57. path: |
  58. ~/.cargo/bin/
  59. ~/.cargo/registry/index/
  60. ~/.cargo/registry/cache/
  61. ~/.cargo/git/db/
  62. ./target/
  63. key: cargo-${{ runner.os }}-anchor-${{ hashFiles('**/Cargo.lock') }}
  64. - run: cargo install --path cli anchor-cli --locked --force
  65. - uses: actions/upload-artifact@v2
  66. with:
  67. name: anchor-binary
  68. path: ~/.cargo/bin/anchor
  69. - uses: ./.github/actions/git-diff/
  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') }}-${{ env.SOLANA_CLI_VERSION }}-${{ hashFiles('**/Cargo.lock') }}
  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') }}-${{ env.SOLANA_CLI_VERSION }}-${{ hashFiles('**/Cargo.lock') }}
  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') }}-${{ env.SOLANA_CLI_VERSION }}-${{ hashFiles('**/Cargo.lock') }}
  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') }}-${{ env.SOLANA_CLI_VERSION }}-${{ hashFiles('**/Cargo.lock') }}
  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') }}-${{ env.SOLANA_CLI_VERSION }}-${{ hashFiles('**/Cargo.lock') }}
  115. - run: cd examples/tutorial && yarn workspaces run test
  116. - uses: ./.github/actions/git-diff/
  117. setup-client-example:
  118. needs: setup-anchor-cli
  119. name: Setup Client Example Test
  120. runs-on: ubuntu-18.04
  121. timeout-minutes: 30
  122. strategy:
  123. fail-fast: false
  124. matrix:
  125. node:
  126. - path: tests/events/
  127. name: events.so
  128. - path: examples/tutorial/basic-4/
  129. name: basic_4.so
  130. - path: examples/tutorial/basic-2/
  131. name: basic_2.so
  132. - path: tests/composite/
  133. name: composite.so
  134. steps:
  135. - uses: actions/checkout@v2
  136. - uses: ./.github/actions/setup/
  137. - uses: ./.github/actions/setup-solana/
  138. - uses: actions/download-artifact@v2
  139. with:
  140. name: anchor-binary
  141. path: ~/.cargo/bin/
  142. - run: chmod +rwx ~/.cargo/bin/anchor
  143. - run: cd ${{ matrix.node.path }} && anchor build --skip-lint
  144. - uses: actions/upload-artifact@v2
  145. with:
  146. name: ${{ matrix.node.name }}
  147. path: ${{ matrix.node.path }}target/deploy/${{ matrix.node.name }}
  148. - uses: ./.github/actions/git-diff/
  149. test-client-example:
  150. needs: setup-client-example
  151. name: Client Example Test
  152. runs-on: ubuntu-18.04
  153. timeout-minutes: 30
  154. steps:
  155. - uses: actions/checkout@v2
  156. - uses: ./.github/actions/setup/
  157. - uses: ./.github/actions/setup-ts/
  158. - uses: actions/download-artifact@v2
  159. with:
  160. name: anchor-binary
  161. path: ~/.cargo/bin/
  162. - uses: actions/download-artifact@v2
  163. with:
  164. name: events.so
  165. path: tests/events/target/deploy/
  166. - uses: actions/download-artifact@v2
  167. with:
  168. name: basic_4.so
  169. path: examples/tutorial/basic-4/target/deploy/
  170. - uses: actions/download-artifact@v2
  171. with:
  172. name: basic_2.so
  173. path: examples/tutorial/basic-2/target/deploy/
  174. - uses: actions/download-artifact@v2
  175. with:
  176. name: composite.so
  177. path: tests/composite/target/deploy/
  178. - uses: actions/cache@v2
  179. name: Cache client/example target
  180. id: cache-test-target
  181. with:
  182. path: client/example/target
  183. key: cargo-${{ runner.os }}-client/example-${{ env.ANCHOR_VERSION }}-${{ env.SOLANA_CLI_VERSION }}-${{ hashFiles('**/Cargo.lock') }}
  184. - uses: ./.github/actions/setup-solana/
  185. - run: cd client/example && ./run-test.sh
  186. - uses: ./.github/actions/git-diff/
  187. test-bpf-upgradeable-state:
  188. needs: setup-anchor-cli
  189. name: Test tests/bpf-upgradeable-state
  190. runs-on: ubuntu-18.04
  191. timeout-minutes: 30
  192. steps:
  193. - uses: actions/checkout@v2
  194. - uses: ./.github/actions/setup/
  195. - uses: ./.github/actions/setup-ts/
  196. - uses: ./.github/actions/setup-solana/
  197. - uses: actions/cache@v2
  198. name: Cache Cargo registry + index
  199. id: cache-anchor
  200. with:
  201. path: |
  202. ~/.cargo/bin/
  203. ~/.cargo/registry/index/
  204. ~/.cargo/registry/cache/
  205. ~/.cargo/git/db/
  206. ./target/
  207. key: cargo-${{ runner.os }}-anchor-${{ hashFiles('**/Cargo.lock') }}
  208. - uses: actions/download-artifact@v2
  209. with:
  210. name: anchor-binary
  211. path: ~/.cargo/bin/
  212. - uses: actions/cache@v2
  213. name: Cache tests/bpf-upgradeable-state target
  214. id: cache-test-target
  215. with:
  216. path: tests/bpf-upgradeable-state/target
  217. key: cargo-${{ runner.os }}-tests/bpf-upgradeable-state-${{ env.ANCHOR_VERSION }}-${{ env.SOLANA_CLI_VERSION }}-${{ hashFiles('**/Cargo.lock') }}
  218. - run: solana-test-validator -r --quiet &
  219. name: start validator
  220. - run: cd tests/bpf-upgradeable-state && yarn --frozen-lockfile
  221. - run: cd tests/bpf-upgradeable-state && yarn link @project-serum/anchor
  222. - run: cd tests/bpf-upgradeable-state && anchor build --skip-lint
  223. - run: cd tests/bpf-upgradeable-state && solana program deploy --program-id program_with_different_programdata.json target/deploy/bpf_upgradeable_state.so
  224. - 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
  225. - uses: ./.github/actions/git-diff/
  226. test-anchor-init:
  227. needs: setup-anchor-cli
  228. name: Test Anchor Init
  229. runs-on: ubuntu-18.04
  230. timeout-minutes: 30
  231. steps:
  232. - uses: actions/checkout@v2
  233. - uses: ./.github/actions/setup/
  234. - uses: ./.github/actions/setup-ts/
  235. - uses: ./.github/actions/setup-solana/
  236. - uses: actions/cache@v2
  237. name: Cache Cargo registry + index
  238. id: cache-anchor
  239. with:
  240. path: |
  241. ~/.cargo/bin/
  242. ~/.cargo/registry/index/
  243. ~/.cargo/registry/cache/
  244. ~/.cargo/git/db/
  245. ./target/
  246. key: cargo-${{ runner.os }}-anchor-${{ hashFiles('**/Cargo.lock') }}
  247. - uses: actions/download-artifact@v2
  248. with:
  249. name: anchor-binary
  250. path: ~/.cargo/bin/
  251. - run: cd "$(mktemp -d)" && anchor init hello-anchor && cd hello-anchor && anchor test
  252. - uses: ./.github/actions/git-diff/
  253. test-programs:
  254. needs: setup-anchor-cli
  255. name: Test ${{ matrix.node.path }}
  256. runs-on: ubuntu-18.04
  257. timeout-minutes: 30
  258. strategy:
  259. fail-fast: false
  260. matrix:
  261. node:
  262. - cmd: cd tests/sysvars && anchor test --skip-lint
  263. path: tests/sysvars
  264. - cmd: cd tests/composite && anchor test --skip-lint
  265. path: tests/composite
  266. - cmd: cd tests/errors && anchor test --skip-lint
  267. path: tests/errors
  268. - cmd: cd tests/spl/token-proxy && anchor test --skip-lint
  269. path: spl/token-proxy
  270. - cmd: cd tests/multisig && anchor test --skip-lint
  271. path: tests/multisig
  272. - cmd: cd tests/interface && anchor test --skip-lint
  273. path: tests/interface
  274. - cmd: cd tests/lockup && anchor test --skip-lint
  275. path: tests/lockup
  276. - cmd: cd tests/swap/deps/serum-dex/dex && cargo build-bpf -- --locked && cd ../../../ && anchor test --skip-lint
  277. path: tests/swap
  278. - cmd: cd tests/escrow && anchor test --skip-lint
  279. path: tests/escrow
  280. - cmd: cd tests/pyth && anchor test --skip-lint
  281. path: tests/pyth
  282. - cmd: cd tests/system-accounts && anchor test --skip-lint
  283. path: tests/system-accounts
  284. - cmd: cd tests/misc && anchor test --skip-lint
  285. path: tests/misc
  286. - cmd: cd tests/events && anchor test --skip-lint
  287. path: tests/events
  288. - cmd: cd tests/cashiers-check && anchor test --skip-lint
  289. path: tests/cashiers-check
  290. - cmd: cd tests/declare-id && anchor test --skip-lint
  291. path: tests/declare-id
  292. - cmd: cd tests/typescript && anchor test --skip-lint
  293. path: tests/typescript
  294. - cmd: cd tests/zero-copy && anchor test --skip-lint && cd programs/zero-copy && cargo test-bpf
  295. path: tests/zero-copy
  296. - cmd: cd tests/chat && anchor test --skip-lint
  297. path: tests/chat
  298. - cmd: cd tests/ido-pool && anchor test --skip-lint
  299. path: tests/ido-pool
  300. - cmd: cd tests/cfo && anchor run test-with-build && cd deps/stake && git checkout Cargo.lock && cd ../swap && git checkout Cargo.lock
  301. path: tests/cfo
  302. - cmd: cd tests/auction-house && yarn --frozen-lockfile && anchor test --skip-lint && git checkout Cargo.lock
  303. path: tests/auction-house
  304. - cmd: cd tests/floats && yarn --frozen-lockfile && anchor test --skip-lint
  305. path: tests/floats
  306. - cmd: cd tests/safety-checks && ./test.sh
  307. path: tests/safety-checks
  308. - cmd: cd tests/custom-coder && anchor test --skip-lint
  309. path: tests/custom-coder
  310. - cmd: cd tests/validator-clone && yarn --frozen-lockfile && anchor test --skip-lint
  311. path: tests/validator-clone
  312. - cmd: cd tests/cpi-returns && anchor test --skip-lint
  313. path: tests/cpi-returns
  314. steps:
  315. - uses: actions/checkout@v2
  316. - uses: ./.github/actions/setup/
  317. - uses: ./.github/actions/setup-ts/
  318. - uses: ./.github/actions/setup-solana/
  319. - uses: actions/cache@v2
  320. name: Cache Cargo registry + index
  321. id: cache-anchor
  322. with:
  323. path: |
  324. ~/.cargo/bin/
  325. ~/.cargo/registry/index/
  326. ~/.cargo/registry/cache/
  327. ~/.cargo/git/db/
  328. ./target/
  329. key: cargo-${{ runner.os }}-anchor-${{ hashFiles('**/Cargo.lock') }}
  330. - uses: actions/download-artifact@v2
  331. with:
  332. name: anchor-binary
  333. path: ~/.cargo/bin/
  334. - uses: actions/cache@v2
  335. name: Cache ${{ matrix.node.path }} target
  336. id: cache-test-target
  337. with:
  338. path: ${{ matrix.node.path }}/target
  339. key: cargo-${{ runner.os }}-${{ matrix.node.path }}-${{ env.ANCHOR_VERSION }}-${{ env.SOLANA_CLI_VERSION }}-${{ hashFiles('**/Cargo.lock') }}
  340. - run: ${{ matrix.node.cmd }}
  341. name: ${{ matrix.node.path }} program test
  342. - uses: ./.github/actions/git-diff/