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

Vagrant: use a pre-packaged Yunohost box

instead of installing Yunohost ourselves.
This commit is contained in:
Pierre de La Morinerie 2017-09-11 14:44:53 +05:30
parent ff7afbbeda
commit dc5e3c7177
2 changed files with 20 additions and 26 deletions

32
Vagrantfile vendored
View file

@ -10,8 +10,8 @@ Vagrant.configure("2") do |config|
# For a complete reference, please see the online documentation at # For a complete reference, please see the online documentation at
# https://docs.vagrantup.com. # https://docs.vagrantup.com.
config.vm.define :mattermost_ynh config.vm.define :ynh_tests
config.vm.box = "debian/contrib-jessie64" config.vm.box = "yunohost/jessie-stable"
# Disable auto updates checks. Run `vagrant outdated` to perform manual updates. # Disable auto updates checks. Run `vagrant outdated` to perform manual updates.
config.vm.box_check_update = false config.vm.box_check_update = false
@ -36,36 +36,26 @@ Vagrant.configure("2") do |config|
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use. # documentation for more information about their specific syntax and use.
config.vm.provision "shell", privileged: false, keep_color: true, inline: <<-SHELL config.vm.provision "shell", privileged: false, keep_color: true, inline: <<-SHELL
TESTS_DIR="/home/vagrant/tests" DOMAIN=ynh-tests.local
APP_DIR="$TESTS_DIR/mattermost_ynh"
VM_ROOT_PASSWORD="alpine"
YUNOHOST_ADMIN_PASSWORD="alpine" YUNOHOST_ADMIN_PASSWORD="alpine"
# Stop on first error # Stop on first error
set -e set -e
# Upgrade the system packages # Upgrade Yunohost and the system packages (disabled)
#DEBIAN_FRONTEND=noninteractive sudo apt-get update #DEBIAN_FRONTEND=noninteractive sudo apt-get update
#DEBIAN_FRONTEND=noninteractive sudo apt-get upgrade --yes -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' #DEBIAN_FRONTEND=noninteractive sudo apt-get upgrade --yes -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold'
# Install git # Finish Yunohost installation
hash git 2>/dev/null || sudo apt-get install git --yes if ! [[ -f /etc/yunohost/installed ]]; then
sudo yunohost tools postinstall --domain ${DOMAIN} --password ${YUNOHOST_ADMIN_PASSWORD} --ignore-dyndns
# Install Yunohost
if ! hash yunohost 2>/dev/null; then
git clone https://github.com/YunoHost/install_script /tmp/install_script
yes ${VM_ROOT_PASSWORD} | sudo passwd
cd /tmp/install_script
echo "Running Yunohost install script…"
sudo ./install_yunohost -a
sudo yunohost tools postinstall --domain mattermost-ynh.local --password ${YUNOHOST_ADMIN_PASSWORD}
fi fi
# Install lxc # Install lxc
if ! hash lxc-start 2>/dev/null; then # if ! hash lxc-start 2>/dev/null; then
DEBIAN_FRONTEND=noninteractive sudo apt-get update # DEBIAN_FRONTEND=noninteractive sudo apt-get update
DEBIAN_FRONTEND=noninteractive sudo apt-get install --yes --fix-missing lxc # DEBIAN_FRONTEND=noninteractive sudo apt-get install --yes --fix-missing lxc
fi # fi
# Install package_check # Install package_check
if ! [ -f "$HOME/package_check/package_check.sh" ]; then if ! [ -f "$HOME/package_check/package_check.sh" ]; then

14
test.sh
View file

@ -10,7 +10,8 @@ set -e
# Configuration constants # Configuration constants
APP_NAME="mattermost" APP_NAME="mattermost"
TESTS_DIR="/home/vagrant/tests" TESTS_DIR="/home/vagrant/tests"
APP_DIR="$TESTS_DIR/mattermost_ynh" APP_DIR="$TESTS_DIR/app"
DOMAIN="ynh-tests.local"
VM_ROOT_PASSWORD="alpine" VM_ROOT_PASSWORD="alpine"
YUNOHOST_ADMIN_PASSWORD="alpine" YUNOHOST_ADMIN_PASSWORD="alpine"
@ -81,16 +82,19 @@ function setup() {
return return
fi fi
if (vagrant snapshot list | grep 'yunohost-2.4-pristine' > /dev/null); then if (vagrant snapshot list | grep 'yunohost-jessie-pristine' > /dev/null); then
echo "--- Restoring Vagrant snapshot ---" echo "--- Restoring Vagrant snapshot ---"
vagrant snapshot restore yunohost-2.4-pristine vagrant snapshot restore yunohost-jessie-pristine
else else
echo "--- Provisioning Vagrant box ---" echo "--- Provisioning Vagrant box ---"
vagrant up --provision vagrant up --provision
echo "--- Saving Vagrant snapshot ---" echo "--- Saving Vagrant snapshot ---"
vagrant snapshot save yunohost-2.4-pristine vagrant snapshot save yunohost-jessie-pristine
fi fi
# Copy the files inside the VM, rather than using the mounted
# files directly.
# This avoids tests screwing up our files if something goes wrong.
echo "--- Copying app content into the box ---" echo "--- Copying app content into the box ---"
if ! [ -d "$APP_DIR" ]; then if ! [ -d "$APP_DIR" ]; then
_vagrant_ssh "mkdir -p '$TESTS_DIR'" _vagrant_ssh "mkdir -p '$TESTS_DIR'"
@ -100,7 +104,7 @@ function setup() {
function test_simple_install() { function test_simple_install() {
echo "--- Running simple installation test ---" echo "--- Running simple installation test ---"
_vagrant_ssh "sudo yunohost app install '$APP_DIR' --args 'domain=mattermost-ynh.local&public_site=Yes&analytics=0' $VERBOSE_OPT" _vagrant_ssh "sudo yunohost app install '$APP_DIR' --args 'domain=${DOMAIN}&public_site=Yes&analytics=0' $VERBOSE_OPT"
} }
function test_simple_upgrade() { function test_simple_upgrade() {