1name: xcm-testnet-build234on:5 workflow_call:6 7 8 workflow_dispatch:91011env:12 REPO_URL: ${{ github.server_url }}/${{ github.repository }}131415jobs:1617 prepare-execution-marix:1819 name: Prepare execution matrix2021 runs-on: [XL]22 outputs:23 matrix: ${{ steps.create_matrix.outputs.matrix }}2425 steps:2627 - name: Clean Workspace28 uses: AutoModality/action-clean@v1.1.02930 31 - uses: actions/checkout@v332 with:33 ref: ${{ github.head_ref }} 3435 - name: Read .env file36 uses: xom9ikk/dotenv@v23738 - name: Create Execution matrix39 uses: fabiocaccamo/create-matrix-action@v240 id: create_matrix41 with:42 matrix: |43 network {opal}, relay_branch {${{ env.UNIQUEWEST_MAINNET_BRANCH }}}, acala_version {${{ env.ACALA_BUILD_BRANCH }}}, moonbeam_version {${{ env.MOONBEAM_BUILD_BRANCH }}}, cumulus_version {${{ env.WESTMINT_BUILD_BRANCH }}}, runtest {testXcmOpal}44 network {quartz}, relay_branch {${{ env.KUSAMA_MAINNET_BRANCH }}}, acala_version {${{ env.KARURA_BUILD_BRANCH }}}, moonbeam_version {${{ env.MOONRIVER_BUILD_BRANCH }}}, cumulus_version {${{ env.STATEMINE_BUILD_BRANCH }}}, astar_version {${{ env.SHIDEN_BUILD_BRANCH }}}, runtest {testXcmQuartz}45 network {unique}, relay_branch {${{ env.POLKADOT_MAINNET_BRANCH }}}, acala_version {${{ env.ACALA_BUILD_BRANCH }}}, moonbeam_version {${{ env.MOONBEAM_BUILD_BRANCH }}}, cumulus_version {${{ env.STATEMINT_BUILD_BRANCH }}}, astar_version {${{ env.ASTAR_BUILD_BRANCH }}}, runtest {testXcmUnique}4647 xcm-build:48 49 needs: prepare-execution-marix50 51 runs-on: [XL]5253 timeout-minutes: 6005455 name: ${{ matrix.network }}-build5657 continue-on-error: true 5859 strategy:60 matrix:61 include: ${{fromJson(needs.prepare-execution-marix.outputs.matrix)}}6263 steps:64 - name: Skip if pull request is in Draft65 if: github.event.pull_request.draft == true66 run: exit 16768 - name: Clean Workspace69 uses: AutoModality/action-clean@v1.1.07071 72 - uses: actions/checkout@v373 with:74 ref: ${{ github.head_ref }} 7576 - name: Read .env file77 uses: xom9ikk/dotenv@v27879 - name: Log in to Docker Hub80 uses: docker/login-action@v2.0.081 with:82 username: ${{ secrets.CORE_DOCKERHUB_USERNAME }}83 password: ${{ secrets.CORE_DOCKERHUB_TOKEN }}8485 - name: Install jq86 run: sudo apt install jq -y8788 89 - name: Generate ENV related extend Dockerfile file for POLKADOT90 uses: cuchi/jinja2-action@v1.2.091 with:92 template: .docker/Dockerfile-polkadot.j293 output_file: .docker/Dockerfile-polkadot.${{ matrix.relay_branch }}.yml94 variables: |95 RUST_TOOLCHAIN=${{ env.RUST_TOOLCHAIN }}96 POLKADOT_BUILD_BRANCH=${{ matrix.relay_branch }}9798 - name: Check if the dockerhub repository contains the needed version POLKADOT99 run: |100 # aquire token101 TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'${{ secrets.CORE_DOCKERHUB_USERNAME }}'", "password": "'${{ secrets.CORE_DOCKERHUB_TOKEN }}'"}' https://hub.docker.com/v2/users/login/ | jq -r .token)102 export TOKEN=$TOKEN103104 # Get TAGS from DOCKERHUB POLKADOT repository105 POLKADOT_TAGS=$(curl -s -H "Authorization: JWT ${TOKEN}" https://hub.docker.com/v2/repositories/uniquenetwork/builder-polkadot/tags/?page_size=100 | jq -r '."results"[]["name"]')106 # Show TAGS107 echo "POLKADOT TAGS:"108 echo $POLKADOT_TAGS109 # Check correct version POLKADOT and build it if it doesn't exist in POLKADOT TAGS110 if [[ ${POLKADOT_TAGS[*]} =~ (^|[[:space:]])"${{ matrix.relay_branch }}"($|[[:space:]]) ]]; then111 echo "Repository has needed POLKADOT version";112 docker pull uniquenetwork/builder-polkadot:${{ matrix.relay_branch }}113 else114 echo "Repository has not needed POLKADOT version, so build it";115 cd .docker/ && docker build --no-cache --file ./Dockerfile-polkadot.${{ matrix.relay_branch }}.yml --tag uniquenetwork/builder-polkadot:${{ matrix.relay_branch }} .116 echo "Push needed POLKADOT version to the repository";117 docker push uniquenetwork/builder-polkadot:${{ matrix.relay_branch }}118 fi119 shell: bash120121 122 - name: Generate ENV related extend Dockerfile file for ACALA123 uses: cuchi/jinja2-action@v1.2.0124 with:125 template: .docker/Dockerfile-acala.j2126 output_file: .docker/Dockerfile-acala.${{ matrix.acala_version }}.yml127 variables: |128 RUST_TOOLCHAIN=${{ env.RUST_TOOLCHAIN }}129 ACALA_BUILD_BRANCH=${{ matrix.acala_version }}130131 - name: Check if the dockerhub repository contains the needed ACALA version132 run: |133 # aquire token134 TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'${{ secrets.CORE_DOCKERHUB_USERNAME }}'", "password": "'${{ secrets.CORE_DOCKERHUB_TOKEN }}'"}' https://hub.docker.com/v2/users/login/ | jq -r .token)135 export TOKEN=$TOKEN136137 # Get TAGS from DOCKERHUB repository138 ACALA_TAGS=$(curl -s -H "Authorization: JWT ${TOKEN}" https://hub.docker.com/v2/repositories/uniquenetwork/builder-acala/tags/?page_size=100 | jq -r '."results"[]["name"]')139 # Show TAGS140 echo "ACALA TAGS:"141 echo $ACALA_TAGS142 # Check correct version ACALA and build it if it doesn't exist in ACALA TAGS143 if [[ ${ACALA_TAGS[*]} =~ (^|[[:space:]])"${{ matrix.acala_version }}"($|[[:space:]]) ]]; then144 echo "Repository has needed ACALA version";145 docker pull uniquenetwork/builder-acala:${{ matrix.acala_version }}146 else147 echo "Repository has not needed ACALA version, so build it";148 cd .docker/ && docker build --no-cache --file ./Dockerfile-acala.${{ matrix.acala_version }}.yml --tag uniquenetwork/builder-acala:${{ matrix.acala_version }} .149 echo "Push needed ACALA version to the repository";150 docker push uniquenetwork/builder-acala:${{ matrix.acala_version }}151 fi152 shell: bash153154 155 - name: Generate ENV related extend Dockerfile file for MOONBEAM156 uses: cuchi/jinja2-action@v1.2.0157 with:158 template: .docker/Dockerfile-moonbeam.j2159 output_file: .docker/Dockerfile-moonbeam.${{ matrix.moonbeam_version }}.yml160 variables: |161 RUST_TOOLCHAIN=${{ env.RUST_TOOLCHAIN }}162 MOONBEAM_BUILD_BRANCH=${{ matrix.moonbeam_version }}163164 - name: Check if the dockerhub repository contains the needed MOONBEAM version165 run: |166 # aquire token167 TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'${{ secrets.CORE_DOCKERHUB_USERNAME }}'", "password": "'${{ secrets.CORE_DOCKERHUB_TOKEN }}'"}' https://hub.docker.com/v2/users/login/ | jq -r .token)168 export TOKEN=$TOKEN169170 # Get TAGS from DOCKERHUB repository171 MOONBEAM_TAGS=$(curl -s -H "Authorization: JWT ${TOKEN}" https://hub.docker.com/v2/repositories/uniquenetwork/builder-moonbeam/tags/?page_size=100 | jq -r '."results"[]["name"]')172 # Show TAGS173 echo "MOONBEAM TAGS:"174 echo $MOONBEAM_TAGS175 # Check correct version MOONBEAM and build it if it doesn't exist in MOONBEAM TAGS176 if [[ ${MOONBEAM_TAGS[*]} =~ (^|[[:space:]])"${{ matrix.moonbeam_version }}"($|[[:space:]]) ]]; then177 echo "Repository has needed MOONBEAM version";178 docker pull uniquenetwork/builder-moonbeam:${{ matrix.moonbeam_version }}179 else180 echo "Repository has not needed MOONBEAM version, so build it";181 cd .docker/ && docker build --no-cache --file ./Dockerfile-moonbeam.${{ matrix.moonbeam_version }}.yml --tag uniquenetwork/builder-moonbeam:${{ matrix.moonbeam_version }} .182 echo "Push needed MOONBEAM version to the repository";183 docker push uniquenetwork/builder-moonbeam:${{ matrix.moonbeam_version }}184 fi185 shell: bash186187 188 - name: Generate ENV related extend Dockerfile file for CUMULUS189 uses: cuchi/jinja2-action@v1.2.0190 with:191 template: .docker/Dockerfile-cumulus.j2192 output_file: .docker/Dockerfile-cumulus.${{ matrix.cumulus_version }}.yml193 variables: |194 RUST_TOOLCHAIN=${{ env.RUST_TOOLCHAIN }}195 CUMULUS_BUILD_BRANCH=${{ matrix.cumulus_version }}196197 - name: Check if the dockerhub repository contains the needed CUMULUS version198 run: | 199 # aquire token200 TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'${{ secrets.CORE_DOCKERHUB_USERNAME }}'", "password": "'${{ secrets.CORE_DOCKERHUB_TOKEN }}'"}' https://hub.docker.com/v2/users/login/ | jq -r .token)201 export TOKEN=$TOKEN202203 # Get TAGS from DOCKERHUB repository204 CUMULUS_TAGS=$(curl -s -H "Authorization: JWT ${TOKEN}" https://hub.docker.com/v2/repositories/uniquenetwork/builder-cumulus/tags/?page_size=100 | jq -r '."results"[]["name"]')205 # Show TAGS206 echo "CUMULUS TAGS:"207 echo $CUMULUS_TAGS208 # Check correct version CUMULUS and build it if it doesn't exist in CUMULUS TAGS209 if [[ ${CUMULUS_TAGS[*]} =~ (^|[[:space:]])"${{ matrix.cumulus_version }}"($|[[:space:]]) ]]; then210 echo "Repository has needed CUMULUS version";211 docker pull uniquenetwork/builder-cumulus:${{ matrix.cumulus_version }}212 else213 echo "Repository has not needed CUMULUS version, so build it";214 cd .docker/ && docker build --no-cache --file ./Dockerfile-cumulus.${{ matrix.cumulus_version }}.yml --tag uniquenetwork/builder-cumulus:${{ matrix.cumulus_version }} .215 echo "Push needed CUMULUS version to the repository";216 docker push uniquenetwork/builder-cumulus:${{ matrix.cumulus_version }}217 fi218 shell: bash219220221 222 - name: Generate ENV related extend Dockerfile file for ASTAR223 uses: cuchi/jinja2-action@v1.2.0224 with:225 template: .docker/Dockerfile-astar.j2226 output_file: .docker/Dockerfile-astar.${{ matrix.astar_version }}.yml227 variables: |228 RUST_TOOLCHAIN=${{ env.RUST_TOOLCHAIN }}229 ASTAR_BUILD_BRANCH=${{ matrix.astar_version }}230231 - name: Check if the dockerhub repository contains the needed MOONBEAM version232 run: |233 # aquire token234 TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'${{ secrets.CORE_DOCKERHUB_USERNAME }}'", "password": "'${{ secrets.CORE_DOCKERHUB_TOKEN }}'"}' https://hub.docker.com/v2/users/login/ | jq -r .token)235 export TOKEN=$TOKEN236237 # Get TAGS from DOCKERHUB repository238 ASTAR_TAGS=$(curl -s -H "Authorization: JWT ${TOKEN}" https://hub.docker.com/v2/repositories/uniquenetwork/builder-astar/tags/?page_size=100 | jq -r '."results"[]["name"]')239 # Show TAGS240 echo "ASTAR TAGS:"241 echo $ASTAR_TAGS242 # Check correct version ASTAR and build it if it doesn't exist in ASTAR TAGS243 if [[ ${ASTAR_TAGS[*]} =~ (^|[[:space:]])"${{ matrix.astar_version }}"($|[[:space:]]) ]]; then244 echo "Repository has needed ASTAR version";245 docker pull uniquenetwork/builder-astar:${{ matrix.astar_version }}246 else247 echo "Repository has not needed ASTAR version, so build it";248 cd .docker/ && docker build --no-cache --file ./Dockerfile-astar.${{ matrix.astar_version }}.yml --tag uniquenetwork/builder-astar:${{ matrix.astar_version }} .249 echo "Push needed ASTAR version to the repository";250 docker push uniquenetwork/builder-astar:${{ matrix.astar_version }}251 fi252 shell: bash253254255 - name: Generate ENV related extend launch-config file256 uses: cuchi/jinja2-action@v1.2.0257 with:258 template: .docker/xcm-config/launch-config-xcm-${{ matrix.network }}.j2259 output_file: .docker/xcm-config/launch-config-xcm-${{ matrix.network }}.json260 variables: |261 RELAY_CHAIN_TYPE=${{ env.RELAY_CHAIN_TYPE }} 262263 - name: Show launch-config-xcm-${{ matrix.network }} configuration264 run: cat .docker/xcm-config/launch-config-xcm-${{ matrix.network }}.json265266 267 - name: Generate ENV related extend Dockerfile file268 uses: cuchi/jinja2-action@v1.2.0269 with:270 template: .docker/Dockerfile-xcm.j2271 output_file: .docker/Dockerfile-xcm.${{ matrix.network }}.yml272 variables: |273 RUST_TOOLCHAIN=${{ env.RUST_TOOLCHAIN }}274 NETWORK=${{ matrix.network }}275 POLKADOT_BUILD_BRANCH=${{ matrix.relay_branch }}276 POLKADOT_LAUNCH_BRANCH=${{ env.POLKADOT_LAUNCH_BRANCH }} 277 BRANCH=${{ github.head_ref }}278 ACALA_BUILD_BRANCH=${{ matrix.acala_version }}279 MOONBEAM_BUILD_BRANCH=${{ matrix.moonbeam_version }}280 CUMULUS_BUILD_BRANCH=${{ matrix.cumulus_version }}281282 - name: Show build Dockerfile283 run: cat .docker/Dockerfile-xcm.${{ matrix.network }}.yml284285 - name: Run find-and-replace to remove slashes from branch name286 uses: mad9000/actions-find-and-replace-string@2287 id: branchname288 with:289 source: ${{ github.head_ref }}290 find: '/'291 replace: '-'292293 - name: Pull chainql docker image294 run: docker pull uniquenetwork/builder-chainql:latest295296 - name: Build the stack297 run: cd .docker/ && docker build --no-cache --file ./Dockerfile-xcm.${{ matrix.network }}.yml --tag uniquenetwork/xcm-${{ matrix.network }}-testnet-local:nightly-${{ steps.branchname.outputs.value }}-${{ github.sha }} --tag uniquenetwork/xcm-${{ matrix.network }}-testnet-local:latest .298299 - name: Push docker image version300 run: docker push uniquenetwork/xcm-${{ matrix.network }}-testnet-local:nightly-${{ steps.branchname.outputs.value }}-${{ github.sha }}301302 - name: Push docker image latest303 run: docker push uniquenetwork/xcm-${{ matrix.network }}-testnet-local:latest304305 - name: Remove builder cache306 if: always() 307 run: |308 docker builder prune -f309 docker system prune -f310311 xcm-tests:312 needs: [prepare-execution-marix, xcm-build]313 314 runs-on: [XL]315316 timeout-minutes: 600317318 name: ${{ matrix.network }}-tests319320 continue-on-error: true 321322 strategy:323 matrix:324 include: ${{fromJson(needs.prepare-execution-marix.outputs.matrix)}}325326 steps:327 - name: Skip if pull request is in Draft328 if: github.event.pull_request.draft == true329 run: exit 1330331 - name: Clean Workspace332 uses: AutoModality/action-clean@v1.1.0333334 335 - uses: actions/checkout@v3336 with:337 ref: ${{ github.head_ref }} 338339 - name: Read .env file340 uses: xom9ikk/dotenv@v2341342 - name: Generate ENV related extend file for docker-compose343 uses: cuchi/jinja2-action@v1.2.0344 with:345 template: .docker/docker-compose.tmp-xcm-tests.j2346 output_file: .docker/docker-compose.xcm-tests.${{ matrix.network }}.yml347 variables: |348 NETWORK=${{ matrix.network }}349350 - name: Show build configuration351 run: cat .docker/docker-compose.xcm-tests.${{ matrix.network }}.yml352353 - uses: actions/setup-node@v3354 with:355 node-version: 16356357 - name: Build the stack358 run: docker-compose -f ".docker/docker-compose.xcm-tests.${{ matrix.network }}.yml" up -d --remove-orphans --force-recreate --timeout 300359360 361 - name: Check if docker logs consist messages related to testing of xcm tests 362 if: success()363 run: |364 counter=160365 function check_container_status {366 docker inspect -f {{.State.Running}} xcm-${{ matrix.network }}-testnet-local367 }368 function do_docker_logs {369 docker logs --details xcm-${{ matrix.network }}-testnet-local 2>&1370 }371 function is_started {372 if [ "$(check_container_status)" == "true" ]; then373 echo "Container: xcm-${{ matrix.network }}-testnet-local RUNNING";374 echo "Check Docker logs"375 DOCKER_LOGS=$(do_docker_logs)376 if [[ ${DOCKER_LOGS} = *"POLKADOT LAUNCH COMPLETE"* ]];then377 echo "🚀 POLKADOT LAUNCH COMPLETE 🚀"378 return 0379 else380 echo "Message not found in logs output, repeating..."381 return 1382 fi383 else384 echo "Container xcm-${{ matrix.network }}-testnet-local NOT RUNNING"385 echo "Halting all future checks"386 exit 1387 fi388 echo "something goes wrong"389 exit 1390 }391 while ! is_started; do392 echo "Waiting for special message in log files "393 sleep 30s394 counter=$(( $counter - 1 ))395 echo "Counter: $counter"396 if [ "$counter" -gt "0" ]; then397 continue398 else399 break400 fi401 done402 echo "Halting script"403 exit 0404 shell: bash405406 - name: Run XCM tests 407 working-directory: tests408 run: |409 yarn install410 yarn add mochawesome411 node scripts/readyness.js412 echo "Ready to start tests"413 yarn polkadot-types 414 NOW=$(date +%s) && yarn ${{ matrix.runtest }} --reporter mochawesome --reporter-options reportFilename=test-${NOW}415 env:416 RPC_URL: http://127.0.0.1:9933/417418 - name: XCM Test Report419 uses: phoenix-actions/test-reporting@v8420 id: test-report421 if: success() || failure() 422 with:423 name: XCM Tests ${{ matrix.network }} 424 path: tests/mochawesome-report/test-*.json 425 reporter: mochawesome-json426 fail-on-error: 'false'427428 - name: Show container logs429 if: always() 430 run: docker-compose -f ".docker/docker-compose.xcm-tests.${{ matrix.network }}.yml" logs431432 - name: Stop running containers433 if: always() 434 run: docker-compose -f ".docker/docker-compose.xcm-tests.${{ matrix.network }}.yml" down435436 - name: Clean Workspace437 if: always()438 uses: AutoModality/action-clean@v1.1.0439440 - name: Remove builder cache441 if: always() 442 run: |443 docker system prune -a -f