git.delta.rocks / unique-network / refs/commits / 232a7d92aded

difftreelog

source

.github/workflows/forkless-update-data.yml10.1 KiBsourcehistory
1# Forkless update with data replication2# https://cryptousetech.atlassian.net/wiki/spaces/CI/pages/2586869792/Forkless+update+with+data34# Triger: only call from main workflow(re-usable workflows)5on:6  workflow_call:789# A workflow run is made up of one or more jobs that can run sequentially or in parallel10jobs:1112  prepare-execution-marix:1314    name: Prepare execution matrix1516    runs-on: self-hosted-ci17    outputs:18      matrix: ${{ steps.create_matrix.outputs.matrix }}1920    steps:2122      - name: Clean Workspace23        uses: AutoModality/action-clean@v1.1.02425      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it26      - uses: actions/checkout@v3.1.027        with:28          ref: ${{ github.head_ref }}  #Checking out head commit2930      - name: Read .env file31        uses: xom9ikk/dotenv@v23233      - name: Create Execution matrix34        uses: CertainLach/create-matrix-action@v435        id: create_matrix36        with:37          # TODO: Remove state-version-0 after mainnet upgrade38          matrix: |39            network {quartz}, wasm_name {quartz}, mainnet_branch {${{ env.QUARTZ_MAINNET_BRANCH }}}, replica_from_address {${{ env.QUARTZ_REPLICA_FROM }}}, relay_branch {${{ env.KUSAMA_MAINNET_BRANCH }}}, extra_features {,state-version-0}40            network {unique}, wasm_name {unique}, mainnet_branch {${{ env.UNIQUE_MAINNET_BRANCH }}}, replica_from_address {${{ env.UNIQUE_REPLICA_FROM }}}, relay_branch {${{ env.POLKADOT_MAINNET_BRANCH }}}, extra_features {,state-version-0}41            network {opal}, wasm_name {opal}, mainnet_branch {${{ env.OPAL_MAINNET_BRANCH }}}, replica_from_address {${{ env.OPAL_REPLICA_FROM }}}, relay_branch {${{ env.UNIQUEWEST_MAINNET_BRANCH }}}, extra_features {,state-version-0}42            network {sapphire}, wasm_name {quartz}, mainnet_branch {${{ env.SAPPHIRE_MAINNET_BRANCH }}}, replica_from_address {${{ env.SAPPHIRE_REPLICA_FROM }}}, relay_branch {${{ env.UNIQUEEAST_MAINNET_BRANCH }}}, extra_features {,state-version-0}4344  forkless-data-build:45    needs: prepare-execution-marix46    # The type of runner that the job will run on47    runs-on: [self-hosted-ci,large]48    timeout-minutes: 13804950    name: ${{ matrix.network }}-data-build51    strategy:52      matrix:53        include: ${{fromJson(needs.prepare-execution-marix.outputs.matrix)}}5455    continue-on-error: true         #Do not stop testing of matrix runs failed.  As it decided during PR review - it required 50/50& Let's check it with false.5657    steps:58      - name: Clean Workspace59        uses: AutoModality/action-clean@v1.1.06061      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it62      - uses: actions/checkout@v3.1.063        with:64          ref: ${{ github.head_ref }}  #Checking out head commit6566      - name: Read .env file67        uses: xom9ikk/dotenv@v26869      # Prepare SHA  70      - name: Prepare SHA71        uses: ./.github/actions/prepare7273      # Build main image for FORKLESS-UPDATE-NODATA74      - name: Generate ENV related extend Dockerfile file75        uses: cuchi/jinja2-action@v1.2.076        with:77          template: .docker/Dockerfile-parachain-upgrade-data.j278          output_file: .docker/Dockerfile-parachain-upgrade-data.${{ matrix.network }}.yml79          variables: |80            RUST_TOOLCHAIN=${{ env.RUST_TOOLCHAIN }}81            NETWORK=${{ matrix.network }}82            MAINNET_BRANCH=${{ matrix.mainnet_branch }}83            WASM_NAME=${{ matrix.wasm_name }}84            RELAY_CHAIN_TYPE=${{ env.RELAY_CHAIN_TYPE }}85            POLKADOT_BUILD_BRANCH=${{ matrix.relay_branch }}86            REPLICA_FROM=${{ matrix.replica_from_address }}87            CHAINQL=${{ env.CHAINQL }}88            EXTRA_FEATURES=${{ matrix.extra_features }}8990      - name: Show build configuration91        run: cat .docker/Dockerfile-parachain-upgrade-data.${{ matrix.network }}.yml9293      - name: Run find-and-replace to remove slashes from branch name94        uses: mad9000/actions-find-and-replace-string@495        id: branchname96        with:97          source: ${{ github.head_ref }}98          find: '/'99          replace: '-'100101      - name: Set build SHA102        shell: bash103        run: |104          echo "BUILD_SHA=${LAST_COMMIT_SHA:0:8}" >> $GITHUB_ENV105106      - name: Build the stack107        run: cd .docker/ && docker build --no-cache --file ./Dockerfile-parachain-upgrade-data.${{ matrix.network }}.yml --tag uniquenetwork/ci-forkless-data-local:${{ matrix.network }}-${{ steps.branchname.outputs.value }}-$BUILD_SHA ../108109      - name: Log in to Docker Hub110        uses: docker/login-action@v2.1.0111        with:112          username: ${{ secrets.CORE_DOCKERHUB_USERNAME }}113          password: ${{ secrets.CORE_DOCKERHUB_TOKEN }}114115      - name: Push docker image version116        run: docker push uniquenetwork/ci-forkless-data-local:${{ matrix.network }}-${{ steps.branchname.outputs.value }}-$BUILD_SHA117118      - name: Remove builder cache119        if: always()                   # run this step always120        run: |121          docker builder prune -f122          docker system prune -f123124  forkless-data-tests:125    needs: [prepare-execution-marix, forkless-data-build]126    # The type of runner that the job will run on127    runs-on: [self-hosted-ci, large]128129    timeout-minutes: 600130131    name: ${{ matrix.network }}-data-tests132133    continue-on-error: true         #Do not stop testing of matrix runs failed.  As it decided during PR review - it required 50/50& Let's check it with false.134135    strategy:136      matrix:137        include: ${{fromJson(needs.prepare-execution-marix.outputs.matrix)}}138139    steps:140      - name: Skip if pull request is in Draft141        if: github.event.pull_request.draft == true142        run: exit 1143144      - name: Clean Workspace145        uses: AutoModality/action-clean@v1.1.0146147      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it148      - uses: actions/checkout@v3.1.0149        with:150          ref: ${{ github.head_ref }}  #Checking out head commit151152      - name: Prepare153        uses: ./.github/actions/prepare154155      - name: Set build SHA156        shell: bash157        run: |158          echo "BUILD_SHA=${LAST_COMMIT_SHA:0:8}" >> $GITHUB_ENV159160      - name: Run find-and-replace to remove slashes from branch name161        uses: mad9000/actions-find-and-replace-string@4162        id: branchname163        with:164          source: ${{ github.head_ref }}165          find: '/'166          replace: '-'167168      - name: Read .env file169        uses: xom9ikk/dotenv@v2170171      - name: Generate ENV related extend file for docker-compose172        uses: cuchi/jinja2-action@v1.2.0173        with:174          template: .docker/docker-compose.forkless-data.j2175          output_file: .docker/docker-compose.forkless-data.${{ matrix.network }}.yml176          variables: |177            NETWORK=${{ matrix.network }}178            BUILD_TAG=${{ steps.branchname.outputs.value }}-$BUILD_SHA179180      - name: Show build configuration181        run: cat .docker/docker-compose.forkless-data.${{ matrix.network }}.yml182183      - name: Log in to Docker Hub184        uses: docker/login-action@v2.1.0185        with:186          username: ${{ secrets.CORE_DOCKERHUB_USERNAME }}187          password: ${{ secrets.CORE_DOCKERHUB_TOKEN }}188189      - name: Build the stack190        run: docker-compose -f ".docker/docker-compose.forkless-data.${{ matrix.network }}.yml" up -d --remove-orphans --force-recreate --timeout 300191192      - uses: actions/setup-node@v3.5.1193        with:194          node-version: 16195196      - name: Check if docker logs consist logs related to Runtime Upgrade testing.197        if: success()198        run: |199          counter=160200          function check_container_status {201                docker inspect -f {{.State.Running}} forkless-data202          }203          function do_docker_logs {204                docker logs --details forkless-data  2>&1205          }206          function is_started {207                if [ "$(check_container_status)" == "true" ]; then208                        echo "Container: forkless-data RUNNING";209                        echo "Check Docker logs"210                        DOCKER_LOGS=$(do_docker_logs)211                        if [[ ${DOCKER_LOGS} = *"🛸 PARACHAINS' RUNTIME UPGRADE TESTING COMPLETE 🛸"* ]];then212                                echo "🛸 PARACHAINS' RUNTIME UPGRADE TESTING COMPLETE 🛸"213                                return 0214                        elif [[ ${DOCKER_LOGS} = *"🚧 PARACHAINS' RUNTIME UPGRADE TESTING FAILED 🚧"* ]];then215                                echo "🚧 PARACHAINS' RUNTIME UPGRADE TESTING FAILED 🚧"216                                return 1217                        else218                                echo "Message not found in logs output, repeating..."219                                return 1220                        fi221                else222                        echo "Container forkless-data not RUNNING"223                        echo "Halting all future checks"224                        exit 1225                fi226          exit 0227          }228          while ! is_started; do229                echo "Waiting for special message in log files "230                sleep 30s231                counter=$(( $counter - 1 ))232                echo "Counter: $counter"233                if [ "$counter" -gt "0" ]; then234                         continue235                else236                         echo "Counter reached zero, yet upgrade is not finished"237                         exit 1238                fi239          done240          echo "Halting script"241          exit 0242        shell: bash243244      - name: Collect Docker Logs245        if: success() || failure()246        uses: jwalton/gh-docker-logs@v2.2.1247        with:248          dest: './forkless-parachain-upgrade-data-logs.${{ matrix.features }}'249250      - name: Show Docker logs251        if: success() || failure()252        run: cat './forkless-parachain-upgrade-data-logs.${{ matrix.features }}/forkless-data.log'253254      - name: Stop running containers255        if: always()                   # run this step always256        run: docker-compose -f ".docker/docker-compose.forkless-data.${{ matrix.network }}.yml" down --volumes257258      - name: Remove builder cache259        if: always()                   # run this step always260        run: |261          docker builder prune -f -a262          docker system prune -f263          docker image prune -f -a