diff --git a/.github/workflows/tree.yml b/.github/workflows/tree.yml index a415aa07d9d8f..74d15a77a0fe4 100644 --- a/.github/workflows/tree.yml +++ b/.github/workflows/tree.yml @@ -46,6 +46,9 @@ jobs: - name: Check entrypoint tag run: ./tools/check-entrypoint-tag.sh + - name: Check downgrade versions + run: ./tools/check-downgrade-versions.sh + - name: Send VK Teams message on failure if: failure() uses: ./.github/actions/report-job-status diff --git a/src/box/lua/upgrade.lua b/src/box/lua/upgrade.lua index 51a5b7527bd46..95fcfc11f1aed 100644 --- a/src/box/lua/upgrade.lua +++ b/src/box/lua/upgrade.lua @@ -2092,6 +2092,7 @@ end -- List of all Tarantool releases we can downgrade to. local downgrade_versions = { + -- DOWNGRADE VERSIONS BEGIN "2.8.2", "2.8.3", "2.8.4", @@ -2105,6 +2106,7 @@ local downgrade_versions = { "2.11.1", "3.0.0", "3.1.0", + -- DOWNGRADE VERSIONS END } -- Downgrade or list downgrade issues depending of dry_run argument value. diff --git a/tools/check-downgrade-versions.sh b/tools/check-downgrade-versions.sh new file mode 100755 index 0000000000000..91eaa8b48e26d --- /dev/null +++ b/tools/check-downgrade-versions.sh @@ -0,0 +1,79 @@ +#!/bin/bash +# +# This script checks that we can downgrade to all the released versions +# less then being released. For example when releasing version 2.11.4 +# we check that we can downgrade to 2.11.3, 2.11.2, ..., 2.10.8, 2.10.7, ... +# 2.8.2. +# +# The versions we can downgrade to are those mentioned in downgrade_versions +# list in src/box/lua/upgrade.lua. For the sake of parsing simplicity +# the versions should be between begin and end marks: +# -- DOWNGRADE VERSIONS BEGIN +# -- DOWNGRADE VERSIONS END +# +# The check is only done for the commit tagged as release version +# (annotated tag with name like 2.11.4). + +set -eo pipefail + +error() { + echo "$@" 1>&2 + exit 1 +} + +# Tags that should not be considered. +tag_exceptions=`mktemp` +echo 2.9.0 > $tag_exceptions + +this_tag=`git describe --exact-match 2>/dev/null || true` +tag_pattern='^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$' +# Make downgrade check only for the release tags. +if [[ $this_tag =~ $tag_pattern ]]; then + # File with expected versions. + expected_versions=`mktemp` + # Sorted (in version order) list of release tags. + tags=`git tag | grep -E $tag_pattern | sort -V` + skip=1 + # Cut tags below 2.8.2 and above $this_tag + for tag in $tags; do + if [[ $tag = '2.8.2' ]]; then + skip=0 + fi + if [[ $skip -eq 0 ]]; then + echo $tag >> $expected_versions + fi + if [[ $tag = $this_tag ]]; then + skip=1 + fi + done + + # File of versions we can downgrade to. + actual_versions=`mktemp` + begin_mark='DOWNGRADE VERSIONS BEGIN' + end_mark='DOWNGRADE VERSIONS END' + upgrade_file='src/box/lua/upgrade.lua' + grep -q "$begin_mark" $upgrade_file || + error "Cannot find start mark in $upgrade_file" + grep -q "$end_mark" $upgrade_file || + error "Cannot find end mark in $upgrade_file" + + # Cut part of $upgrade_file between $begin_mark and $end_mark + # and for every line strip everything except version. + awk "/$begin_mark/{flag=1; next} + /$end_mark/{flag=0} flag" $upgrade_file | + sed -E 's/.*"(.*)".*/\1/' > $actual_versions + + cat $tag_exceptions >> $actual_versions + # Sort is usual order before using `comm`. + sort -o $expected_versions $expected_versions + sort -o $actual_versions $actual_versions + diff=`comm -23 $expected_versions $actual_versions` + if [ -n "$diff" ]; then + echo "Some versions are missing in downgrade list:" 1>&2 + echo "$diff" + exit 1 + fi +fi + +echo OK +exit 0