-
Notifications
You must be signed in to change notification settings - Fork 4
/
.travis.yml
56 lines (50 loc) · 2.46 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
language: generic
services:
- docker
matrix:
fast_finish: true
env:
# - IMAGE_BUILD_PLATFORM=stable-centos7
# - IMAGE_BUILD_PLATFORM=devel-centos7
- IMAGE_BUILD_PLATFORM=epel-centos7
install:
- npm install -g validate-dockerfile
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:
- docker exec -ti $DOCKER_CONTAINER_ID /bin/sh -c "/$ROLETOTEST/tests/test-in-docker-image.sh"
# 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 'sudo yum -y install tree'
- 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
#after_success:
# - docker login -e="$DOCKER_EMAIL" -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
# - if [ "$TRAVIS_BRANCH" == "master" -a "$IMAGE_BUILD_PLATFORM" == "stable-centos7" ]; then docker tag ${REPO}:${IMAGE_BUILD_PLATFORM} $REPO:latest; fi
# - docker tag ${REPO}:${IMAGE_BUILD_PLATFORM} $REPO:travis-${TRAVIS_BUILD_NUMBER}
# - docker tag ${REPO}:${IMAGE_BUILD_PLATFORM} $REPO:${IMAGE_BUILD_PLATFORM}-${ANSIBLE_VERSION}
# - docker tag ${REPO}:${IMAGE_BUILD_PLATFORM} $REPO:${IMAGE_BUILD_PLATFORM}-${GIT_COMMIT:-$GIT_TAG}
# - docker push $REPO
# - "[ -e \"~/.docker/config.json\" ] && shred -n 30 -u -z ~/.docker/config.json"
notifications:
email: false