tests.yaml 15 KB

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