#!/bin/bash

set -e

echo "Testing circleci build and test locally"
echo

cd `dirname $0`
cd ..

set -x
circleci config validate
docker pull centos:latest
mkdir -p /tmp/ccache
mkdir -p /tmp/yum-cache
mkdir -p dist

if [ "$#" == "0" ] ; then
    echo "Error: supply job name(s) as arguments, please."
    echo "Example: $0 build test"
    echo " or "
    echo "just $0 test"
    echo "Depending on what jobs you have defined in .circleci/config.yml"
    echo
    echo "Instructions:"
    echo "This scripts simulates running CircleCI automation in the could with"
    echo "/dist, ccache and yum cache preserved between jobs."
    echo "-> run build and tests as they would in the cloud but with local caching"
    
    exit 1
fi

while (( "$#" )) ; do
    circleci local execute -v /tmp/yum-cache:/var/cache/yum -v /tmp/ccache:/ccache -v ${PWD}/dist:/root/dist -v ${PWD}/dist:/dist --job "$1"
    shift
done

Add CI simulation possibility for devs
Add CI simulation possibility for devs
