Adding docker container capabilities to Travis

This commit is contained in:
James Cammarata 2016-03-03 15:23:44 -05:00
parent 80b10bd669
commit 92dcad8e99
4 changed files with 109 additions and 16 deletions

View file

@ -1,16 +1,20 @@
sudo: false
sudo: required
services:
- docker
language: python
matrix:
include:
- env: TOXENV=py24 INTEGRATION=no
- env: TOXENV=py26 INTEGRATION=yes
- env: TARGET=sanity TOXENV=py24
- env: TARGET=sanity TOXENV=py26
python: 2.6
- env: TOXENV=py27 INTEGRATION=yes
- env: TARGET=sanity TOXENV=py27
python: 2.7
- env: TOXENV=py34 INTEGRATION=no
- env: TARGET=sanity TOXENV=py34
python: 3.4
- env: TOXENV=py35 INTEGRATION=no
- env: TARGET=sanity TOXENV=py35
python: 3.5
- env: TARGET=centos7 TARGET_OPTIONS="--volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
- env: TARGET=ubuntu1404
addons:
apt:
sources:
@ -18,16 +22,8 @@ addons:
packages:
- python2.4
install:
- pip install tox PyYAML Jinja2 sphinx
- pip install tox
script:
# urllib2's defaults are not secure enough for us
- ./test/code-smell/replace-urlopen.sh .
- ./test/code-smell/use-compat-six.sh lib
- ./test/code-smell/boilerplate.sh
- ./test/code-smell/required-and-default-attributes.sh
- if test x"$TOXENV" != x'py24' ; then tox ; fi
- if test x"$TOXENV" = x'py24' ; then python2.4 -V && python2.4 -m compileall -fq -x 'module_utils/(a10|rax|openstack|ec2|gce).py' lib/ansible/module_utils ; fi
#- make -C docsite all
- if test x"$INTEGRATION" = x'yes' ; then source ./hacking/env-setup && cd test/integration/ && make parsing && make test_var_precedence && make unicode ; fi
- ./test/utils/run_tests.sh
after_success:
- coveralls

View file

@ -0,0 +1,48 @@
# Latest version of centos
FROM centos:centos7
ENV LC_ALL en_US.UTF-8
#RUN yum -y swap fakesystemd systemd
RUN yum -y update; yum clean all; yum -y swap fakesystemd systemd
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*; \
rm -f /etc/systemd/system/*.wants/*; \
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*; \
rm -f /lib/systemd/system/anaconda.target.wants/*;
RUN yum -y install \
dbus-python \
epel-release \
git \
make \
mercurial \
rubygems \
subversion \
sudo \
unzip \
which
RUN yum -y install \
PyYAML \
python-coverage \
python-httplib2 \
python-jinja2 \
python-keyczar \
python-mock \
python-nose \
python-paramiko \
python-pip \
python-setuptools \
python-virtualenv
RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers
RUN mkdir /etc/ansible/
RUN echo -e '[local]\nlocalhost' > /etc/ansible/hosts
VOLUME /sys/fs/cgroup /run /tmp
ENV container=docker
CMD ["/usr/sbin/init"]

View file

@ -0,0 +1,34 @@
FROM ubuntu:trusty
ENV LC_ALL en_US.UTF-8
RUN apt-get clean; apt-get update -y;
RUN apt-get install -y \
debianutils \
git \
make \
mercurial \
ruby \
subversion \
sudo \
unzip
RUN apt-get install -y \
python-coverage \
python-httplib2 \
python-jinja2 \
python-keyczar \
python-mock \
python-nose \
python-paramiko \
python-pip \
python-setuptools \
python-virtualenv \
python-yaml
RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers
RUN mkdir /etc/ansible/
RUN echo -e '[local]\nlocalhost' > /etc/ansible/hosts
VOLUME /sys/fs/cgroup /run /tmp
ENV container=docker

15
test/utils/run_tests.sh Executable file
View file

@ -0,0 +1,15 @@
#!/bin/sh -x
if [ "${TARGET}" = "sanity" ]; then
./test/code-smell/replace-urlopen.sh .
./test/code-smell/use-compat-six.sh lib
./test/code-smell/boilerplate.sh
./test/code-smell/required-and-default-attributes.sh
if test x"$TOXENV" != x'py24' ; then tox ; fi
if test x"$TOXENV" = x'py24' ; then python2.4 -V && python2.4 -m compileall -fq -x 'module_utils/(a10|rax|openstack|ec2|gce).py' lib/ansible/module_utils ; fi
else
docker build -t ansible_test/${TARGET} test/utils/docker/${TARGET}
docker run -d --volume="${PWD}:/root/ansible" ${TARGET_OPTIONS} ansible_test/${TARGET} > /tmp/cid_${TARGET}
docker exec -ti $(cat /tmp/cid_${TARGET}) /bin/sh -c 'cd /root/ansible; . hacking/env-setup; make tests && (cd test/integration; make)'
docker kill $(cat /tmp/cid_${TARGET})
fi