run-network-tests-pull-request.yml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. name: run-network-tests-pull-request
  2. on:
  3. pull_request:
  4. types: [labeled, synchronize]
  5. jobs:
  6. prepare_artifacts:
  7. name: Prepare joystream/node docker image
  8. if: contains(github.event.pull_request.labels.*.name, 'run-network-tests')
  9. runs-on: ubuntu-latest
  10. outputs:
  11. use_artifact: ${{ steps.final.outputs.artifact_name }}
  12. steps:
  13. - uses: actions/checkout@v1
  14. - uses: actions/setup-node@v1
  15. with:
  16. node-version: '12.x'
  17. - uses: technote-space/get-diff-action@v3
  18. with:
  19. PREFIX_FILTER: |
  20. node
  21. runtime-modules
  22. utils/chain-spec-builder
  23. SUFFIX_FILTER: |
  24. .rs
  25. FILES: |
  26. Cargo.lock
  27. Cargo.toml
  28. - id: compute_shasum
  29. name: Compute runtime code shasum
  30. run: |
  31. export RUNTIME_CODE_SHASUM=`tar -c runtime runtime-modules utils/chain-spec-builder | shasum | cut -d " " -f 1`
  32. echo "::set-output name=shasum::${RUNTIME_CODE_SHASUM}"
  33. if: env.GIT_DIFF
  34. - name: Check if we have a pre-built image
  35. continue-on-error: true
  36. uses: actions/download-artifact@v2
  37. with:
  38. name: ${{ steps.compute_shasum.outputs.shasum }}-joystream-node-docker-image.tar.gz
  39. if: env.GIT_DIFF
  40. - name: Build new joystream/node image
  41. run: |
  42. docker-compose build
  43. docker save --output joystream-node-docker-image.tar joystream/node
  44. gzip joystream-node-docker-image.tar
  45. echo "::set-env name=DO_UPLOAD::true"
  46. if: env.GIT_DIFF && ${{ failure() }}
  47. - name: Upload new joystream/node image
  48. uses: actions/upload-artifact@v2
  49. with:
  50. name: ${{ steps.compute_shasum.outputs.shasum }}-joystream-node-docker-image.tar.gz
  51. path: joystream-node-docker-image.tar.gz
  52. if: env.DO_UPLOAD
  53. # Only set the final output shasum in last step when we know we have an artifact
  54. # which we will use.
  55. - id: final
  56. name: Set final output
  57. run: echo "::set-output name=shasum::${{ steps.compute_shasum.outputs.shasum }}"
  58. if: env.GIT_DIFF
  59. network_tests_1:
  60. name: Network Integration Tests (pull request)
  61. needs: prepare_artifacts
  62. runs-on: ubuntu-latest
  63. steps:
  64. - uses: actions/checkout@v1
  65. - uses: actions/setup-node@v1
  66. with:
  67. node-version: '12.x'
  68. - name: Download Pre-built artifact
  69. uses: actions/download-artifact@v2
  70. with:
  71. name: ${{ needs.prepare_artifacts.outputs.artifact_name }}
  72. if: ${{ needs.prepare_artifacts.outputs.artifact_name }}
  73. - name: Install artifact
  74. run: |
  75. docker load --input joystream-node-docker-image.tar.gz
  76. docker images
  77. if: ${{ needs.prepare_artifacts.outputs.artifact_name }}
  78. - name: Pull joystream/node image for base branch from Dockerhub
  79. continue-on-error: true
  80. run: |
  81. export JOYSTREAM_NODE_TAG=${{ github.event.pull_request.base.ref }}
  82. docker-compose pull
  83. docker image tag joystream/node:${JOYSTREAM_NODE_TAG} joystream/node:latest
  84. if: needs.prepare_artifacts.outputs.artifact_name == null
  85. # If not relying on a prebuilt artifact, (ie. no runtime code changed)
  86. # but joystream/node image was not sucessfully pulled from dockerhub,
  87. # fallback to building from source!
  88. - name: Build joystream/node from source
  89. run: |
  90. if ! docker inspect joystream/node:latest > /dev/null 2>&1;
  91. then
  92. docker-compose build
  93. fi
  94. if: needs.prepare_docker_images.outputs.runtime_code_shasum == null
  95. - name: Install packages and dependencies
  96. run: yarn install --frozen-lockfile
  97. - name: Ensure tests are runnable
  98. run: yarn workspace network-tests build
  99. - name: Start chain
  100. run: docker-compose up -d
  101. - name: Execute network tests
  102. run: yarn workspace network-tests test