Ver código fonte

network tests workflow: single file

Mokhtar Naamani 4 anos atrás
pai
commit
362ecb93c4

+ 0 - 130
.github/workflows/run-network-tests-push.yml

@@ -1,130 +0,0 @@
-name: run-network-tests-branch
-on:
-  push:
-  workflow_dispatch:
-
-jobs:
-  prepare_docker_images:
-    name: Build new images
-    runs-on: ubuntu-latest
-    outputs:
-      joystream_node_tag: ${{ steps.docker_build.outputs.tag }}
-    steps:
-      - uses: actions/checkout@v1
-      - name: Login to DockerHub
-        uses: docker/login-action@v1
-        with:
-          username: ${{ secrets.DOCKERHUB_USERNAME }}
-          password: ${{ secrets.DOCKERHUB_PASSWORD }}
-
-      - id: compute_shasum
-        name: Compute runtime code shasum
-        run: |
-          export RUNTIME_CODE_SHASUM=`scripts/runtime-code-shasum.sh`
-          echo "::set-output name=shasum::${RUNTIME_CODE_SHASUM}"
-
-      - name: Setup cache directory
-        run: mkdir ~/docker-images
-
-      - name: Docker images cache
-        uses: actions/cache@v2
-        env:
-          cache-name: joystream-node-docker
-        with:
-          path: ~/docker-images
-          key: ${{ env.cache-name }}-${{ steps.compute_shasum.outputs.shasum }}
-
-      - id: docker_build
-        name: Build and publish docker images
-        env:
-          RUNTIME_CODE_SHASUM: ${{ steps.compute_shasum.outputs.shasum }}
-        run: |
-          function docker_tag_exists() {
-            curl --silent -f -lSL https://index.docker.io/v1/repositories/joystream/node/tags/$1 > /dev/null
-          }
-
-          if docker_tag_exists ${{ env.RUNTIME_CODE_SHASUM }}; then
-            export JOYSTREAM_NODE_TAG=${{ env.RUNTIME_CODE_SHASUM }}
-            docker pull joystream/node:${JOYSTREAM_NODE_TAG}
-            docker image tag joystream/node:${JOYSTREAM_NODE_TAG} joystream/node:latest
-          else
-            export JOYSTREAM_NODE_TAG=latest
-            docker-compose build
-            docker image tag joystream/node joystream/node:${{ env.RUNTIME_CODE_SHASUM }}
-            docker push joystream/node:${{ env.RUNTIME_CODE_SHASUM }}
-          fi
-
-          # update cache
-          docker save --output joystream-node-docker-image.tar joystream/node:latest
-          gzip joystream-node-docker-image.tar
-          cp joystream-node-docker-image.tar.gz ~/docker-images/
-
-          echo "::set-output name=tag::${{ env.RUNTIME_CODE_SHASUM }}"
-
-  run_network_tests_1:
-    name: Network Integration Runtime Tests
-    needs: prepare_docker_images
-    runs-on: ubuntu-latest
-    env:
-      JOYSTREAM_NODE_TAG: ${{ needs.prepare_docker_images.outputs.joystream_node_tag }}
-    steps:
-      - uses: actions/checkout@v1
-      - uses: actions/setup-node@v1
-        with:
-          node-version: '12.x'
-      - name: Install packages and dependencies
-        run: yarn install --frozen-lockfile
-      - name: Ensure tests are runnable
-        run: yarn workspace network-tests build
-      - name: Pull joystream/node image from Dockerhub
-        run: docker-compose pull
-      - name: Start chain
-        run: docker-compose up -d
-      - name: Execute network tests
-        run: yarn workspace network-tests test
-
-  run_network_tests_2:
-    name: Query Node Tests (Placeholder)
-    needs: prepare_docker_images
-    runs-on: ubuntu-latest
-    env:
-      JOYSTREAM_NODE_TAG: ${{ needs.prepare_docker_images.outputs.joystream_node_tag }}
-    steps:
-      - uses: actions/checkout@v1
-      - uses: actions/setup-node@v1
-        with:
-          node-version: '12.x'
-      - name: Install packages and dependencies
-        run: yarn install --frozen-lockfile
-      - name: Ensure tests are runnable
-        run: yarn workspace network-tests build
-      - name: Pull joystream/node image from Dockerhub
-        run: docker-compose pull
-      - name: Start chain
-        run: docker-compose up -d
-      # - name: Execute network tests
-      #   run: yarn workspace network-tests test
-
-  run_network_tests_3:
-    name: Storage Node Tests
-    needs: prepare_docker_images
-    runs-on: ubuntu-latest
-    env:
-      JOYSTREAM_NODE_TAG: ${{ needs.prepare_docker_images.outputs.joystream_node_tag }}
-    steps:
-      - uses: actions/checkout@v1
-      - uses: actions/setup-node@v1
-        with:
-          node-version: '12.x'
-      - name: Install packages and dependencies
-        run: |
-          yarn install --frozen-lockfile
-          yarn workspace storage-node build
-      - name: Build storage node
-        run: yarn workspace storage-node build
-      - name: Pull joystream/node image from Dockerhub
-        run: docker-compose pull
-      - name: Start chain
-        run: docker-compose up -d
-      - name: Execute tests
-        run: DEBUG=* yarn storage-cli dev-init

