mirror of
https://github.com/YunoHost/package_check.git
synced 2024-09-03 20:06:20 +02:00
Introduce pre-upgrade
This commit is contained in:
parent
03e044d39b
commit
2e729ca7bb
2 changed files with 39 additions and 8 deletions
37
lib/tests.sh
37
lib/tests.sh
|
@ -32,10 +32,10 @@ _PREINSTALL () {
|
|||
local preinstall_script="$TEST_CONTEXT/preinstall.sh"
|
||||
echo "$preinstall_template" > "$preinstall_script"
|
||||
# Hydrate the template with variables
|
||||
sed -i "s/\$USER/$TEST_USER/" "$preinstall_script"
|
||||
sed -i "s/\$DOMAIN/$DOMAIN/" "$preinstall_script"
|
||||
sed -i "s/\$SUBDOMAIN/$SUBDOMAIN/" "$preinstall_script"
|
||||
sed -i "s/\$PASSWORD/$YUNO_PWD/" "$preinstall_script"
|
||||
sed -i "s/\$USER/$TEST_USER/g" "$preinstall_script"
|
||||
sed -i "s/\$DOMAIN/$DOMAIN/g" "$preinstall_script"
|
||||
sed -i "s/\$SUBDOMAIN/$SUBDOMAIN/g" "$preinstall_script"
|
||||
sed -i "s/\$PASSWORD/$YUNO_PWD/g" "$preinstall_script"
|
||||
# Copy the pre-install script into the container.
|
||||
lxc file push "$preinstall_script" "$LXC_NAME/preinstall.sh"
|
||||
# Then execute the script to execute the pre-install commands.
|
||||
|
@ -43,6 +43,31 @@ _PREINSTALL () {
|
|||
fi
|
||||
}
|
||||
|
||||
_PREUPGRADE () {
|
||||
local preupgrade_template="$(jq -r '.preupgrade_template' $current_test_infos)"
|
||||
local commit=${1:-HEAD}
|
||||
|
||||
# Exec the pre-upgrade instruction, if there one
|
||||
if [ -n "$preupgrade_template" ]
|
||||
then
|
||||
log_small_title "Running pre-upgrade steps"
|
||||
# Copy all the instructions into a script
|
||||
local preupgrade_script="$TEST_CONTEXT/preupgrade.sh"
|
||||
echo "$preupgrade_template" >> "$preupgrade_script"
|
||||
# Hydrate the template with variables
|
||||
sed -i "s/\$USER/$TEST_USER/g" "$preupgrade_script"
|
||||
sed -i "s/\$DOMAIN/$DOMAIN/g" "$preupgrade_script"
|
||||
sed -i "s/\$SUBDOMAIN/$SUBDOMAIN/g" "$preupgrade_script"
|
||||
sed -i "s/\$PASSWORD/$YUNO_PWD/g" "$preupgrade_script"
|
||||
sed -i "s/\$FROM_COMMIT/$commit/g" "$preupgrade_script"
|
||||
# Copy the pre-upgrade script into the container.
|
||||
lxc file push "$preupgrade_script" "$LXC_NAME/preupgrade.sh"
|
||||
# Then execute the script to execute the pre-upgrade commands.
|
||||
LXC_EXEC "bash /preupgrade.sh"
|
||||
return $?
|
||||
fi
|
||||
}
|
||||
|
||||
_INSTALL_APP () {
|
||||
local install_args="$(jq -r '.install_args' $current_test_infos)"
|
||||
|
||||
|
@ -433,6 +458,10 @@ TEST_UPGRADE () {
|
|||
|
||||
log_small_title "Upgrade..."
|
||||
|
||||
_PREUPGRADE "${commit}"
|
||||
ret=$?
|
||||
[ $ret -eq 0 ] || { log_error "Pre-upgrade instruction failed"; return 1; }
|
||||
|
||||
# Upgrade the application in a LXC container
|
||||
_RUN_YUNOHOST_CMD "app upgrade $app_id --file /app_folder --force" \
|
||||
&& _VALIDATE_THAT_APP_CAN_BE_ACCESSED "$SUBDOMAIN" "$check_path" "upgrade"
|
||||
|
|
|
@ -80,6 +80,7 @@ parse_check_process() {
|
|||
# during tests
|
||||
local install_args=$( extract_check_process_section "^; Manifest" "^; " $test_serie_rawconf | sed 's/\s*(.*)$//g' | tr -d '"' | tr '\n' '&')
|
||||
local preinstall_template=$(extract_check_process_section "^; pre-install" "^; " $test_serie_rawconf)
|
||||
local preupgrade_template=$(extract_check_process_section "^; pre-upgrade" "^; " $test_serie_rawconf)
|
||||
local action_infos=$( extract_check_process_section "^; Actions" "^; " $test_serie_rawconf)
|
||||
local configpanel_infos=$( extract_check_process_section "^; Config_panel" "^; " $test_serie_rawconf)
|
||||
|
||||
|
@ -130,9 +131,10 @@ parse_check_process() {
|
|||
--arg test_type "$test_type" \
|
||||
--arg test_arg "$test_arg" \
|
||||
--arg preinstall_template "$preinstall_template" \
|
||||
--arg preupgrade_template "$preupgrade_template" \
|
||||
--arg install_args "${_install_args//\"}" \
|
||||
--argjson extra "$extra" \
|
||||
'{ $test_serie, $test_type, $test_arg, $preinstall_template, $install_args, $extra }' \
|
||||
'{ $test_serie, $test_type, $test_arg, $preinstall_template, $preupgrade_template, $install_args, $extra }' \
|
||||
> "$TEST_CONTEXT/tests/$test_id.json"
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue