tests.yaml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  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.9.13
  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. # using singlethreaded testing for avm so that tests that change files do not conflict with each other
  39. - run: cd avm && cargo fmt -- --check && cargo clippy --all-targets -- -D warnings && cargo test -- --test-threads=1
  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. - run: chmod +x ~/.cargo/bin/anchor
  68. - uses: actions/upload-artifact@v2
  69. with:
  70. name: anchor-binary
  71. path: ~/.cargo/bin/anchor
  72. - uses: ./.github/actions/git-diff/
  73. test-examples:
  74. needs: setup-anchor-cli
  75. name: Examples Test
  76. runs-on: ubuntu-18.04
  77. timeout-minutes: 30
  78. steps:
  79. - uses: actions/checkout@v2
  80. - uses: actions/download-artifact@v2
  81. with:
  82. name: anchor-binary
  83. path: ~/.cargo/bin/
  84. - run: chmod +rwx ~/.cargo/bin/anchor
  85. - uses: ./.github/actions/setup/
  86. - uses: ./.github/actions/setup-solana/
  87. - uses: ./.github/actions/setup-ts/
  88. - uses: actions/cache@v2
  89. name: basic-0 cache
  90. id: cache-basic-0
  91. with:
  92. path: ./examples/tutorial/basic-0/target
  93. key: cargo-${{ runner.os }}-${{ hashFiles('./examples/tutorial/basic-0/**/Cargo.toml') }}-${{ env.SOLANA_CLI_VERSION }}-${{ hashFiles('**/Cargo.lock') }}
  94. - uses: actions/cache@v2
  95. name: basic-1 cache
  96. id: cache-basic-1
  97. with:
  98. path: ./examples/tutorial/basic-1/target
  99. key: cargo-${{ runner.os }}-${{ hashFiles('./examples/tutorial/basic-1/**/Cargo.toml') }}-${{ env.SOLANA_CLI_VERSION }}-${{ hashFiles('**/Cargo.lock') }}
  100. - uses: actions/cache@v2
  101. name: basic-2 cache
  102. id: cache-basic-2
  103. with:
  104. path: ./examples/tutorial/basic-2/target
  105. key: cargo-${{ runner.os }}-${{ hashFiles('./examples/tutorial/basic-2/**/Cargo.toml') }}-${{ env.SOLANA_CLI_VERSION }}-${{ hashFiles('**/Cargo.lock') }}
  106. - uses: actions/cache@v2
  107. name: basic-3 cache
  108. id: cache-basic-3
  109. with:
  110. path: ./examples/tutorial/basic-3/target
  111. key: cargo-${{ runner.os }}-${{ hashFiles('./examples/tutorial/basic-3/**/Cargo.toml') }}-${{ env.SOLANA_CLI_VERSION }}-${{ hashFiles('**/Cargo.lock') }}
  112. - uses: actions/cache@v2
  113. name: basic-4 cache
  114. id: cache-basic-4
  115. with:
  116. path: ./examples/tutorial/basic-4/target
  117. key: cargo-${{ runner.os }}-${{ hashFiles('./examples/tutorial/basic-4/**/Cargo.toml') }}-${{ env.SOLANA_CLI_VERSION }}-${{ hashFiles('**/Cargo.lock') }}
  118. - run: cd examples/tutorial && yarn workspaces run test
  119. - uses: ./.github/actions/git-diff/
  120. setup-client-example:
  121. needs: setup-anchor-cli
  122. name: Setup Client Example Test
  123. runs-on: ubuntu-18.04
  124. timeout-minutes: 30
  125. strategy:
  126. fail-fast: false
  127. matrix:
  128. node:
  129. - path: tests/events/
  130. name: events.so
  131. - path: examples/tutorial/basic-4/
  132. name: basic_4.so
  133. - path: examples/tutorial/basic-2/
  134. name: basic_2.so
  135. - path: tests/composite/
  136. name: composite.so
  137. steps:
  138. - uses: actions/checkout@v2
  139. - uses: ./.github/actions/setup/
  140. - uses: ./.github/actions/setup-solana/
  141. - uses: actions/download-artifact@v2
  142. with:
  143. name: anchor-binary
  144. path: ~/.cargo/bin/
  145. - run: chmod +rwx ~/.cargo/bin/anchor
  146. - run: cd ${{ matrix.node.path }} && anchor build --skip-lint
  147. - uses: actions/upload-artifact@v2
  148. with:
  149. name: ${{ matrix.node.name }}
  150. path: ${{ matrix.node.path }}target/deploy/${{ matrix.node.name }}
  151. - uses: ./.github/actions/git-diff/
  152. test-client-example:
  153. needs: setup-client-example
  154. name: Client Example Test
  155. runs-on: ubuntu-18.04
  156. timeout-minutes: 30
  157. steps:
  158. - uses: actions/checkout@v2
  159. - uses: ./.github/actions/setup/
  160. - uses: ./.github/actions/setup-ts/
  161. - uses: actions/download-artifact@v2
  162. with:
  163. name: anchor-binary
  164. path: ~/.cargo/bin/
  165. - run: chmod +x ~/.cargo/bin/anchor
  166. - uses: actions/download-artifact@v2
  167. with:
  168. name: events.so
  169. path: tests/events/target/deploy/
  170. - uses: actions/download-artifact@v2
  171. with:
  172. name: basic_4.so
  173. path: examples/tutorial/basic-4/target/deploy/
  174. - uses: actions/download-artifact@v2
  175. with:
  176. name: basic_2.so
  177. path: examples/tutorial/basic-2/target/deploy/
  178. - uses: actions/download-artifact@v2
  179. with:
  180. name: composite.so
  181. path: tests/composite/target/deploy/
  182. - uses: actions/cache@v2
  183. name: Cache client/example target
  184. id: cache-test-target
  185. with:
  186. path: client/example/target
  187. key: cargo-${{ runner.os }}-client/example-${{ env.ANCHOR_VERSION }}-${{ env.SOLANA_CLI_VERSION }}-${{ hashFiles('**/Cargo.lock') }}
  188. - uses: ./.github/actions/setup-solana/
  189. - run: cd client/example && ./run-test.sh
  190. - uses: ./.github/actions/git-diff/
  191. test-bpf-upgradeable-state:
  192. needs: setup-anchor-cli
  193. name: Test tests/bpf-upgradeable-state
  194. runs-on: ubuntu-18.04
  195. timeout-minutes: 30
  196. steps:
  197. - uses: actions/checkout@v2
  198. - uses: ./.github/actions/setup/
  199. - uses: ./.github/actions/setup-ts/
  200. - uses: ./.github/actions/setup-solana/
  201. - uses: actions/cache@v2
  202. name: Cache Cargo registry + index
  203. id: cache-anchor
  204. with:
  205. path: |
  206. ~/.cargo/bin/
  207. ~/.cargo/registry/index/
  208. ~/.cargo/registry/cache/
  209. ~/.cargo/git/db/
  210. ./target/
  211. key: cargo-${{ runner.os }}-anchor-${{ hashFiles('**/Cargo.lock') }}
  212. - uses: actions/download-artifact@v2
  213. with:
  214. name: anchor-binary
  215. path: ~/.cargo/bin/
  216. - run: chmod +x ~/.cargo/bin/anchor
  217. - uses: actions/cache@v2
  218. name: Cache tests/bpf-upgradeable-state target
  219. id: cache-test-target
  220. with:
  221. path: tests/bpf-upgradeable-state/target
  222. key: cargo-${{ runner.os }}-tests/bpf-upgradeable-state-${{ env.ANCHOR_VERSION }}-${{ env.SOLANA_CLI_VERSION }}-${{ hashFiles('**/Cargo.lock') }}
  223. - run: solana-test-validator -r --quiet &
  224. name: start validator
  225. - run: cd tests/bpf-upgradeable-state && yarn --frozen-lockfile
  226. - run: cd tests/bpf-upgradeable-state && yarn link @project-serum/anchor
  227. - run: cd tests/bpf-upgradeable-state && anchor build --skip-lint
  228. - run: cd tests/bpf-upgradeable-state && solana program deploy --program-id program_with_different_programdata.json target/deploy/bpf_upgradeable_state.so
  229. - run: cd tests/bpf-upgradeable-state && cp bpf_upgradeable_state-keypair.json target/deploy/bpf_upgradeable_state-keypair.json && anchor test --skip-local-validator --skip-build --skip-lint
  230. - uses: ./.github/actions/git-diff/
  231. # this test exists to make sure that anchor
  232. # checks rent correctly for legacy accounts
  233. # that don't have to be rent-exempt
  234. test-misc-non-rent-exempt:
  235. # the anchor cli is built with a different solana version
  236. # but that's fine since it's just the cli
  237. needs: setup-anchor-cli
  238. name: Test tests/misc/nonRentExempt
  239. runs-on: ubuntu-18.04
  240. timeout-minutes: 30
  241. steps:
  242. - uses: actions/checkout@v2
  243. - uses: ./.github/actions/setup/
  244. - uses: ./.github/actions/setup-ts/
  245. - uses: actions/cache@v2
  246. name: Cache Solana Tool Suite
  247. id: cache-solana
  248. with:
  249. path: |
  250. ~/.cache/solana/
  251. ~/.local/share/solana/
  252. key: solana-${{ runner.os }}-v0000-1.8.14
  253. # using an outdated validator but that
  254. # is ok as long as the test doesn't
  255. # include newer incompatible features
  256. - run: sh -c "$(curl -sSfL https://release.solana.com/v1.8.14/install)"
  257. shell: bash
  258. - run: echo "/home/runner/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
  259. shell: bash
  260. - run: solana-keygen new --no-bip39-passphrase
  261. shell: bash
  262. - run: solana config set --url localhost
  263. shell: bash
  264. - uses: actions/download-artifact@v2
  265. with:
  266. name: anchor-binary
  267. path: ~/.cargo/bin/
  268. - run: chmod +x ~/.cargo/bin/anchor
  269. - uses: actions/cache@v2
  270. name: Cache tests/misc target
  271. id: cache-test-target
  272. with:
  273. path: tests/misc/target
  274. key: cargo-${{ runner.os }}-tests/misc-${{ env.ANCHOR_VERSION }}-1.8.14-${{ hashFiles('**/Cargo.lock') }}
  275. - run: cd tests/misc && yarn --frozen-lockfile
  276. - run: cd tests/misc && yarn link @project-serum/anchor
  277. - run: cd tests/misc && chmod +x ci.sh && ./ci.sh
  278. - run: cd tests/misc && anchor test --skip-lint
  279. test-anchor-init:
  280. needs: setup-anchor-cli
  281. name: Test Anchor Init
  282. runs-on: ubuntu-18.04
  283. timeout-minutes: 30
  284. steps:
  285. - uses: actions/checkout@v2
  286. - uses: ./.github/actions/setup/
  287. - uses: ./.github/actions/setup-ts/
  288. - uses: ./.github/actions/setup-solana/
  289. - uses: actions/cache@v2
  290. name: Cache Cargo registry + index
  291. id: cache-anchor
  292. with:
  293. path: |
  294. ~/.cargo/bin/
  295. ~/.cargo/registry/index/
  296. ~/.cargo/registry/cache/
  297. ~/.cargo/git/db/
  298. ./target/
  299. key: cargo-${{ runner.os }}-anchor-${{ hashFiles('**/Cargo.lock') }}
  300. - uses: actions/download-artifact@v2
  301. with:
  302. name: anchor-binary
  303. path: ~/.cargo/bin/
  304. - run: chmod +x ~/.cargo/bin/anchor
  305. - run: cd "$(mktemp -d)" && anchor init hello-anchor && cd hello-anchor && yarn link @project-serum/anchor && anchor test && yarn lint:fix
  306. - uses: ./.github/actions/git-diff/
  307. test-programs:
  308. needs: setup-anchor-cli
  309. name: Test ${{ matrix.node.path }}
  310. runs-on: ubuntu-18.04
  311. timeout-minutes: 30
  312. strategy:
  313. fail-fast: false
  314. matrix:
  315. node:
  316. - cmd: cd tests/sysvars && anchor test --skip-lint
  317. path: tests/sysvars
  318. - cmd: cd tests/composite && anchor test --skip-lint
  319. path: tests/composite
  320. - cmd: cd tests/errors && anchor test --skip-lint
  321. path: tests/errors
  322. - cmd: cd tests/spl/token-proxy && anchor test --skip-lint
  323. path: spl/token-proxy
  324. - cmd: cd tests/multisig && anchor test --skip-lint
  325. path: tests/multisig
  326. - cmd: cd tests/interface && anchor test --skip-lint
  327. path: tests/interface
  328. - cmd: cd tests/lockup && anchor test --skip-lint
  329. path: tests/lockup
  330. - cmd: cd tests/swap/deps/serum-dex/dex && cargo build-bpf -- --locked && cd ../../../ && anchor test --skip-lint
  331. path: tests/swap
  332. - cmd: cd tests/escrow && anchor test --skip-lint
  333. path: tests/escrow
  334. - cmd: cd tests/pyth && anchor test --skip-lint
  335. path: tests/pyth
  336. - cmd: cd tests/system-accounts && anchor test --skip-lint
  337. path: tests/system-accounts
  338. - cmd: cd tests/misc && anchor test --skip-lint
  339. path: tests/misc
  340. - cmd: cd tests/events && anchor test --skip-lint
  341. path: tests/events
  342. - cmd: cd tests/cashiers-check && anchor test --skip-lint
  343. path: tests/cashiers-check
  344. - cmd: cd tests/declare-id && anchor test --skip-lint
  345. path: tests/declare-id
  346. - cmd: cd tests/typescript && anchor test --skip-lint
  347. path: tests/typescript
  348. - cmd: cd tests/zero-copy && anchor test --skip-lint && cd programs/zero-copy && cargo test-bpf
  349. path: tests/zero-copy
  350. - cmd: cd tests/chat && anchor test --skip-lint
  351. path: tests/chat
  352. - cmd: cd tests/ido-pool && anchor test --skip-lint
  353. path: tests/ido-pool
  354. - cmd: cd tests/cfo && anchor run test-with-build && cd deps/stake && git checkout Cargo.lock && cd ../swap && git checkout Cargo.lock
  355. path: tests/cfo
  356. - cmd: cd tests/auction-house && yarn --frozen-lockfile && anchor test --skip-lint && git checkout Cargo.lock
  357. path: tests/auction-house
  358. - cmd: cd tests/floats && yarn --frozen-lockfile && anchor test --skip-lint
  359. path: tests/floats
  360. - cmd: cd tests/safety-checks && ./test.sh
  361. path: tests/safety-checks
  362. - cmd: cd tests/custom-coder && anchor test --skip-lint
  363. path: tests/custom-coder
  364. - cmd: cd tests/validator-clone && yarn --frozen-lockfile && anchor test --skip-lint
  365. path: tests/validator-clone
  366. - cmd: cd tests/cpi-returns && anchor test --skip-lint
  367. path: tests/cpi-returns
  368. - cmd: cd tests/multiple-suites && anchor test --skip-lint
  369. path: tests/multiple-suites
  370. steps:
  371. - uses: actions/checkout@v2
  372. - uses: ./.github/actions/setup/
  373. - uses: ./.github/actions/setup-ts/
  374. - uses: ./.github/actions/setup-solana/
  375. - uses: actions/cache@v2
  376. name: Cache Cargo registry + index
  377. id: cache-anchor
  378. with:
  379. path: |
  380. ~/.cargo/bin/
  381. ~/.cargo/registry/index/
  382. ~/.cargo/registry/cache/
  383. ~/.cargo/git/db/
  384. ./target/
  385. key: cargo-${{ runner.os }}-anchor-${{ hashFiles('**/Cargo.lock') }}
  386. - uses: actions/download-artifact@v2
  387. with:
  388. name: anchor-binary
  389. path: ~/.cargo/bin/
  390. - run: chmod +x ~/.cargo/bin/anchor
  391. - uses: actions/cache@v2
  392. name: Cache ${{ matrix.node.path }} target
  393. id: cache-test-target
  394. with:
  395. path: ${{ matrix.node.path }}/target
  396. key: cargo-${{ runner.os }}-${{ matrix.node.path }}-${{ env.ANCHOR_VERSION }}-${{ env.SOLANA_CLI_VERSION }}-${{ hashFiles('**/Cargo.lock') }}
  397. - run: ${{ matrix.node.cmd }}
  398. name: ${{ matrix.node.path }} program test
  399. - uses: ./.github/actions/git-diff/