From 529af30c736f2c25785d3c4726ec47e1196ef7d2 Mon Sep 17 00:00:00 2001 From: Wil Wade Date: Mon, 22 Jul 2024 15:54:55 +0000 Subject: [PATCH] Add new metadata summary to the release notes --- .github/workflows/release.yml | 3 +- tools/ci/release-notes/build-release-notes.sh | 5 + tools/ci/release-notes/release-notes.md.tera | 9 ++ tools/ci/scripts/extrinsic-ordering-filter.sh | 147 +++++++++++++----- 4 files changed, 120 insertions(+), 44 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d5313700e1..db4739492c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -586,7 +586,7 @@ jobs: - name: Compare Metadata timeout-minutes: 10 run: | - CMD="docker run --pull always --net=net-${{env.RELEASE_BRANCH_NAME}} jacogr/polkadot-js-tools:0.55.3 metadata ws://ref-node:9944 ws://test-node:9944" + CMD="docker run --pull always --net=net-${{env.RELEASE_BRANCH_NAME}} jacogr/polkadot-js-tools:0.57.1 metadata ws://ref-node:9944 ws://test-node:9944" echo -e "Running:\n$CMD" $CMD >> ${{env.OUTPUT_DIR}}/${{env.OUTPUT_FILENAME}} sed -z -i 's/\n\n/\n/g' ${{env.OUTPUT_DIR}}/${{env.OUTPUT_FILENAME}} @@ -752,6 +752,7 @@ jobs: "${RUNTIME_INFO_MAINNET}" \ "${RUNTIME_INFO_PASEO}" \ "${IS_FULL_RELEASE}" \ + "/tmp/metadata-compare-mainnet.txt" \ > release-notes.md - name: Publish Release Candidate on GitHub if: steps.is-full-release.outputs.is-full-release != 'true' diff --git a/tools/ci/release-notes/build-release-notes.sh b/tools/ci/release-notes/build-release-notes.sh index 4686dfaf0e..02b27a323e 100755 --- a/tools/ci/release-notes/build-release-notes.sh +++ b/tools/ci/release-notes/build-release-notes.sh @@ -6,10 +6,15 @@ changelog=$2 runtime_mainnet_info=$3 runtime_paseo_info=$4 is_full_release=$5 +metadata_change_summary_file=$6 + +# Extract the contents of the Summary section from the metadata change summary file, but remove trailing whitespace/blank lines +metadata_change_summary=`sed -n '/SUMMARY/,/^------/p' "$metadata_change_summary_file" | sed '1d;$d' | sed -e :a -e '/^[[:space:]]*$/{$d;N;ba' -e '}'` CHANGELOG="$changelog" \ POLKADOT_VERSION="$polkadot_version" \ RUNTIME_MAINNET_INFO="$runtime_mainnet_info" \ RUNTIME_PASEO_INFO="$runtime_paseo_info" \ IS_FULL_RELEASE="$is_full_release" \ + METADATA_CHANGE_SUMMARY="$metadata_change_summary" \ tera -a --env --env-key env --env-only --template release-notes.md.tera diff --git a/tools/ci/release-notes/release-notes.md.tera b/tools/ci/release-notes/release-notes.md.tera index 5b9d193a3d..20a1dca921 100644 --- a/tools/ci/release-notes/release-notes.md.tera +++ b/tools/ci/release-notes/release-notes.md.tera @@ -45,3 +45,12 @@ The information about the runtimes included in this release can be found below. {{ line | safe }} {% endfor -%} ``` + +### Metadata Change Summary vs Mainnet + +{% set summary = env.METADATA_CHANGE_SUMMARY | split(pat='|') -%} +``` +{% for line in summary -%} + {{ line | safe }} +{% endfor -%} +``` diff --git a/tools/ci/scripts/extrinsic-ordering-filter.sh b/tools/ci/scripts/extrinsic-ordering-filter.sh index 1f974d5b9b..9140f7e7c0 100755 --- a/tools/ci/scripts/extrinsic-ordering-filter.sh +++ b/tools/ci/scripts/extrinsic-ordering-filter.sh @@ -1,55 +1,116 @@ #!/usr/bin/env bash -# This script is used in a Github Workflow. It helps filtering out what is interesting -# when comparing metadata and spot what would require a tx version bump. FILE=$1 -# Higlight indexes that were deleted -function find_deletions() { - echo "\n## Deletions\n" - RES=$(cat "$FILE" | grep -n '\[\-\]' | tr -s " ") - if [ "$RES" ]; then - echo "$RES" | awk '{ printf "%s\\n", $0 }' - else - echo "n/a" - fi +function find_module_changes() { + echo "## Modules" + echo "- Added" + grep '\[+\] modules:' "$FILE" | sed 's/.*modules: / - /' || echo " n/a" + echo "- Removed" + grep '\[-\] modules:' "$FILE" | sed 's/.*modules: / - /' || echo " n/a" + echo } -# Highlight indexes that have been deleted -function find_index_changes() { - echo "\n## Index changes\n" - RES=$(cat "$FILE" | grep -E -n -i 'idx:\s*([0-9]+)\s*(->)\s*([0-9]+)' | tr -s " ") - if [ "$RES" ]; then - echo "$RES" | awk '{ printf "%s\\n", $0 }' - else - echo "n/a" - fi +function find_removals() { + echo "## Removals" + # Find all the modules with changes and pull in all the changes after it + grep -n -E '\[.*\] idx: .*\((calls:.*|storage:.*)\)' "$FILE" | + while read -r mod_line; do + module=$(echo "$mod_line" | sed -E 's/^[0-9]+:[[:space:]]*\[([^]]+)\].*/\1/') + mod_line_number=$(echo "$mod_line" | sed -E 's/^([0-9]+):.*/\1/') + mod_line_number_plus=$(($mod_line_number + 1)) + # Find all the [-] lines after that line until the next empty line + lines=$(sed -n -E "${mod_line_number_plus},\$ { + /\[-\]/ { + p + a\\ + | + } + /^$/ q + }" "$FILE") + # If some were found, then echo out the header, and the lines + if [ -n "$lines" ]; then + echo "- $module" + echo $lines | tr "|" "\n" | + while read -r line; do + if [ -n "${line}" ]; then + echo " - ${line}" + fi + done + fi + done || echo " n/a" + echo } -# Highlight values that decreased -function find_decreases() { - echo "\n## Decreases\n" - OUT=$(cat "$FILE" | grep -E -i -o '([0-9]+)\s*(->)\s*([0-9]+)' | awk '$1 > $3 { printf "%s;", $0 }') - IFS=$';' LIST=("$OUT") - unset RES - # for line in "${LIST[@]}"; do - for line in ${LIST[@]}; do - # RES="$RES\n$(cat "$FILE" | grep -E -i -n $line | tr -s " ")" - RES="$RES$(cat "$FILE" | grep -E -i -n $line | tr -s " ")\n" - done +function find_changes() { + echo "## Changes" + # Find all the modules with changes and pull in all the changes after it + grep -n -E '\[.*\] idx: .*\((calls:.*|storage:.*)\)' "$FILE" | + while read -r mod_line; do + module=$(echo "$mod_line" | sed -E 's/^[0-9]+:[[:space:]]*\[([^]]+)\].*/\1/') + mod_line_number=$(echo "$mod_line" | sed -E 's/^([0-9]+):.*/\1/') + mod_line_number_plus=$(($mod_line_number + 1)) + # Find all the [extrinsic] lines after that line until the next empty line + lines=$(sed -n -E "${mod_line_number_plus},\$ { + /\[[^\+-]+\]/ { + p + a\\ + | + } + /^$/ q + }" "$FILE") + # If some were found, then echo out the header, and the lines + if [ -n "$lines" ]; then + echo "- $module" + echo $lines | tr "|" "\n" | + while read -r line; do + if [ -n "${line}" ]; then + echo " - ${line}" + fi + done + fi + done || echo " n/a" + echo +} - if [ "$RES" ]; then - echo "$RES" | awk '{ printf "%s\\n", $0 }' | sort -u -g | uniq - else - echo "n/a" - fi +function find_additions() { + echo "## Additions" + # Find all the modules with changes and pull in all the changes after it + grep -n -E '\[.*\] idx: .*\((calls:.*|storage:.*)\)' "$FILE" | + while read -r mod_line; do + module=$(echo "$mod_line" | sed -E 's/^[0-9]+:[[:space:]]*\[([^]]+)\].*/\1/') + mod_line_number=$(echo "$mod_line" | sed -E 's/^([0-9]+):.*/\1/') + mod_line_number_plus=$(($mod_line_number + 1)) + # Find all the [+] lines after that line until the next empty line + lines=$(sed -n -E "${mod_line_number_plus},\$ { + /\[\+\]/ { + p + a\\ + | + } + /^$/ q + }" "$FILE") + # If some were found, then echo out the header, and the lines + if [ -n "$lines" ]; then + echo "- $module" + echo $lines | tr "|" "\n" | + while read -r line; do + if [ -n "${line}" ]; then + echo " - ${line}" + fi + done + fi + done || echo " n/a" + echo } -echo "\n------------------------------ SUMMARY -------------------------------" -echo "\n⚠️ This filter is here to help spotting changes that should be reviewed carefully." -echo "\n⚠️ It catches only index changes, deletions and value decreases". +echo "------------------------------ SUMMARY -------------------------------" +echo "⚠️ This filter is here to help spotting changes that should be reviewed carefully." +echo "⚠️ It catches only index changes, deletions and value decreases." +echo -find_deletions "$FILE" -find_index_changes "$FILE" -find_decreases "$FILE" -echo "\n----------------------------------------------------------------------\n" +find_module_changes "$FILE" +find_removals "$FILE" +find_additions "$FILE" +find_changes "$FILE" +echo "----------------------------------------------------------------------"