+ 19 - 14
.github/workflows/run-network-tests-pull-request.yml → .github/workflows/run-network-tests.yml

@@ -2,11 +2,12 @@ name: run-network-tests-pull-request
 on:
   pull_request:
     types: [labeled, synchronize]
+  push:
+  workflow_dispatch:
 
 jobs:
   build_images:
     name: Prepare joystream/node docker image
-    if: contains(github.event.pull_request.labels.*.name, 'run-network-tests')
     runs-on: ubuntu-latest
     outputs:
       use_artifact: ${{ steps.compute_shasum.outputs.shasum }}-joystream-node-docker-image.tar.gz
@@ -27,7 +28,7 @@ jobs:
             Cargo.lock
             Cargo.toml
 
-      # TODO: Look for change in source code but no corresponding version bump of runtime or binaries
+      # TODO: For a pull request Look for change in source code but no corresponding version bump of runtime or binaries
       # - name: Check version modified correctly
       #   if: env.GIT_DIFF
 
@@ -37,18 +38,6 @@ jobs:
           export RUNTIME_CODE_SHASUM=`scripts/runtime-code-shasum.sh`
           echo "::set-output name=shasum::${RUNTIME_CODE_SHASUM}"
 
-      # Theis step is pointeless!
-      # The intention here was to fetch an artifact from a previous workflow run.
-      # This can be done using GitHub REST API
-      # https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#download-an-artifact
-      # Problem: It doesn't work anymore without authentication!
-      # https://github.com/actions/upload-artifact/issues/51
-      # - name: Check if we have a pre-built image in Artifacts
-      #   continue-on-error: true
-      #   uses: actions/download-artifact@v2
-      #   with:
-      #     name: ${{ steps.compute_shasum.outputs.shasum }}-joystream-node-docker-image.tar.gz
-
       - name: Setup cache directory
         run: mkdir ~/docker-images
 
@@ -100,8 +89,22 @@ jobs:
           path: joystream-node-docker-image.tar.gz
         if: env.UPLOAD_NEW_ARTIFACT
 
+      - name: Login to DockerHub
+        uses: docker/login-action@v1
+        with:
+          username: ${{ secrets.DOCKERHUB_USERNAME }}
+          password: ${{ secrets.DOCKERHUB_PASSWORD }}
+        if: github.event.push != null && secrets.DOCKERHUB_USERNAME != null && secrets.DOCKERHUB_PASSWORD != null
+
+      - name: Publish new image to DockerHub
+        run: |
+          docker image tag joystream/node joystream/node:${{ steps.compute_shasum.outputs.shasum }}
+          docker push joystream/node:${{ steps.compute_shasum.outputs.shasum }}
+        if: github.event.push != null && secrets.DOCKERHUB_USERNAME != null && secrets.DOCKERHUB_PASSWORD != null
+  
   network_tests_1:
     name: Network Integration Runtime Tests
+    if: contains(github.event.pull_request.labels.*.name, 'run-network-tests') || github.event.push || github.event.dispatch
     needs: build_images
     runs-on: ubuntu-latest
     steps:
@@ -128,6 +131,7 @@ jobs:
 
   network_tests_2:
     name: Query Node Tests (Placeholder)
+    if: contains(github.event.pull_request.labels.*.name, 'run-network-tests') || github.event.push || github.event.dispatch
     needs: build_images
     runs-on: ubuntu-latest
     steps:
@@ -154,6 +158,7 @@ jobs:
 
   network_tests_3:
     name: Storage Node Tests
+    if: contains(github.event.pull_request.labels.*.name, 'run-network-tests') || github.event.push || github.event.dispatch
     needs: build_images
     runs-on: ubuntu-latest
     steps: