diff --git a/polkadot/.gitlab-ci.yml b/polkadot/.gitlab-ci.yml index af3e3811a4..11a9e42d80 100644 --- a/polkadot/.gitlab-ci.yml +++ b/polkadot/.gitlab-ci.yml @@ -157,8 +157,9 @@ check-transaction-versions: <<: *docker-env needs: - job: test-linux-stable - artifacts: false + artifacts: true before_script: + - apt-get -y update; apt-get -y install jq lsof - npm install --ignore-scripts -g @polkadot/metadata-cmp - git fetch origin release script: diff --git a/polkadot/scripts/common/lib.sh b/polkadot/scripts/common/lib.sh index 2e40fffe2c..9a232ca4c1 100755 --- a/polkadot/scripts/common/lib.sh +++ b/polkadot/scripts/common/lib.sh @@ -117,3 +117,10 @@ skip_if_companion_pr() { echo "[+] PR is not a companion PR. Proceeding test" fi } + +# Fetches the tag name of the latest release from a repository +# repo: 'organisation/repo' +# Usage: latest_release 'paritytech/polkadot' +latest_release() { + curl -s "$api_base/$1/releases/latest" | jq -r '.tag_name' +} diff --git a/polkadot/scripts/gitlab/check_extrinsics_ordering.sh b/polkadot/scripts/gitlab/check_extrinsics_ordering.sh index cfdad63691..2c70b21f16 100755 --- a/polkadot/scripts/gitlab/check_extrinsics_ordering.sh +++ b/polkadot/scripts/gitlab/check_extrinsics_ordering.sh @@ -1,10 +1,13 @@ -#!/bin/bash -BIN=./target/release/polkadot -LIVE_WS=wss://rpc.polkadot.io -LOCAL_WS=ws://localhost:9944 +#!/usr/bin/env bash +set -e -# Kill the polkadot client before exiting -trap 'kill "$(jobs -p)"' EXIT +# Include the common functions library +#shellcheck source=../common/lib.sh +. "$(dirname "${0}")/../common/lib.sh" + +HEAD_BIN=./target/release/polkadot +HEAD_WS=ws://localhost:9944 +RELEASE_WS=ws://localhost:9945 runtimes=( "westend" @@ -12,6 +15,14 @@ runtimes=( "polkadot" ) +# First we fetch the latest released binary +latest_release=$(latest_release 'paritytech/polkadot') +RELEASE_BIN="./polkadot-$latest_release" +echo "[+] Fetching binary for Polkadot version $latest_release" +curl -L "https://github.com/paritytech/polkadot/releases/download/$latest_release/polkadot" > "$RELEASE_BIN" || exit 1 +chmod +x "$RELEASE_BIN" + + for RUNTIME in "${runtimes[@]}"; do echo "[+] Checking runtime: ${RUNTIME}" @@ -32,19 +43,29 @@ for RUNTIME in "${runtimes[@]}"; do exit 0 fi - if [ "$RUNTIME" = 'polkadot' ]; then - LIVE_WS="wss://rpc.polkadot.io" - else - LIVE_WS="wss://${RUNTIME}-rpc.polkadot.io" - fi - - # Start running the local polkadot node in the background - $BIN --chain="$RUNTIME-local" & + # Start running the nodes in the background + $HEAD_BIN --chain="$RUNTIME-local" --tmp & + $RELEASE_BIN --chain="$RUNTIME-local" --ws-port 9945 --tmp & jobs + # Sleep a little to allow the nodes to spin up and start listening + TIMEOUT=5 + for i in $(seq $TIMEOUT); do + sleep 1 + if [ "$(lsof -nP -iTCP -sTCP:LISTEN | grep -c '994[45]')" == 2 ]; then + echo "[+] Both nodes listening" + break + fi + if [ "$i" == $TIMEOUT ]; then + echo "[!] Both nodes not listening after $i seconds. Exiting" + exit 1 + fi + done + sleep 5 + changed_extrinsics=$( - polkadot-js-metadata-cmp "$LIVE_WS" "$LOCAL_WS" \ - | sed 's/^ \+//g' | grep -e 'idx: [0-9]\+ -> [0-9]\+' + polkadot-js-metadata-cmp "$RELEASE_WS" "$HEAD_WS" \ + | sed 's/^ \+//g' | grep -e 'idx: [0-9]\+ -> [0-9]\+' || true ) if [ -n "$changed_extrinsics" ]; then @@ -54,6 +75,8 @@ for RUNTIME in "${runtimes[@]}"; do fi echo "[+] No change in extrinsics ordering for the ${RUNTIME} runtime" - kill "$(jobs -p)"; sleep 5 + jobs -p | xargs kill; sleep 5 done +# Sleep a little to let the jobs die properly +sleep 5