-
Notifications
You must be signed in to change notification settings - Fork 2
/
.travis.yml
63 lines (56 loc) · 2.43 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
language: python
sudo: required
dist: trusty
group: edge
services:
- docker
matrix:
fast_finish: true
allow_failures:
- env: IMAGE_BUILD_PLATFORM=devel-centos7
env:
- IMAGE_BUILD_PLATFORM=stable-centos7
- IMAGE_BUILD_PLATFORM=devel-centos7
- IMAGE_BUILD_PLATFORM=epel-centos7
- IMAGE_BUILD_PLATFORM=ansible-min-version-centos7
- IMAGE_BUILD_PLATFORM=pip-ubuntu
install:
- npm install -g validate-dockerfile
before_script:
# TESTDIR = Where the stable-centos/Dockerfile is located
- export TESTDIR=tests
# ROLETOTEST = The name of this repo
- export ROLETOTEST=$(basename $(pwd))
- export COMMIT=${TRAVIS_COMMIT::8}
# The tag we assign the docker image we build with the Dockerfile
- export REPO=csc/ansible
# https://www.npmjs.com/package/validate-dockerfile - validate the Dockerfile
- docklint ${TESTDIR}/${IMAGE_BUILD_PLATFORM}/Dockerfile
# Build the image
- docker build -t ${REPO}:${IMAGE_BUILD_PLATFORM} ${TESTDIR}/${IMAGE_BUILD_PLATFORM}/
# Find out min_ansible_version
- export MIN_ANSIBLE_VERSION=$(grep min_ansible_version meta/main.yml|cut -d ':' -f2|xargs)
- echo "INFO min_ansible_version $MIN_ANSIBLE_VERSION"
# Launch the container
- docker run --privileged -d -ti -e "container=docker" -v `pwd`:/$ROLETOTEST -v /sys/fs/cgroup:/sys/fs/cgroup ${REPO}:${IMAGE_BUILD_PLATFORM} /usr/sbin/init
- DOCKER_CONTAINER_ID=$(docker ps | grep ${IMAGE_BUILD_PLATFORM} | awk '{print $1}')
# If ansible-min-version install it with yum
- if [ "$IMAGE_BUILD_PLATFORM" == "ansible-min-version-centos7" ]; then docker exec -ti $DOCKER_CONTAINER_ID /bin/sh -c "/usr/bin/yum -y install ansible-$MIN_ANSIBLE_VERSION"; fi
- docker logs $DOCKER_CONTAINER_ID
script:
# Testing of this ansible-role:
- docker exec -ti $DOCKER_CONTAINER_ID /bin/sh -c "/$ROLETOTEST/tests/test-in-docker-image.sh"
after_script:
# Print some logs and other useful information for debugging travis:
- >
docker exec -ti $DOCKER_CONTAINER_ID /bin/sh -c 'echo -ne "------\nEND ANSIBLE TESTS\n------\nSystemD Units:\n------\n";
systemctl --no-pager --all --full status ;
echo -ne "------\nJournalD Logs:\n------\n" ;
sudo journalctl --catalog --all --full --no-pager'
- docker exec -ti $DOCKER_CONTAINER_ID /bin/sh -c 'tree /ansible*'
- docker ps -a
- docker stop $DOCKER_CONTAINER_ID
- docker rm -v $DOCKER_CONTAINER_ID
notifications:
email: false
webhooks: https://galaxy.ansible.com/api/v1/notifications/