run-tests.yml 5.8 KB

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