1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mattermost_ynh.git synced 2024-09-03 19:36:29 +02:00

test: cache source archive

This commit is contained in:
Pierre de La Morinerie 2017-10-24 11:28:54 +00:00
parent 905155e438
commit 484cd42279
2 changed files with 35 additions and 1 deletions

View file

@ -3,4 +3,4 @@ SOURCE_SUM=c21eefaa87fca836e17d874296e67baf181ab5594f705090247614faae219d01
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_FILENAME=mattermost-4.3.0-linux-amd64.tar.gz

34
test.sh
View file

@ -5,6 +5,7 @@
set -e
# Configuration constants
APP_ID="mattermost"
APP_DIR="/vagrant"
function _usage() {
@ -46,9 +47,42 @@ function _vagrant_ssh() {
return $exit_code
}
# Pre-download the app source archive declared in an app.src file.
# The local archive will be used during tests, instead of being re-downloaded every time.
#
# TODO: let package_check do the caching itself
function _cache_app_source() {
local app_src="conf/app.src"
if [ ! -e "conf/app.src" ]; then
return
fi
local src_url=$(grep 'SOURCE_URL=' "$app_src" | cut -d= -f2-)
local src_format=$(grep 'SOURCE_FORMAT=' "$app_src" | cut -d= -f2-)
local src_filename=$(grep 'SOURCE_FILENAME=' "$app_src" | cut -d= -f2-)
if [ "$src_filename" = "" ] ; then
src_filename="app.${src_format}"
fi
local lxc_name="pchecker_lxc"
local lxc_root="/var/lib/lxcsnaps/${lxc_name}/snap0/rootfs"
local local_src_dir="${lxc_root}/opt/yunohost-apps-src/${APP_ID}"
local file_exists=false
_vagrant_ssh "sudo test -e ${local_src_dir}/${src_filename}" && file_exists=true
if [ "$file_exists" = false ]; then
echo "--- Downloading and caching app source ---"
_vagrant_ssh " \
sudo mkdir -p ${local_src_dir} && \
sudo wget -O ${local_src_dir}/${src_filename} ${src_url};";
fi
}
function setup() {
echo "--- Setting up Vagrant VM ---"
vagrant up --provision
_cache_app_source
}
function test_package_check() {