Skip to content

Commit

Permalink
ci: add workflow to check downgrade versions
Browse files Browse the repository at this point in the history
Tarantool has hardcoded list of versions it can downgrade to. This list
should consist of all the released versions less than Tarantool version.
This workflow helps to make sure we update the list before release.

When run on the commit with release tag it check the list and fail
if it misses some released version less than current. In this case
we are supposed to update downgrade list (with required downgrade code)
and update the release tag.

Closes tarantool#8319

NO_TEST=ci
NO_CHANGELOG=ci
NO_DOC=ci
  • Loading branch information
nshy committed Jun 14, 2024
1 parent c06d0d1 commit 3d552e9
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/tree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/box/lua/upgrade.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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.
Expand Down
79 changes: 79 additions & 0 deletions tools/check-downgrade-versions.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3d552e9

Please sign in to comment.