packages: simplify the setup to use the same as upgrades

the packages tests control which Forgejo version they run against so
they can test a feature on version X+1 and not on version X
This commit is contained in:
Twenty Panda 2024-03-15 14:34:55 +07:00 committed by p
parent dd35a9f1a8
commit 9ff495254a
8 changed files with 64 additions and 153 deletions

30
packages/alpine-app.ini Normal file
View file

@ -0,0 +1,30 @@
RUN_MODE = prod
WORK_PATH = ${WORK_PATH}
[server]
APP_DATA_PATH = ${WORK_PATH}/data
HTTP_PORT = 3000
SSH_LISTEN_PORT = 2222
LFS_START_SERVER = true
[database]
DB_TYPE = sqlite3
PATH = ${WORK_PATH}/forgejo.db
[log]
MODE = file
LEVEL = trace
ROUTER = file
[log.file]
FILE_NAME = forgejo.log
[security]
INSTALL_LOCK = true
[repository]
ENABLE_PUSH_CREATE_USER = true
DEFAULT_PUSH_CREATE_PRIVATE = false
[actions]
ENABLED = true

View file

@ -2,16 +2,18 @@
# Copyright 2024 The Forgejo Authors
# SPDX-License-Identifier: MIT
SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
function test_packages_alpine_v1.21() {
stop_daemon forgejo
reset_forgejo $PACKAGES_DIR/alpine-app.ini
start_forgejo 1.21
source $SELF_DIR/../lib/lib.sh
function main() {
local d=$SELF_DIR/alpine
local token=$(cat $DIR/forgejo-token)
local url=$(cat $DIR/forgejo-url)
local d=$PACKAGES_DIR/alpine
local token=$(cat $DIR/forgejo-curl/token)
local url=http://${HOST_PORT}
docker run --rm --volume $d:$d:ro --workdir $d docker.io/alpine:3.19 ash -c "./test.sh $url $token"
}
"${@:-main}"
function test_packages_alpine() {
test_packages_alpine_v1.21
}

11
packages/packages.sh Normal file
View file

@ -0,0 +1,11 @@
#!/bin/sh
# Copyright 2024 The Forgejo Authors
# SPDX-License-Identifier: MIT
PACKAGES_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $PACKAGES_DIR/alpine.sh
function test_packages() {
run test_packages_alpine
}

View file

@ -1,80 +0,0 @@
#!/bin/bash
# Copyright 2024 The Forgejo Authors
# SPDX-License-Identifier: MIT
SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $SELF_DIR/../lib/lib.sh
function run() {
local package=$1
bash -ex $SELF_DIR/$package.sh
}
function packages_v1_21() {
echo 'alpine'
}
function packages_v7_0() {
packages_v1_21
}
function setup() {
local binary=$1
forgejo-binary.sh setup root admin1234 $binary
}
function teardown() {
forgejo-curl.sh logout
forgejo-binary.sh teardown
}
function main() {
local binary="$1"
shift
export full_version="$1"
shift
export version="$1"
shift
export DOT=$DIR/forgejo-curl
teardown
if test "$#" = 0 ; then
packages=$(packages_${version/./_})
else
packages="$@"
fi
if test "$packages" = "none" ; then
exit 0
fi
setup $binary
if ! test -f "$DIR/forgejo-auth-url" ; then
echo "DIR=$DIR must be a directory with a forgejo-auth-url file"
fi
export url=$(cat $DIR/forgejo-auth-url)
export token=$(cat $DIR/forgejo-token)
for package in $packages ; do
echo "======================== BEGIN package-$package ==================="
if ! time run $package >& /tmp/run.out ; then
sed -e 's/^/[RUN] /' < /tmp/run.out
echo "======================== FAIL package-$package ==================="
sleep 5 # hack for Forgejo v1.21 to workaround a bug by which the last lines of the output are moved to the next step
false
else
if test "$VERBOSE" = true ; then
sed -e 's/^/[RUN] /' < /tmp/run.out
fi
fi
echo "======================== END package-$package ==================="
done
}
main "$@"