Skip to content

Commit

Permalink
Travis CI: Parallelize the test matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
gildegoma committed Jul 26, 2020
1 parent 00c1252 commit d5c230f
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,47 @@ language: generic
sudo: required

env:
DOCKER_COMPOSE_VERSION: 1.26.2
global:
- DOCKER_CACHE_DIR=$HOME/docker
- DOCKER_COMPOSE_VERSION=1.26.2
- ANSIBLE_VERSION=2.9.9
jobs:
- PLATFORM=centos PLAYBOOK=user.yml
- PLATFORM=debian PLAYBOOK=user.yml
- PLATFORM=ubuntu PLAYBOOK=user.yml
- PLATFORM=centos PLAYBOOK=root.yml
- PLATFORM=debian PLAYBOOK=root.yml
- PLATFORM=ubuntu PLAYBOOK=root.yml

services:
- docker

cache:
pip: true
directories:
- $HOME/docker
- $DOCKER_CACHE_DIR

before_install:
- if [[ -d $HOME/docker ]]; then ls $HOME/docker/*.tar.gz | xargs -I {file} sh -c "zcat {file} | docker load"; fi
- export DOCKER_CACHE_PLATFORM_DIR=$DOCKER_CACHE_DIR/$PLATFORM
- if [[ -d $DOCKER_CACHE_PLATFORM_DIR ]]; then ls $DOCKER_CACHE_PLATFORM_DIR/*.tar.gz | xargs -I {file} sh -c "zcat {file} | docker load"; fi
- sudo rm /usr/local/bin/docker-compose
- curl -L https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_VERSION/docker-compose-`uname -s`-`uname -m` > docker-compose
- chmod +x docker-compose
- sudo mv docker-compose /usr/local/bin

install:
- sudo pip install ansible==2.9.9 > /dev/null 2>&1
- sudo pip install ansible==$ANSIBLE_VERSION > /dev/null 2>&1

script:
- cd tests
- docker-compose up -d
- ansible-playbook user.yml -l centos
- ansible-playbook user.yml -l debian
- ansible-playbook user.yml -l ubuntu
- docker-compose config --services | grep $PLATFORM | xargs docker-compose up -d
- ansible-playbook $PLAYBOOK -l $PLATFORM
- docker-compose down
- docker-compose up -d
- ansible-playbook root.yml -l centos
- ansible-playbook root.yml -l debian
- ansible-playbook root.yml -l ubuntu

before_cache:
- >
mkdir -p $HOME/docker && docker images -a --filter='dangling=false' --format '{{.Repository}}:{{.Tag}} {{.ID}}'
| xargs -n 2 -t sh -c 'test -e $HOME/docker/$1.tar.gz || docker save $0 | gzip -2 > $HOME/docker/$1.tar.gz'
mkdir -p $DOCKER_CACHE_PLATFORM_DIR && docker images -a --filter='dangling=false' --format '{{.Repository}}:{{.Tag}} {{.ID}}' "tests_$PLATFORM*"
| xargs -n 2 -t sh -c 'test -e $DOCKER_CACHE_PLATFORM_DIR/$1.tar.gz || docker save $0 | gzip -2 > $DOCKER_CACHE_PLATFORM_DIR/$1.tar.gz'
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/

0 comments on commit d5c230f

Please sign in to comment.