Skip to content

Commit

Permalink
docker: Pass environment to docker
Browse files Browse the repository at this point in the history
  • Loading branch information
mudler committed Aug 15, 2018
1 parent b76db5d commit 99f8d58
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ cache:
directories:
- assets/cache
script:
- mkdir -p assets/cache
- chmod a+w assets/cache
- touch openqa-debug.log autoinst-log.txt
- chmod a+w openqa-debug.log autoinst-log.txt
- mkdir -p assets/cache && chmod a+w assets/cache
- touch openqa-debug.log autoinst-log.txt && chmod a+w openqa-debug.log autoinst-log.txt
- make docker-test
after_failure:
- cat openqa-debug.log
Expand Down
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ PROVE_ARGS ?= -r -v
DOCKER_IMG ?= openqa:latest
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
current_dir := $(patsubst %/,%,$(dir $(mkfile_path)))
docker_env := $(shell env | grep -v -E 'LANG|LC_|HOME|USER|PWD|PATH' | cut -f1 -d= | sed 's/^/-e /')

.PHONY: all
all:
Expand Down Expand Up @@ -126,15 +127,15 @@ docker-test-build:

.PHONY: docker-test-run
docker-test-run:
docker run --cap-add SYS_ADMIN -v $(current_dir):/opt/openqa -v /var/run/dbus:/var/run/dbus \
--env-file <(env) $(DOCKER_IMG) make travis-codecov
docker run -v $(current_dir):/opt/openqa -v /var/run/dbus:/var/run/dbus \
$(docker_env) $(DOCKER_IMG) make travis-codecov

.PHONY: docker-test-travis
docker-test-travis:
docker run --cap-add SYS_ADMIN -v $(current_dir):/opt/openqa -v /var/run/dbus:/var/run/dbus \
--env-file <(env | grep TRAVIS) -e TRAVIS=true -e FULLSTACK -e UITESTS -e SCHEDULER_FULLSTACK -e DEVELOPER_FULLSTACK \
docker run -v $(current_dir):/opt/openqa -v /var/run/dbus:/var/run/dbus \
$(docker_env) -e TRAVIS=true -e FULLSTACK -e UITESTS -e SCHEDULER_FULLSTACK -e DEVELOPER_FULLSTACK \
-e GH_PUBLISH $(DOCKER_IMG) make travis-codecov

.PHONY: docker-test
docker-test: docker-test-build docker-test-travis
docker-test: docker-test-build docker-test-run
echo "Use docker-rm and docker-rmi to remove the container and image if necessary"
27 changes: 16 additions & 11 deletions docker/openqa/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/bin/bash

set -e
#!/bin/bash

DEBUG="${DEBUG:-0}"
INSTALL_FROM_CPAN="${INSTALL_FROM_CPAN:-0}"

set -e
[ "$DEBUG" -eq 1 ] && set -x

# First, try to upgrade all container dependencies (or we won't catch bugs until a new docker image is built)
sudo zypper --gpg-auto-import-keys -n ref --force && sudo zypper up -l -y

Expand All @@ -14,13 +16,14 @@ cd /opt/testing_area/openqa
function create_db {
set -e
export PGDATA=$(mktemp -d)
echo ">> Creating fake database in ${PGDATA}"
initdb --auth=trust -N $PGDATA

cat >> $PGDATA/postgresql.conf <<HEREDOC
listen_addresses='localhost'
unix_socket_directories='$PGDATA'
fsync=off
full_page_writes=off
listen_addresses='localhost'
unix_socket_directories='$PGDATA'
fsync=off
full_page_writes=off
HEREDOC

pg_ctl -D $PGDATA start -w
Expand All @@ -31,6 +34,8 @@ HEREDOC


function run_as_normal_user {
echo ">> Trying to get dependencies from CPAN"

[ "$INSTALL_FROM_CPAN" -eq 1 ] && \
(cpanm --local-lib=~/perl5 local::lib && cpanm -n --installdeps . ) || \
cpanm -n --mirror http://no.where/ --installdeps .
Expand All @@ -41,16 +46,16 @@ function run_as_normal_user {
export MOJO_TMPDIR=$(mktemp -d)
export OPENQA_LOGFILE=/tmp/openqa-debug.log
else
echo "Missing depdencies. Please check output above"
echo ">> Dependencies missing. Please check output above"
fi

[ "$INSTALL_FROM_CPAN" -eq 1 ] && eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
[ "$INSTALL_FROM_CPAN" -eq 1 ] && eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib) || true
}

export -f create_db run_as_normal_user



run_as_normal_user;

echo ">> Running tests"

dbus-run-session -- sh -c "$*"

0 comments on commit 99f8d58

Please sign in to comment.