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