From d368aaf8ad75df8645fb1174a8f101d6f48ee6ac Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Fri, 6 Oct 2023 00:17:00 +0200 Subject: [PATCH] [UPGRADE] add sanity check for v1.20.5-0 See https://forgejo.org/2023-10-release-v1-20-5-0/ (cherry picked from commit 7d619f79a0ebebf0de49be6175701769db04f7c2) (cherry picked from commit ce5c75e1532894c180c66c38f828fd647c3b8174) (cherry picked from commit 7b9eddf494211c247984e01fa299d9ba4e38589e) (cherry picked from commit 200b6cdbdb1f16a193d1e22904567fc470a007c2) (cherry picked from commit 860b18393da614113b74807345369e334aa7332a) (cherry picked from commit 358386fab7384d2e76757236b2eebec1ad17e24f) (cherry picked from commit b57ea4bdcd9bdf000602cf1810d14089250b38d8) (cherry picked from commit bfa359048bfd52729be618b86fde3b290742d60f) (cherry picked from commit 520a459c3c2abde7315a85d910676fda1f1a0afc) --- .forgejo/upgrades/test-upgrade.sh | 45 ++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/.forgejo/upgrades/test-upgrade.sh b/.forgejo/upgrades/test-upgrade.sh index 287a92a591..941301cbf2 100755 --- a/.forgejo/upgrades/test-upgrade.sh +++ b/.forgejo/upgrades/test-upgrade.sh @@ -42,12 +42,12 @@ function log_info() { function dependencies() { maybe_sudo if ! which curl daemon jq git-lfs > /dev/null ; then - $SUDO apt-get install -y -qq curl daemon git-lfs jq + $SUDO apt-get install -y -qq curl daemon git-lfs jq sqlite3 fi if ! test -f /usr/local/bin/mc || ! test -f /usr/local/bin/minio > /dev/null ; then $SUDO curl --fail -sS https://dl.min.io/client/mc/release/linux-amd64/mc -o /usr/local/bin/mc - $SUDO curl --fail -sS https://dl.min.io/server/minio/release/linux-amd64/archive/minio.RELEASE.2023-08-23T10-07-06Z -o /usr/local/bin/minio + $SUDO curl --fail -sS https://dl.min.io/server/minio/release/linux-amd64/minio -o /usr/local/bin/minio fi if ! test -x /usr/local/bin/mc || ! test -x /usr/local/bin/minio > /dev/null ; then $SUDO chmod +x /usr/local/bin/mc @@ -101,7 +101,11 @@ function download() { if ! test -f $DIR/forgejo-$version ; then mkdir -p $DIR - wget -O $DIR/forgejo-$version --quiet https://codeberg.org/forgejo/forgejo/releases/download/v$version/forgejo-$version-linux-amd64 + for owner in forgejo forgejo-experimental forgejo-integration ; do + if wget -O $DIR/forgejo-$version --quiet https://codeberg.org/$owner/forgejo/releases/download/v$version/forgejo-$version-linux-amd64 ; then + break + fi + done chmod +x $DIR/forgejo-$version fi } @@ -555,6 +559,40 @@ function test_successful_upgrades() { done } +function test_forgejo_database_version() { + local expected_version=$1 + local work_path=$DIR/forgejo-work-path + + actual_version=$(sqlite3 $work_path/forgejo.db "select version from forgejo_version") + test "$expected_version" = "$actual_version" +} + +function test_forgejo_database_v3_upgrades_list_table() { + local table=$1 + local work_path=$DIR/forgejo-work-path + + sqlite3 $work_path/forgejo.db ".tables $table" .exit | grep --quiet $table +} + +function test_forgejo_database_v3_upgrades() { + local table=forgejo_auth_token + + stop + + reset default + log_info "run 1.20.4-1" + start 1.20.4-1 + stop + ! test_forgejo_database_v3_upgrades_list_table $table + test_forgejo_database_version 2 + + log_info "run 1.20.5-0" + start 1.20.5-0 + stop + test_forgejo_database_v3_upgrades_list_table $table + test_forgejo_database_version 3 +} + function run() { local fun=$1 shift @@ -585,6 +623,7 @@ function test_upgrades() { run test_bug_storage_s3_misplace run test_storage_stable_s3 minio run test_storage_stable_s3 garage + run test_forgejo_database_v3_upgrades } "$@"