tests.yaml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  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.10.29
  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
  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. - run: cd tests/bpf-upgradeable-state && npx tsc --noEmit
  231. - uses: ./.github/actions/git-diff/
  232. # this test exists to make sure that anchor
  233. # checks rent correctly for legacy accounts
  234. # that don't have to be rent-exempt
  235. test-misc-non-rent-exempt:
  236. # the anchor cli is built with a different solana version
  237. # but that's fine since it's just the cli
  238. needs: setup-anchor-cli
  239. name: Test tests/misc/nonRentExempt
  240. runs-on: ubuntu-18.04
  241. timeout-minutes: 30
  242. steps:
  243. - uses: actions/checkout@v2
  244. - uses: ./.github/actions/setup/
  245. - uses: ./.github/actions/setup-ts/
  246. - uses: actions/cache@v2
  247. name: Cache Solana Tool Suite
  248. id: cache-solana
  249. with:
  250. path: |
  251. ~/.cache/solana/
  252. ~/.local/share/solana/
  253. key: solana-${{ runner.os }}-v0000-1.8.14
  254. # using an outdated validator but that
  255. # is ok as long as the test doesn't
  256. # include newer incompatible features
  257. - run: sh -c "$(curl -sSfL https://release.solana.com/v1.8.14/install)"
  258. shell: bash
  259. - run: echo "/home/runner/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
  260. shell: bash
  261. - run: solana-keygen new --no-bip39-passphrase
  262. shell: bash
  263. - run: solana config set --url localhost
  264. shell: bash
  265. - uses: actions/download-artifact@v2
  266. with:
  267. name: anchor-binary
  268. path: ~/.cargo/bin/
  269. - run: chmod +x ~/.cargo/bin/anchor
  270. - uses: actions/cache@v2
  271. name: Cache tests/misc target
  272. id: cache-test-target
  273. with:
  274. path: tests/misc/target
  275. key: cargo-${{ runner.os }}-tests/misc-${{ env.ANCHOR_VERSION }}-1.8.14-${{ hashFiles('**/Cargo.lock') }}
  276. - run: cd tests/misc && yarn --frozen-lockfile
  277. - run: cd tests/misc
  278. - run: cd tests/misc && chmod +x ci.sh && ./ci.sh
  279. - run: cd tests/misc && anchor test --skip-lint
  280. test-anchor-init:
  281. needs: setup-anchor-cli
  282. name: Test Anchor Init
  283. runs-on: ubuntu-18.04
  284. timeout-minutes: 30
  285. steps:
  286. - uses: actions/checkout@v2
  287. - uses: ./.github/actions/setup/
  288. - uses: ./.github/actions/setup-ts/
  289. - uses: ./.github/actions/setup-solana/
  290. - uses: actions/cache@v2
  291. name: Cache Cargo registry + index
  292. id: cache-anchor
  293. with:
  294. path: |
  295. ~/.cargo/bin/
  296. ~/.cargo/registry/index/
  297. ~/.cargo/registry/cache/
  298. ~/.cargo/git/db/
  299. ./target/
  300. key: cargo-${{ runner.os }}-anchor-${{ hashFiles('**/Cargo.lock') }}
  301. - uses: actions/download-artifact@v2
  302. with:
  303. name: anchor-binary
  304. path: ~/.cargo/bin/
  305. - run: chmod +x ~/.cargo/bin/anchor
  306. - run: cd "$(mktemp -d)" && anchor init hello-anchor && cd hello-anchor && yarn link @project-serum/anchor && yarn && anchor test && yarn lint:fix
  307. - uses: ./.github/actions/git-diff/
  308. test-programs:
  309. needs: setup-anchor-cli
  310. name: Test ${{ matrix.node.path }}
  311. runs-on: ubuntu-18.04
  312. timeout-minutes: 30
  313. strategy:
  314. fail-fast: false
  315. matrix:
  316. node:
  317. - cmd: cd tests/sysvars && anchor test --skip-lint
  318. path: tests/sysvars
  319. - cmd: cd tests/composite && anchor test --skip-lint
  320. path: tests/composite
  321. - cmd: cd tests/errors && anchor test --skip-lint && npx tsc --noEmit
  322. path: tests/errors
  323. - cmd: cd tests/spl/token-proxy && anchor test --skip-lint
  324. path: spl/token-proxy
  325. - cmd: cd tests/multisig && anchor test --skip-lint
  326. path: tests/multisig
  327. - cmd: cd tests/interface && anchor test --skip-lint
  328. path: tests/interface
  329. - cmd: cd tests/lockup && anchor test --skip-lint
  330. path: tests/lockup
  331. - cmd: cd tests/swap/deps/serum-dex/dex && cargo build-bpf -- --locked && cd ../../../ && anchor test --skip-lint
  332. path: tests/swap
  333. - cmd: cd tests/escrow && anchor test --skip-lint && npx tsc --noEmit
  334. path: tests/escrow
  335. - cmd: cd tests/pyth && anchor test --skip-lint && npx tsc --noEmit
  336. path: tests/pyth
  337. - cmd: cd tests/realloc && anchor test --skip-lint && npx tsc --noEmit
  338. path: tests/realloc
  339. - cmd: cd tests/system-accounts && anchor test --skip-lint
  340. path: tests/system-accounts
  341. - cmd: cd tests/misc && anchor test --skip-lint && npx tsc --noEmit
  342. path: tests/misc
  343. - cmd: cd tests/events && anchor test --skip-lint
  344. path: tests/events
  345. - cmd: cd tests/cashiers-check && anchor test --skip-lint
  346. path: tests/cashiers-check
  347. - cmd: cd tests/declare-id && anchor test --skip-lint && npx tsc --noEmit
  348. path: tests/declare-id
  349. - cmd: cd tests/typescript && anchor test --skip-lint && npx tsc --noEmit
  350. path: tests/typescript
  351. - cmd: cd tests/zero-copy && anchor test --skip-lint && cd programs/zero-copy && cargo test-bpf
  352. path: tests/zero-copy
  353. - cmd: cd tests/chat && anchor test --skip-lint
  354. path: tests/chat
  355. - cmd: cd tests/ido-pool && anchor test --skip-lint
  356. path: tests/ido-pool
  357. - cmd: cd tests/cfo && anchor run test-with-build && cd deps/stake && git checkout Cargo.lock && cd ../swap && git checkout Cargo.lock
  358. path: tests/cfo
  359. - cmd: cd tests/auction-house && yarn --frozen-lockfile && anchor test --skip-lint && git checkout Cargo.lock
  360. path: tests/auction-house
  361. - cmd: cd tests/floats && yarn --frozen-lockfile && anchor test --skip-lint && npx tsc --noEmit
  362. path: tests/floats
  363. - cmd: cd tests/safety-checks && anchor run test
  364. path: tests/safety-checks
  365. - cmd: cd tests/custom-coder && anchor test --skip-lint && npx tsc --noEmit
  366. path: tests/custom-coder
  367. - cmd: cd tests/validator-clone && anchor test --skip-lint && npx tsc --noEmit
  368. path: tests/validator-clone
  369. - cmd: cd tests/cpi-returns && anchor test --skip-lint && npx tsc --noEmit
  370. path: tests/cpi-returns
  371. - cmd: cd tests/multiple-suites && anchor test --skip-lint && npx tsc --noEmit
  372. path: tests/multiple-suites
  373. - cmd: cd tests/pda-derivation && anchor test --skip-lint && npx tsc --noEmit
  374. path: tests/pda-derivation
  375. - cmd: cd tests/anchor-cli-idl && ./test.sh
  376. path: tests/anchor-cli-idl
  377. steps:
  378. - uses: actions/checkout@v2
  379. - uses: ./.github/actions/setup/
  380. - uses: ./.github/actions/setup-ts/
  381. - uses: ./.github/actions/setup-solana/
  382. - uses: actions/cache@v2
  383. name: Cache Cargo registry + index
  384. id: cache-anchor
  385. with:
  386. path: |
  387. ~/.cargo/bin/
  388. ~/.cargo/registry/index/
  389. ~/.cargo/registry/cache/
  390. ~/.cargo/git/db/
  391. ./target/
  392. key: cargo-${{ runner.os }}-anchor-${{ hashFiles('**/Cargo.lock') }}
  393. - uses: actions/download-artifact@v2
  394. with:
  395. name: anchor-binary
  396. path: ~/.cargo/bin/
  397. - run: chmod +x ~/.cargo/bin/anchor
  398. - uses: actions/cache@v2
  399. name: Cache ${{ matrix.node.path }} target
  400. id: cache-test-target
  401. with:
  402. path: ${{ matrix.node.path }}/target
  403. key: cargo-${{ runner.os }}-${{ matrix.node.path }}-${{ env.ANCHOR_VERSION }}-${{ env.SOLANA_CLI_VERSION }}-${{ hashFiles('**/Cargo.lock') }}
  404. - run: ${{ matrix.node.cmd }}
  405. name: ${{ matrix.node.path }} program test
  406. - uses: ./.github/actions/git-diff/