run-tests.yml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. name: Run Bolt Tests
  2. on:
  3. push:
  4. pull_request:
  5. env:
  6. solana_version: v1.18.1
  7. anchor_version: 0.29.0
  8. jobs:
  9. install:
  10. runs-on: ubuntu-latest
  11. steps:
  12. - uses: actions/checkout@v4
  13. - uses: actions/cache@v4
  14. name: cache solana cli
  15. id: cache-solana
  16. with:
  17. path: |
  18. ~/.cache/solana/
  19. ~/.local/share/solana/
  20. key: solana-${{ runner.os }}-v0000-${{ env.solana_version }}
  21. - uses: actions/setup-node@v4
  22. with:
  23. node-version: 20
  24. - name: install essentials
  25. run: |
  26. sudo apt-get update
  27. sudo apt-get install -y pkg-config build-essential libudev-dev
  28. npm install --global yarn
  29. - name: Cache node dependencies
  30. uses: actions/cache@v3
  31. with:
  32. path: '**/node_modules'
  33. key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
  34. - name: install node_modules
  35. run: |
  36. export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
  37. yarn --frozen-lockfile --network-concurrency 2
  38. - name: install rust
  39. uses: dtolnay/rust-toolchain@stable
  40. with:
  41. toolchain: stable
  42. - name: Cache rust
  43. uses: Swatinem/rust-cache@v2
  44. - name: install solana
  45. if: steps.cache-solana.outputs.cache-hit != 'true'
  46. run: |
  47. sh -c "$(curl -sSfL https://release.solana.com/${{ env.solana_version }}/install)"
  48. export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
  49. solana --version
  50. clippy-lint:
  51. needs: install
  52. runs-on: ubuntu-latest
  53. steps:
  54. - uses: actions/checkout@v4
  55. - name: Cache rust
  56. uses: Swatinem/rust-cache@v2
  57. - name: Run fmt
  58. run: cargo fmt -- --check
  59. - name: Run clippy
  60. run: cargo clippy -- --deny=warnings
  61. yarn-lint:
  62. needs: install
  63. runs-on: ubuntu-latest
  64. steps:
  65. - uses: actions/checkout@v4
  66. - name: Use Node ${{ matrix.node }}
  67. uses: actions/setup-node@v4
  68. with:
  69. node-version: 20
  70. - name: Cache node dependencies
  71. uses: actions/cache@v4
  72. with:
  73. path: '**/node_modules'
  74. key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
  75. - name: Run lint
  76. run: yarn lint
  77. test:
  78. needs: [clippy-lint, yarn-lint]
  79. runs-on: ubuntu-latest
  80. steps:
  81. - name: install rust
  82. uses: dtolnay/rust-toolchain@stable
  83. with:
  84. toolchain: stable
  85. - name: Cache rust
  86. uses: Swatinem/rust-cache@v2
  87. - uses: actions/checkout@v4
  88. - name: Use Node ${{ matrix.node }}
  89. uses: actions/setup-node@v4
  90. with:
  91. node-version: 20
  92. - name: Cache node dependencies
  93. uses: actions/cache@v3
  94. with:
  95. path: '**/node_modules'
  96. key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
  97. - name: install node_modules
  98. run: |
  99. export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
  100. yarn --frozen-lockfile
  101. - uses: actions/cache@v4
  102. name: cache solana cli
  103. id: cache-solana
  104. with:
  105. path: |
  106. ~/.cache/solana/
  107. ~/.local/share/solana/
  108. key: solana-${{ runner.os }}-v0000-${{ env.solana_version }}
  109. - name: setup solana
  110. run: |
  111. export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
  112. solana --version
  113. solana-keygen new --silent --no-bip39-passphrase
  114. - name: Set deployments keys
  115. run: |
  116. mkdir -p target/deploy
  117. echo ${{ secrets.WORLD }} > target/deploy/world-keypair.json
  118. echo ${{ secrets.BOLT_COMPONENT }} > target/deploy/bolt_component-keypair.json
  119. echo ${{ secrets.BOLT_SYSTEM }} > target/deploy/bolt_system-keypair.json
  120. echo ${{ secrets.COMPONENT_POSITION }} > target/deploy/component_position-keypair.json
  121. echo ${{ secrets.COMPONENT_VELOCITY }} > target/deploy/component_velocity-keypair.json
  122. echo ${{ secrets.SYSTEM_APPLY_VELOCITY }} > target/deploy/system_apply_velocity-keypair.json
  123. echo ${{ secrets.SYSTEM_FLY }} > target/deploy/system_fly-keypair.json
  124. echo ${{ secrets.SYSTEM_SIMPLE_MOVEMENT }} > target/deploy/system_simple_movement-keypair.json
  125. - name: run build
  126. run: |
  127. export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
  128. npm i -g @coral-xyz/anchor-cli@${{ env.anchor_version }} ts-mocha typescript
  129. solana-test-validator > /dev/null &
  130. sleep 5
  131. solana airdrop -u l 100 tEsT3eV6RFCWs1BZ7AXTzasHqTtMnMLCB2tjQ42TDXD
  132. anchor build
  133. anchor idl build
  134. anchor deploy
  135. pkill -9 -f solana-test-validator
  136. - name: run tests
  137. run: |
  138. export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
  139. npm i -g @coral-xyz/anchor-cli@${{ env.anchor_version }} ts-mocha typescript
  140. anchor test
  141. - name: Install the Bolt CLI and create & build a new project
  142. run: |
  143. export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
  144. cargo install --path cli --force --locked
  145. bolt init test-project --force
  146. cd test-project
  147. cargo add --package position --path "../crates/bolt-lang" # Overrides the version with the local version
  148. cargo add --package movement --path "../crates/bolt-lang" # -
  149. yarn add file:../clients/bolt-sdk/ -D # Overrides the bolt ts SDK with the local version
  150. bolt build
  151. bolt test
  152. - uses: actions/upload-artifact@v3
  153. if: always()
  154. with:
  155. name: program-logs
  156. path: .anchor/program-logs/*