add script and Makefile target to test multiverse in a docker container

This commit is contained in:
Fredrik Thulin 2023-01-19 11:40:42 +01:00
parent 44f4fb6620
commit 187e3bc9be
No known key found for this signature in database
GPG key ID: 2707330D4030CCAD
2 changed files with 52 additions and 2 deletions

View file

@ -1,3 +1,5 @@
DIST := "ubuntu:latest"
cosmos:
fab all cosmos
@ -9,4 +11,10 @@ db:
@git add global/overlay/etc/puppet/cosmos-db.yaml && git commit -m "update db" global/overlay/etc/puppet/cosmos-db.yaml
tag: db
./bump-tag
./bump-tag
test_in_docker:
docker run --rm -it \
-v ${CURDIR}:/multiverse:ro \
\
$(DIST) /multiverse/scripts/test-in-docker.sh

42
scripts/test-in-docker.sh Executable file
View file

@ -0,0 +1,42 @@
#!/bin/bash
#
# This script runs in a Docker container (started with the 'make test_in_docker' command)
# and installs multiverse as it is in your source directory.
#
set -e
apt -y update
apt -y install git rsync gpg
cosmos_deb=$(find /multiverse/apt/ -maxdepth 1 -name 'cosmos_*.deb' | sort -V | tail -1)
dpkg -i "$cosmos_deb"
test -d /var/cache/cosmos/repo || mkdir -p /var/cache/cosmos/repo
test -d /var/cache/cosmos/model || mkdir -p /var/cache/cosmos/model
# Make every "cosmos update" copy the contents from /multiverse
# without requiring the changes in there to be checked into git.
cat >/etc/cosmos/update.d/50update-while-testing << EOF
#!/bin/sh
rsync -a --delete --exclude .git /multiverse/ /var/cache/cosmos/repo
EOF
chmod 755 /etc/cosmos/update.d/50update-while-testing
sed -i -e 's!^#COSMOS_REPO_MODELS=.*!COSMOS_REPO_MODELS="\$COSMOS_REPO/global/"!' /etc/cosmos/cosmos.conf
export DEBIAN_FRONTEND=noninteractive
echo ""
echo "***"
echo ""
echo "$0: Configured docker container for testing of files in /multiverse."
echo ""
echo "You should now be able to do"
echo ""
echo " cosmos -v update"
echo " cosmos -v apply"
echo ""
exec bash -l