tests.yaml 15 KB

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