git.delta.rocks / unique-network / refs/commits / 1e1dae4deafd

difftreelog

source

.github/workflows/try-runtime.yml8.8 KiBsourcehistory
1# Try-runtime checks2# https://cryptousetech.atlassian.net/wiki/spaces/CI/pages/2587656213/Try+runtime34# Triger: only call from main workflow(re-usable workflows)5on:6  workflow_call:78# A workflow run is made up of one or more jobs that can run sequentially or in parallel9jobs:10  prepare-execution-marix:1112    name: Prepare execution matrix1314    runs-on: self-hosted-ci15    outputs:16      matrix: ${{ steps.create_matrix.outputs.matrix }}1718    steps:1920      - name: Clean Workspace21        uses: AutoModality/action-clean@v1.1.02223      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it24      - uses: actions/checkout@v3.1.025        with:26          ref: ${{ github.head_ref }}  #Checking out head commit2728      - name: Read .env file29        uses: xom9ikk/dotenv@v23031      - name: Create Execution matrix32        uses: CertainLach/create-matrix-action@v433        id: create_matrix34        with:35          matrix: |36            network {opal}, wasm_name {opal}, replica_from_address {${{ env.OPAL_REPLICA_FROM }}}37            network {quartz}, wasm_name {quartz}, replica_from_address {${{ env.QUARTZ_REPLICA_FROM }}}38            network {unique}, wasm_name {unique}, replica_from_address {${{ env.UNIQUE_REPLICA_FROM }}}3940  try-runtime-build:41    needs: prepare-execution-marix4243    # The type of runner that the job will run on44    runs-on: [self-hosted-ci]45    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.4647    name: ${{ matrix.network }}-try-runtime-build48    strategy:49      matrix:50        include: ${{fromJson(needs.prepare-execution-marix.outputs.matrix)}}5152    steps:5354      - name: Clean Workspace55        uses: AutoModality/action-clean@v1.1.05657      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it58      - uses: actions/checkout@v3.1.059        with:60          ref: ${{ github.head_ref }}  #Checking out head commit6162      # Prepare SHA  63      - name: Prepare SHA64        uses: ./.github/actions/prepare6566      - name: Read .env file67        uses: xom9ikk/dotenv@v26869      - name: Log in to Docker Hub70        uses: docker/login-action@v2.1.071        with:72          username: ${{ secrets.CORE_DOCKERHUB_USERNAME }}73          password: ${{ secrets.CORE_DOCKERHUB_TOKEN }}7475      # Build main image for TRY-RUNTIME76      - name: Generate ENV related extend Dockerfile file77        uses: cuchi/jinja2-action@v1.2.078        with:79          template: .docker/Dockerfile-try-runtime.j280          output_file: .docker/Dockerfile-try-runtime.${{ matrix.network }}.yml81          variables: |82            RUST_TOOLCHAIN=${{ env.RUST_TOOLCHAIN }}83            NETWORK=${{ matrix.network }}84            WASM_NAME=${{ matrix.wasm_name }}85            REPLICA_FROM=${{ matrix.replica_from_address }}8687      - name: Show build Dockerfile88        run: cat .docker/Dockerfile-try-runtime.${{ matrix.network }}.yml8990      - name: Run find-and-replace to remove slashes from branch name91        uses: mad9000/actions-find-and-replace-string@492        id: branchname93        with:94          source: ${{ github.head_ref }}95          find: '/'96          replace: '-'9798      - name: Set build SHA99        shell: bash100        run: |101          echo "BUILD_SHA=${LAST_COMMIT_SHA:0:8}" >> $GITHUB_ENV102103      - name: Build the stack104        run: cd .docker/ && docker build --no-cache --file ./Dockerfile-try-runtime.${{ matrix.network }}.yml --tag uniquenetwork/ci-tryruntime-local:${{ matrix.network }}-${{ steps.branchname.outputs.value }}-$BUILD_SHA ../105106      - name: Push docker image version107        run: docker push uniquenetwork/ci-tryruntime-local:${{ matrix.network }}-${{ steps.branchname.outputs.value }}-$BUILD_SHA108109      - name: Remove builder cache110        if: always()                   # run this step always111        run: |112          docker builder prune -f113          docker system prune -f114115116  try-runtime-tests:117    needs: [prepare-execution-marix, try-runtime-build]118    # The type of runner that the job will run on119    runs-on: [medium]120121    timeout-minutes: 600122123    name: ${{ matrix.network }}-try-runtime-tests124125    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.126127    strategy:128      matrix:129        include: ${{fromJson(needs.prepare-execution-marix.outputs.matrix)}}130131    steps:132      - name: Skip if pull request is in Draft133        if: github.event.pull_request.draft == true134        run: exit 1135136      - name: Clean Workspace137        uses: AutoModality/action-clean@v1.1.0138139      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it140      - uses: actions/checkout@v3.1.0141        with:142          ref: ${{ github.head_ref }}  #Checking out head commit143144      - name: Prepare145        uses: ./.github/actions/prepare146147      - name: Set build SHA148        shell: bash149        run: |150          echo "BUILD_SHA=${LAST_COMMIT_SHA:0:8}" >> $GITHUB_ENV151152      - name: Run find-and-replace to remove slashes from branch name153        uses: mad9000/actions-find-and-replace-string@4154        id: branchname155        with:156          source: ${{ github.head_ref }}157          find: '/'158          replace: '-'159160      - name: Read .env file161        uses: xom9ikk/dotenv@v2162163      - name: Generate ENV related extend file for docker-compose164        uses: cuchi/jinja2-action@v1.2.0165        with:166          template: .docker/docker-compose.try-runtime.j2167          output_file: .docker/docker-compose.try-runtime.${{ matrix.network }}.yml168          variables: |169            NETWORK=${{ matrix.network }}170            BUILD_TAG=${{ steps.branchname.outputs.value }}-$BUILD_SHA171172      - name: Show build configuration173        run: cat .docker/docker-compose.try-runtime.${{ matrix.network }}.yml174175      - uses: actions/setup-node@v3.5.1176        with:177          node-version: 20178179      - name: Log in to Docker Hub180        uses: docker/login-action@v2.1.0181        with:182          username: ${{ secrets.CORE_DOCKERHUB_USERNAME }}183          password: ${{ secrets.CORE_DOCKERHUB_TOKEN }}184185      - name: Build the stack186        run: docker-compose -f ".docker/docker-compose.try-runtime.${{ matrix.network }}.yml" up -d --remove-orphans --force-recreate --timeout 300187188      - name: Check if docker logs consist logs related to Runtime Upgrade testing.189        if: success()190        run: |191          counter=300192          counter_life=0193          function check_container_status {194                docker inspect -f {{.State.Running}} try-runtime195          }196          function do_docker_logs {197                docker logs --details try-runtime 2>&1 | grep -i 'TryRuntime_on_runtime_upgrade executed without errors. Consumed'198          }199          function is_started {200                if [ "$(check_container_status)" == "true" ]; then201                        echo "Container: try-runtime RUNNING";202                        echo "Check Docker logs"203                        DOCKER_LOGS=$(do_docker_logs)204                        if [[ -n ${DOCKER_LOGS} ]]; then205                                echo "TryRuntime_on_runtime_upgrade executed without errors."206                                return 0207                        else208                                echo "Message not found in logs output, repeating..."209                                return 1210                        fi211                else212                    (( counter_life++ ))213                    echo "Container try-runtime not RUNNING" $counter_life "time"214                    return 1215                fi216          }217218          while ! is_started; do219                echo "Waiting for special message in log files "220                sleep 30s221                counter=$(( $counter - 1 ))222                echo "Counter: $counter"223                if [ "$counter" -gt "0" ] && [ "$counter_life" -lt "3" ]; then224                         continue225                else226                         echo "Counter reached zero, yet upgrade is not finished correctly or Container try-runtime is not RUNNING"227                         exit 1228                fi229          done230          echo "Halting script"231          exit 0232        shell: bash233234      - name: Collect Docker Logs235        if: success() || failure()236        uses: jwalton/gh-docker-logs@v2.2.1237        with:238          dest: './try-runtime-logs.${{ matrix.network }}'239240      - name: Show docker logs241        if: success() || failure()242        run: cat './try-runtime-logs.${{ matrix.network }}/try-runtime.log'243244      - name: Stop running containers245        if: always()                   # run this step always246        run: docker-compose -f ".docker/docker-compose.try-runtime.${{ matrix.network }}.yml" down247248      - name: Remove builder cache249        if: always()                   # run this step always250        run: |251          docker builder prune -f -a252          docker system prune -f253          docker image prune -f -a