tests.yaml 15 KB

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