mirror of
https://github.com/YunoHost-Apps/mattermost_ynh.git
synced 2024-09-03 19:36:29 +02:00
commit
105c1932ed
2 changed files with 0 additions and 213 deletions
100
Vagrantfile
vendored
100
Vagrantfile
vendored
|
@ -1,100 +0,0 @@
|
|||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
# All Vagrant configuration is done below. The "2" in Vagrant.configure
|
||||
# configures the configuration version (we support older styles for
|
||||
# backwards compatibility). Please don't change it unless you know what
|
||||
# you're doing.
|
||||
Vagrant.configure("2") do |config|
|
||||
# The most common configuration options are documented and commented below.
|
||||
# For a complete reference, please see the online documentation at
|
||||
# https://docs.vagrantup.com.
|
||||
|
||||
config.vm.define :ynhtests
|
||||
config.vm.box = "yunohost-stretch-unstable"
|
||||
config.vm.box_url = "https://build.yunohost.org/yunohost-stretch-unstable.box"
|
||||
|
||||
# Disable auto updates checks. Run `vagrant outdated` to perform manual updates.
|
||||
config.vm.box_check_update = false
|
||||
|
||||
# Configuration for the vagrant-disksize plugin.
|
||||
# We need more space because package_check will create many LXC containers and snapshots.
|
||||
#
|
||||
# IMPORTANT: when re-creating the VM from scratch, the logical size of the disk will
|
||||
# still be 10 Go.
|
||||
# You'll need a live GParted ISO to resize partitions and fix it.
|
||||
config.disksize.size = '20GB'
|
||||
|
||||
# Force guest type, because YunoHost /etc/issue can't be tuned
|
||||
config.vm.guest = :debian
|
||||
|
||||
# Create a forwarded port mapping which allows access to a specific port
|
||||
# within the machine from a port on the host machine. In the example below,
|
||||
# accessing "localhost:8080" will access port 80 on the guest machine.
|
||||
# config.vm.network "forwarded_port", guest: 80, host: 8080
|
||||
# config.vm.network "forwarded_port", guest: 443, host: 8443
|
||||
|
||||
# Create a private network, which allows host-only access to the machine
|
||||
# using a specific IP.
|
||||
config.vm.network "private_network", ip: "192.168.33.10"
|
||||
|
||||
# Use the NAT hosts DNS resolver. Fixes slow network in the guest.
|
||||
# See https://serverfault.com/questions/495914/vagrant-slow-internet-connection-in-guest
|
||||
#config.vm.provider "virtualbox" do |v|
|
||||
# v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
|
||||
# v.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
|
||||
# v.customize ["modifyvm", :id, "--nictype1", "virtio"]
|
||||
#end
|
||||
|
||||
# Share an additional folder to the guest VM. The first argument is
|
||||
# the path on the host to the actual folder. The second argument is
|
||||
# the path on the guest to mount the folder. And the optional third
|
||||
# argument is a set of non-required options.
|
||||
config.vm.synced_folder "./", "/vagrant",
|
||||
owner: "root",
|
||||
group: "sudo",
|
||||
mount_options: ["dmode=775,fmode=774"]
|
||||
|
||||
# Enable provisioning with a shell script. Additional provisioners such as
|
||||
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
|
||||
# documentation for more information about their specific syntax and use.
|
||||
config.vm.provision "shell", privileged: false, keep_color: true, inline: <<-SHELL
|
||||
DOMAIN=ynhtests.local
|
||||
YUNOHOST_ADMIN_PASSWORD="ynhadminpwd"
|
||||
|
||||
# Stop on first error
|
||||
set -e
|
||||
|
||||
if ! [[ -f /etc/yunohost/installed ]]; then
|
||||
# Upgrade Yunohost and the system packages
|
||||
sudo apt-get update
|
||||
sudo apt-get upgrade --yes
|
||||
# Run dist-upgrade twice, as the first Yunohost upgrade may fail
|
||||
sudo apt-get dist-upgrade --yes || sudo apt-get dist-upgrade --yes
|
||||
|
||||
# Finish Yunohost installation
|
||||
sudo yunohost tools postinstall --domain ${DOMAIN} --password ${YUNOHOST_ADMIN_PASSWORD} --ignore-dyndns
|
||||
fi
|
||||
|
||||
# Install package_check
|
||||
if ! [ -f "$HOME/package_check/package_check.sh" ]; then
|
||||
git clone https://github.com/YunoHost/package_check
|
||||
|
||||
# Fix LXC containers not being able to reach outside internet.
|
||||
# The default configuration is to detect the default gateway used
|
||||
# by the Vagrant machine to configure LXC containers.
|
||||
# Unfortunately this results in the LXC containers not being able
|
||||
# to connect to the Internet.
|
||||
echo "dns=8.8.8.8" > $HOME/package_check/config
|
||||
fi
|
||||
|
||||
# Build the initial LXC container
|
||||
if ! hash lxc-start 2>/dev/null || [ "$(sudo lxc-ls | wc -l)" == "0" ]; then
|
||||
# Build the default LXC container
|
||||
$HOME/package_check/sub_scripts/lxc_build.sh
|
||||
|
||||
# Ensure the LXC container is correctly configured
|
||||
$HOME/package_check/sub_scripts/lxc_check.sh
|
||||
fi
|
||||
SHELL
|
||||
end
|
113
test.sh
113
test.sh
|
@ -1,113 +0,0 @@
|
|||
#!/bin/bash
|
||||
# Run package_check tests against the app in the working directory on a Vagrant virtual machine.
|
||||
#
|
||||
# NB: Vagrant is used because package_check uses LXC containers, and Docker doesn't support running LXC.
|
||||
|
||||
# Fail on first error
|
||||
set -e
|
||||
|
||||
# Configuration constants
|
||||
APP_ID="mattermost"
|
||||
APP_DIR="/vagrant"
|
||||
|
||||
function _usage() {
|
||||
echo "Run package_check tests against the app in the working directory on a Vagrant virtual machine."
|
||||
echo "Usage: test.sh [--verbose] [--help]"
|
||||
}
|
||||
|
||||
# Configuration arguments
|
||||
function _parse_args() {
|
||||
VERBOSE=false
|
||||
VERBOSE_OPT=''
|
||||
while [ "$1" != "" ]; do
|
||||
case $1 in
|
||||
"-v" | "--verbose")
|
||||
shift
|
||||
VERBOSE=true
|
||||
VERBOSE_OPT='--verbose';;
|
||||
"--help")
|
||||
_usage
|
||||
exit;;
|
||||
*)
|
||||
_usage
|
||||
exit 1;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
# Execute an ssh command on the vagrant box
|
||||
function _vagrant_ssh() {
|
||||
local command="$1"
|
||||
local tty_output=$([ $VERBOSE ] && echo '/dev/stdout' || echo '/dev/null')
|
||||
|
||||
[ $VERBOSE == true ] && echo "vagrant ssh -c \"$command\""
|
||||
|
||||
vagrant ssh -c "$command" \
|
||||
> $tty_output \
|
||||
2> >(grep --invert-match 'Connection to 127.0.0.1 closed.' 1>&2) # Filter out the SSH deconnection message printed on stderr
|
||||
local exit_code=$?
|
||||
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() {
|
||||
echo "--- Running package_check ---"
|
||||
_vagrant_ssh "package_check/package_check.sh --bash-mode '$APP_DIR'"
|
||||
}
|
||||
|
||||
function abort() {
|
||||
trap - SIGINT SIGTERM
|
||||
echo "--- Aborting ---"
|
||||
if (vagrant status | grep -q "running"); then
|
||||
echo "Removing package_check lock…"
|
||||
_vagrant_ssh "rm -f package_check/pcheck.lock"
|
||||
fi
|
||||
teardown
|
||||
}
|
||||
trap abort SIGINT SIGTERM
|
||||
|
||||
function teardown() {
|
||||
echo "--- Cleaning up ---"
|
||||
}
|
||||
|
||||
_parse_args $*
|
||||
setup
|
||||
test_package_check
|
||||
teardown
|
Loading…
Reference in a new issue