[CI] Fix check-tx-version Gitlab job (#2449)

* set -e for tx job

* dont set -e while we investigate

* fetch latest release polkadot

* add jq to node:15 image

* Add logic for timing out if nodes never start listening

* remove trap
This commit is contained in:
Martin Pugh
2021-02-17 16:25:44 +01:00
committed by GitHub
parent 0771537a0b
commit 62c5896592
3 changed files with 49 additions and 18 deletions
+2 -1
View File
@@ -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:
+7
View File
@@ -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'
}
@@ -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