run-network-tests.yml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. name: run-network-tests
  2. on:
  3. pull_request:
  4. workflow_dispatch:
  5. # TODO: add an input so dispatcher can specify a list of tests to run,
  6. # composed of the job ids separated by `:`
  7. # for eg.
  8. # 'network_tests_1:network_tests_3'
  9. # 'network_tests_2'
  10. # inputs:
  11. # test_to_run:
  12. # description: 'Tests to run'
  13. # required: false
  14. # default: 'all'
  15. jobs:
  16. build_images:
  17. name: Build joystream/node
  18. runs-on: ubuntu-latest
  19. outputs:
  20. use_artifact: ${{ steps.compute_shasum.outputs.shasum }}-joystream-node-docker-image.tar.gz
  21. steps:
  22. - uses: actions/checkout@v1
  23. - uses: actions/setup-node@v1
  24. with:
  25. node-version: '12.x'
  26. - id: compute_shasum
  27. name: Compute runtime code shasum
  28. run: |
  29. export RUNTIME_CODE_SHASUM=`scripts/runtime-code-shasum.sh`
  30. echo "::set-output name=shasum::${RUNTIME_CODE_SHASUM}"
  31. - name: Setup cache directory
  32. run: mkdir ~/docker-images
  33. - name: Cache docker images
  34. uses: actions/cache@v2
  35. env:
  36. cache-name: joystream-node-docker
  37. with:
  38. path: ~/docker-images
  39. key: ${{ env.cache-name }}-${{ steps.compute_shasum.outputs.shasum }}
  40. - name: Check if we have cached image
  41. continue-on-error: true
  42. run: |
  43. if [ -f ~/docker-images/joystream-node-docker-image.tar.gz ]; then
  44. docker load --input ~/docker-images/joystream-node-docker-image.tar.gz
  45. cp ~/docker-images/joystream-node-docker-image.tar.gz .
  46. fi
  47. - name: Check if we have pre-built image on Dockerhub
  48. continue-on-error: true
  49. run: |
  50. if ! [ -f joystream-node-docker-image.tar.gz ]; then
  51. docker pull joystream/node:${{ steps.compute_shasum.outputs.shasum }}
  52. docker image tag joystream/node:${{ steps.compute_shasum.outputs.shasum }} joystream/node:latest
  53. docker save --output joystream-node-docker-image.tar joystream/node:latest
  54. gzip joystream-node-docker-image.tar
  55. cp joystream-node-docker-image.tar.gz ~/docker-images/
  56. fi
  57. - name: Build new joystream/node image
  58. run: |
  59. if ! [ -f joystream-node-docker-image.tar.gz ]; then
  60. docker build . --file joystream-node.Dockerfile --tag joystream/node
  61. docker save --output joystream-node-docker-image.tar joystream/node
  62. gzip joystream-node-docker-image.tar
  63. cp joystream-node-docker-image.tar.gz ~/docker-images/
  64. fi
  65. - name: Save joystream/node image to Artifacts
  66. uses: actions/upload-artifact@v2
  67. with:
  68. name: ${{ steps.compute_shasum.outputs.shasum }}-joystream-node-docker-image.tar.gz
  69. path: joystream-node-docker-image.tar.gz
  70. network_tests_1:
  71. name: Network Integration Runtime Tests
  72. if: contains(github.event.pull_request.labels.*.name, 'run-network-tests') || github.event.push != null
  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: yarn install --frozen-lockfile
  90. - name: Ensure tests are runnable
  91. run: yarn workspace network-tests build
  92. - name: Execute network tests
  93. run: tests/network-tests/run-tests.sh
  94. network_tests_2:
  95. name: Query Node Tests (Placeholder)
  96. if: contains(github.event.pull_request.labels.*.name, 'run-network-tests') || github.event.push != null
  97. needs: build_images
  98. runs-on: ubuntu-latest
  99. steps:
  100. - uses: actions/checkout@v1
  101. - uses: actions/setup-node@v1
  102. with:
  103. node-version: '12.x'
  104. - name: Get artifacts
  105. uses: actions/download-artifact@v2
  106. with:
  107. name: ${{ needs.build_images.outputs.use_artifact }}
  108. - name: Install artifacts
  109. run: |
  110. docker load --input joystream-node-docker-image.tar.gz
  111. docker images
  112. - name: Install packages and dependencies
  113. run: yarn install --frozen-lockfile
  114. - name: Ensure tests are runnable
  115. run: yarn workspace network-tests build
  116. - name: Start chain
  117. run: docker-compose up -d
  118. # - name: Execute network tests
  119. # run: yarn workspace network-tests test
  120. network_tests_3:
  121. name: Storage Node Tests
  122. if: contains(github.event.pull_request.labels.*.name, 'run-network-tests') || github.event.push != null
  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 storage-node build
  142. - name: Build storage node
  143. run: yarn workspace storage-node build
  144. - name: Start chain
  145. run: docker-compose up -d
  146. - name: Execute tests
  147. run: DEBUG=* yarn storage-cli dev-init