run-network-tests.yml 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. name: run-network-tests
  2. on:
  3. pull_request:
  4. types: [opened, synchronize]
  5. workflow_dispatch:
  6. # TODO: add an input so dispatcher can specify a list of tests to run,
  7. # composed of the job ids separated by `:`
  8. # for eg.
  9. # 'network_tests_1:network_tests_3'
  10. # 'network_tests_2'
  11. # inputs:
  12. # test_to_run:
  13. # description: 'Tests to run'
  14. # required: false
  15. # default: 'all'
  16. jobs:
  17. build_images:
  18. name: Build joystream/node
  19. runs-on: ubuntu-latest
  20. outputs:
  21. use_artifact: ${{ steps.compute_shasum.outputs.shasum }}-joystream-node-docker-image.tar.gz
  22. steps:
  23. - uses: actions/checkout@v1
  24. - uses: actions/setup-node@v1
  25. with:
  26. node-version: '12.x'
  27. - id: compute_shasum
  28. name: Compute runtime code shasum
  29. run: |
  30. export RUNTIME_CODE_SHASUM=`scripts/runtime-code-shasum.sh`
  31. echo "::set-output name=shasum::${RUNTIME_CODE_SHASUM}"
  32. - name: Setup cache directory
  33. run: mkdir ~/docker-images
  34. - name: Cache docker images
  35. uses: actions/cache@v2
  36. env:
  37. cache-name: joystream-node-docker
  38. with:
  39. path: ~/docker-images
  40. key: ${{ env.cache-name }}-${{ steps.compute_shasum.outputs.shasum }}
  41. - name: Check if we have cached image
  42. continue-on-error: true
  43. run: |
  44. if [ -f ~/docker-images/joystream-node-docker-image.tar.gz ]; then
  45. docker load --input ~/docker-images/joystream-node-docker-image.tar.gz
  46. cp ~/docker-images/joystream-node-docker-image.tar.gz .
  47. fi
  48. - name: Check if we have pre-built image on Dockerhub
  49. continue-on-error: true
  50. run: |
  51. if ! [ -f joystream-node-docker-image.tar.gz ]; then
  52. docker pull joystream/node:${{ steps.compute_shasum.outputs.shasum }}
  53. docker image tag joystream/node:${{ steps.compute_shasum.outputs.shasum }} joystream/node:latest
  54. docker save --output joystream-node-docker-image.tar joystream/node:latest
  55. gzip joystream-node-docker-image.tar
  56. cp joystream-node-docker-image.tar.gz ~/docker-images/
  57. fi
  58. - name: Build new joystream/node image
  59. run: |
  60. if ! [ -f joystream-node-docker-image.tar.gz ]; then
  61. docker build . --file joystream-node.Dockerfile --tag joystream/node
  62. docker save --output joystream-node-docker-image.tar joystream/node
  63. gzip joystream-node-docker-image.tar
  64. cp joystream-node-docker-image.tar.gz ~/docker-images/
  65. fi
  66. - name: Save joystream/node image to Artifacts
  67. uses: actions/upload-artifact@v2
  68. with:
  69. name: ${{ steps.compute_shasum.outputs.shasum }}-joystream-node-docker-image.tar.gz
  70. path: joystream-node-docker-image.tar.gz
  71. basic_runtime_with_upgrade:
  72. name: Integration Tests (Runtime Upgrade)
  73. needs: build_images
  74. runs-on: ubuntu-latest
  75. steps:
  76. - uses: actions/checkout@v1
  77. - uses: actions/setup-node@v1
  78. with:
  79. node-version: '12.x'
  80. - name: Get artifacts
  81. uses: actions/download-artifact@v2
  82. with:
  83. name: ${{ needs.build_images.outputs.use_artifact }}
  84. - name: Install artifacts
  85. run: |
  86. docker load --input joystream-node-docker-image.tar.gz
  87. docker images
  88. - name: Install packages and dependencies
  89. run: |
  90. yarn install --frozen-lockfile
  91. yarn workspace @joystream/types build
  92. - name: Ensure tests are runnable
  93. run: yarn workspace network-tests build
  94. - name: Execute network tests
  95. run: RUNTIME=babylon tests/network-tests/run-tests.sh full
  96. basic_runtime:
  97. name: Integration Tests (New Chain)
  98. needs: build_images
  99. runs-on: ubuntu-latest
  100. steps:
  101. - uses: actions/checkout@v1
  102. - uses: actions/setup-node@v1
  103. with:
  104. node-version: '12.x'
  105. - name: Get artifacts
  106. uses: actions/download-artifact@v2
  107. with:
  108. name: ${{ needs.build_images.outputs.use_artifact }}
  109. - name: Install artifacts
  110. run: |
  111. docker load --input joystream-node-docker-image.tar.gz
  112. docker images
  113. - name: Install packages and dependencies
  114. run: |
  115. yarn install --frozen-lockfile
  116. yarn workspace @joystream/types build
  117. - name: Ensure tests are runnable
  118. run: yarn workspace network-tests build
  119. - name: Execute network tests
  120. run: tests/network-tests/run-tests.sh full
  121. content_dir_init:
  122. name: Content Directory Initialization
  123. needs: build_images
  124. runs-on: ubuntu-latest
  125. steps:
  126. - uses: actions/checkout@v1
  127. - uses: actions/setup-node@v1
  128. with:
  129. node-version: '12.x'
  130. - name: Get artifacts
  131. uses: actions/download-artifact@v2
  132. with:
  133. name: ${{ needs.build_images.outputs.use_artifact }}
  134. - name: Install artifacts
  135. run: |
  136. docker load --input joystream-node-docker-image.tar.gz
  137. docker images
  138. - name: Install packages and dependencies
  139. run: |
  140. yarn install --frozen-lockfile
  141. yarn workspace @joystream/types build
  142. - name: Start chain
  143. run: docker-compose up -d joystream-node
  144. - name: Initialize the content directory
  145. run: yarn workspace api-scripts initialize-content-lead
  146. query_node:
  147. name: Query Node Integration Tests
  148. needs: build_images
  149. runs-on: ubuntu-latest
  150. steps:
  151. - uses: actions/checkout@v1
  152. - uses: actions/setup-node@v1
  153. with:
  154. node-version: '12.x'
  155. - name: Get artifacts
  156. uses: actions/download-artifact@v2
  157. with:
  158. name: ${{ needs.build_images.outputs.use_artifact }}
  159. - name: Install artifacts
  160. run: |
  161. docker load --input joystream-node-docker-image.tar.gz
  162. docker images
  163. - name: Install packages and dependencies
  164. run: |
  165. yarn install --frozen-lockfile
  166. yarn workspace @joystream/types build
  167. - name: Ensure query-node builds
  168. run: yarn workspace query-node-root build
  169. - name: Ensure tests are runnable
  170. run: yarn workspace network-tests build
  171. # Bring up hydra query-node development instance, then run content directory
  172. # integration tests
  173. - name: Execute Tests
  174. run: query-node/run-tests.sh
  175. storage_node:
  176. name: Storage Node Tests
  177. needs: build_images
  178. runs-on: ubuntu-latest
  179. steps:
  180. - uses: actions/checkout@v1
  181. - uses: actions/setup-node@v1
  182. with:
  183. node-version: '12.x'
  184. - name: Get artifacts
  185. uses: actions/download-artifact@v2
  186. with:
  187. name: ${{ needs.build_images.outputs.use_artifact }}
  188. - name: Install artifacts
  189. run: |
  190. docker load --input joystream-node-docker-image.tar.gz
  191. docker images
  192. - name: Install packages and dependencies
  193. run: |
  194. yarn install --frozen-lockfile
  195. yarn workspace @joystream/types build
  196. - name: Build storage node
  197. run: yarn workspace storage-node build
  198. - name: Start Services
  199. run: |
  200. docker-compose up -d ipfs
  201. docker-compose up -d joystream-node
  202. - name: Configure and start development storage node
  203. run: |
  204. DEBUG=* yarn storage-cli dev-init
  205. docker-compose up -d colossus
  206. - name: Test uploading
  207. run: |
  208. sleep 6
  209. export DEBUG=joystream:*
  210. yarn storage-cli upload ./pioneer/packages/apps/public/images/default-thumbnail.png 1 0
  211. # Wait for storage-node to set status Accepted on uploaded content
  212. sleep 6
  213. cd utils/api-scripts/
  214. # Assume only one accepted data object was created
  215. CONTENT_ID=`yarn --silent script get-first-content-id | tail -n2 | head -n1`
  216. yarn storage-cli download http://localhost:3001 ${CONTENT_ID} ./download.png