Skip to content

Commit

Permalink
Merge 36cd1a2 into 0b90854
Browse files Browse the repository at this point in the history
  • Loading branch information
sergsalatsky committed Mar 4, 2020
2 parents 0b90854 + 36cd1a2 commit 6919913
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
18 changes: 10 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,27 @@ services:
env:
matrix:
- ACTION=bandit
OS=fedora
OS_VERSION=29
OS=centos
OS_VERSION=7
PYTHON_VERSION=2
ENGINE=docker
- ACTION=bandit
OS=fedora
OS_VERSION=29
OS_VERSION=31
PYTHON_VERSION=3
ENGINE=docker
- OS=centos
OS_VERSION=7
PYTHON_VERSION=2
ENGINE=docker
- OS=fedora
OS_VERSION=29
PYTHON_VERSION=2
- OS=fedora
OS_VERSION=29
OS_VERSION=30
PYTHON_VERSION=3
ENGINE=docker
- OS=fedora
OS_VERSION=30
OS_VERSION=31
PYTHON_VERSION=3
ENGINE=docker
script:
- pip install coveralls
- ./test.sh
Expand Down
16 changes: 9 additions & 7 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
set -eux

# Prepare env vars
ENGINE=${ENGINE:="podman"}
OS=${OS:="centos"}
OS_VERSION=${OS_VERSION:="7"}
PYTHON_VERSION=${PYTHON_VERSION:="2"}
ACTION=${ACTION:="test"}
IMAGE="$OS:$OS_VERSION"
docker_mounts="-v $PWD:$PWD:z"
# Use arrays to prevent globbing and word splitting
engine_mounts=(-v "$PWD":"$PWD":z)
for dir in ${EXTRA_MOUNT:-}; do
docker_mounts="${docker_mounts} -v $dir:$dir:z"
engine_mounts=("${engine_mounts[@]}" -v "$dir":"$dir":z)
done

# Pull fedora images from registry.fedoraproject.org
Expand All @@ -19,7 +21,7 @@ fi


CONTAINER_NAME="dockerfile-parse-$OS-$OS_VERSION-py$PYTHON_VERSION"
RUN="docker exec -ti $CONTAINER_NAME"
RUN="$ENGINE exec -ti $CONTAINER_NAME"
if [[ $OS == "fedora" ]]; then
PIP_PKG="python$PYTHON_VERSION-pip"
PIP="pip$PYTHON_VERSION"
Expand All @@ -37,11 +39,11 @@ else
fi

# Create or resurrect container if needed
if [[ $(docker ps -qa -f name=$CONTAINER_NAME | wc -l) -eq 0 ]]; then
docker run --name $CONTAINER_NAME -d $docker_mounts -w $PWD -ti $IMAGE sleep infinity
elif [[ $(docker ps -q -f name=$CONTAINER_NAME | wc -l) -eq 0 ]]; then
if [[ $($ENGINE ps -qa -f name="$CONTAINER_NAME" | wc -l) -eq 0 ]]; then
$ENGINE run --name "$CONTAINER_NAME" -d "${engine_mounts[@]}" -w "$PWD" -ti "$IMAGE" sleep infinity
elif [[ $($ENGINE ps -q -f name="$CONTAINER_NAME" | wc -l) -eq 0 ]]; then
echo found stopped existing container, restarting. volume mounts cannot be updated.
docker container start $CONTAINER_NAME
$ENGINE container start "$CONTAINER_NAME"
fi

# Install dependencies
Expand Down

0 comments on commit 6919913

Please sign in to comment.