From 8e267559a7da9c114beba318d7d43723594e971d Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Wed, 10 Jan 2024 21:41:48 +0100 Subject: [PATCH] Restructure some stuff to improve UX, ideally don't want to wait for the apt deps to install before being able to know which yunohost version is running and package linter ... --- lib/lxc.sh | 3 +-- lib/tests.sh | 15 ++++++++++++--- lib/tests_coordination.sh | 5 ----- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/lxc.sh b/lib/lxc.sh index 4b2dabd..0595eef 100644 --- a/lib/lxc.sh +++ b/lib/lxc.sh @@ -48,8 +48,7 @@ LXC_CREATE () { log_critical "Failed to run 'test -e /etc/yunohost' on the container ... either the container did not start, or YunoHost doesn't exists yet in the container :/" fi - set_witness_files - _PREINSTALL_APT_DEPS + _STUFF_TO_RUN_BEFORE_INITIAL_SNAPSHOT sleep 3 log_info "Creating initial snapshot $LXC_NAME ..." diff --git a/lib/tests.sh b/lib/tests.sh index 4fd0de5..b719b3b 100644 --- a/lib/tests.sh +++ b/lib/tests.sh @@ -4,13 +4,23 @@ # "Low-level" logistic helpers #================================================= -_PREINSTALL_APT_DEPS() +_STUFF_TO_RUN_BEFORE_INITIAL_SNAPSHOT() { + # Print the version of YunoHost from the LXC container + log_small_title "YunoHost versions" + lxc exec $LXC_NAME -t -- /bin/bash -c "yunohost --version" | tee -a "$full_log" >/dev/null + + log_title "Package linter" + ./package_linter/package_linter.py "$package_path" | tee -a "$full_log" + + # Set witness files + set_witness_files + [[ -e $package_path/manifest.toml ]] || return local apt_deps=$(python3 -c "import toml, sys; t = toml.loads(sys.stdin.read()); p = t['resources'].get('apt', {}).get('packages', ''); print(p.replace(',', ' ')) if isinstance(p, str) else print(' '.join(p));" < $package_path/manifest.toml) - log_small_title "Preinstalling apt dependencies before creating the initial snapshot..." + log_title "Preinstalling apt dependencies before creating the initial snapshot..." apt="LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get --assume-yes --quiet -o=Acquire::Retries=3 -o=Dpkg::Use-Pty=0" # Execute the command given in argument in the container and log its results. @@ -371,7 +381,6 @@ TEST_PACKAGE_LINTER () { start_test "Package linter" # Execute package linter and linter_result gets the return code of the package linter - ./package_linter/package_linter.py "$package_path" | tee -a "$full_log" ./package_linter/package_linter.py "$package_path" --json | tee -a "$full_log" > $current_test_results return ${PIPESTATUS[0]} diff --git a/lib/tests_coordination.sh b/lib/tests_coordination.sh index 5369b9e..8c384b2 100644 --- a/lib/tests_coordination.sh +++ b/lib/tests_coordination.sh @@ -72,12 +72,7 @@ run_all_tests() { check_lxd_setup LXC_RESET LXC_CREATE - # Be sure that the container is running - LXC_EXEC "true" - # Print the version of YunoHost from the LXC container - log_small_title "YunoHost versions" - LXC_EXEC "yunohost --version" LXC_EXEC "yunohost --version --output-as json" | jq -r .yunohost.version >> $TEST_CONTEXT/ynh_version LXC_EXEC "yunohost --version --output-as json" | jq -r .yunohost.repo >> $TEST_CONTEXT/ynh_branch echo $ARCH > $TEST_CONTEXT/architecture