-
Notifications
You must be signed in to change notification settings - Fork 18
/
.travis.yml
59 lines (52 loc) · 2.3 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
language: python
sudo: required
dist: trusty
group: edge
services:
- docker
matrix:
fast_finish: true
allow_failures:
- env: IMAGE_BUILD_PLATFORM=latest-epel-centos7
env:
- IMAGE_BUILD_PLATFORM=stable-centos7
- IMAGE_BUILD_PLATFORM=devel-centos7
- IMAGE_BUILD_PLATFORM=epel-centos7
- IMAGE_BUILD_PLATFORM=latest-epel-centos7
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}/
# 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}')
- docker logs $DOCKER_CONTAINER_ID
# Testing of this ansible-role:
# Two variants, one where we modify requirements.yml to not have any versions
script:
- if [ "$IMAGE_BUILD_PLATFORM" == "latest-epel-centos7" ]; then docker exec -ti $DOCKER_CONTAINER_ID /bin/sh -c "/$ROLETOTEST/tests/test-in-docker-image.sh latest"; fi
- if [ "$IMAGE_BUILD_PLATFORM" != "latest-epel-centos7" ]; then docker exec -ti $DOCKER_CONTAINER_ID /bin/sh -c "/$ROLETOTEST/tests/test-in-docker-image.sh"; fi
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/