Add Docker image definition as reference platform to run IDE tests. wxPython4
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Sun, 13 Feb 2022 21:01:27 +0100
branchwxPython4
changeset 3425 ee3b84d09ccf
parent 3424 7db96e011fe7
child 3426 c2c366964913
Add Docker image definition as reference platform to run IDE tests.
tests/tools/Docker/beremiz-sikuli/Dockerfile
tests/tools/Docker/beremiz-sikuli/build_docker_image.sh
tests/tools/Docker/beremiz-sikuli/build_in_docker.sh
tests/tools/Docker/beremiz-sikuli/clean_docker_container.sh
tests/tools/Docker/beremiz-sikuli/clean_docker_image.sh
tests/tools/Docker/beremiz-sikuli/create_docker_container.sh
tests/tools/Docker/beremiz-sikuli/enter_docker.sh
tests/tools/Docker/beremiz-sikuli/enter_docker_as_root.sh
tests/tools/Docker/beremiz-sikuli/rebuild_docker.sh
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/tools/Docker/beremiz-sikuli/Dockerfile	Sun Feb 13 21:01:27 2022 +0100
@@ -0,0 +1,66 @@
+#
+# Dockerfile for Beremiz
+# This container is used to run tests for Beremiz
+#
+FROM ubuntu:focal  
+                                        
+ENV TERM xterm-256color
+    
+ENV LANG en_US.UTF-8
+ENV LANGUAGE en_US:en
+ENV LC_ALL en_US.UTF-8
+
+ARG UNAME=testing
+ENV UNAME ${UNAME}
+ARG UID=1000
+ARG GID=1000
+RUN groupadd -g $GID $UNAME
+RUN useradd -m -u $UID -g $GID -s /bin/bash $UNAME
+
+RUN set -xe \
+    && apt-get update \
+    && TZ="America/Paris" \
+       DEBIAN_FRONTEND="noninteractive" \
+       apt-get install -y --no-install-recommends \
+               `# run sikuli` \
+               wget \
+               libopencv4.2-java \
+               openjdk-11-jre \
+               \
+               `# run X based tests` \
+               fluxbox \
+               wmctrl xdotool xvfb \
+               x11vnc xterm xnest \
+               \
+               `# to build tested apps` \
+               build-essential automake flex bison mercurial \
+               libgtk-3-dev libgl1-mesa-dev libglu1-mesa-dev \
+               libpython2.7-dev libssl-dev \
+               python2 virtualenv
+
+# link obtained from https://raiman.github.io/SikuliX1/downloads.html
+RUN set -xe && \
+    wget -qP /usr/local/bin \
+        https://launchpad.net/sikuli/sikulix/2.0.5/+download/sikulixide-2.0.5.jar && \
+    echo 0795f1e0866ee5a7a84e4c89793ea78c /usr/local/bin/sikulixide-2.0.5.jar | md5sum -c && \
+    ( echo '#!/bin/sh' && \
+      echo "exec java -jar /usr/local/bin/sikulixide-*.jar \"\$@\"" \
+    ) | install /dev/stdin /usr/local/bin/sikulix
+
+USER $UNAME
+
+RUN mkdir /home/$UNAME/build /home/$UNAME/src /home/$UNAME/test
+
+RUN virtualenv --python=$(which python2) ~/beremizenv
+
+RUN ~/beremizenv/bin/pip install \
+        lxml future matplotlib zeroconf2 enum34 pyro sslpsk posix_spawn \
+        twisted nevow autobahn \
+        wxPython==4.1.1
+
+# easy to remember 'do_tests' alias to invoke main makefile
+ARG OWNDIRBASENAME=beremiz
+ENV OWNDIRBASENAME ${OWNDIRBASENAME}
+RUN echo "alias do_tests='make -f /home/testing/src/beremiz/tests/Makefile'">/home/$UNAME/.bash_aliases
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/tools/Docker/beremiz-sikuli/build_docker_image.sh	Sun Feb 13 21:01:27 2022 +0100
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+set -e
+
+echo "Building docker image"
+docker build \
+    --build-arg UID=$(id -u) \
+    --build-arg GID=$(id -g) \
+    -t beremiz_sikuli .
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/tools/Docker/beremiz-sikuli/build_in_docker.sh	Sun Feb 13 21:01:27 2022 +0100
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+CONTAINER=beremiz_sikuli_current
+
+docker start $CONTAINER 
+docker exec -i -t $CONTAINER bash -i -c do_test $1
+docker stop $CONTAINER
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/tools/Docker/beremiz-sikuli/clean_docker_container.sh	Sun Feb 13 21:01:27 2022 +0100
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+# delete container
+docker rm beremiz_sikuli_current
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/tools/Docker/beremiz-sikuli/clean_docker_image.sh	Sun Feb 13 21:01:27 2022 +0100
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+# delete image
+docker rmi beremiz_sikuli
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/tools/Docker/beremiz-sikuli/create_docker_container.sh	Sun Feb 13 21:01:27 2022 +0100
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+set -e
+
+# source directory containing beremiz, matiec, etc..
+SRCDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd ../../../../.. && pwd )"
+echo "SOURCE direcory : $SRCDIR"
+
+# absolute path to test directory. ~/test if not given as only argument
+TESTDIR=${1:-~/test}
+mkdir -p $TESTDIR
+echo "TEST direcory : $TESTDIR"
+
+UNAME=testing
+UHOME=/home/$UNAME
+
+# define TESTDEBUG in env to enable dev-mode debug pasthrough
+# for x11vnc and Xnest
+DEBUGARGS="-v /tmp/.X11-unix/X0:/tmp/.X11-unix/X0 -e DISPLAY=$DISPLAY"
+
+# In case VNC with x11vnc is prefered, then a port should bepassed like this
+# DEBUGARGS="-p 5900:5900"
+
+echo "Creating docker container"
+docker create \
+       --name beremiz_sikuli_current \
+       -v $SRCDIR:$UHOME/src \
+       -v $TESTDIR:$UHOME/test \
+       `if [ "$TESTDEBUG" == "YES" ]; then echo $DEBUGARGS; fi` \
+       -w $UHOME/test \
+       -i -t beremiz_sikuli /bin/bash
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/tools/Docker/beremiz-sikuli/enter_docker.sh	Sun Feb 13 21:01:27 2022 +0100
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+CONTAINER=beremiz_sikuli_current
+
+docker start -i $CONTAINER
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/tools/Docker/beremiz-sikuli/enter_docker_as_root.sh	Sun Feb 13 21:01:27 2022 +0100
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+CONTAINER=beremiz_sikuli_current
+
+docker start $CONTAINER
+docker exec -i -t -u root $CONTAINER bash
+docker stop $CONTAINER
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/tools/Docker/beremiz-sikuli/rebuild_docker.sh	Sun Feb 13 21:01:27 2022 +0100
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+set -e
+
+./clean_docker_container.sh || true
+./clean_docker_image.sh || true
+./build_docker_image.sh
+./create_docker_container.sh $1
+