run-tests.yml 5.7 KB

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