#!/bin/sh
set -eux
IMAGE="$1"

if type podman >/dev/null 2>&1; then
    RUNC=podman
else
    RUNC="sudo docker"
fi

# only run pylint on a single release, too annoying to keep the code compatible with multiple versions
if [ "${IMAGE%fedora:latest}" != "$IMAGE" ]; then
    TEST_CODE="1"
fi

OS=${IMAGE##*/}
OS=${OS%:*}
$RUNC run --interactive -e DEBUG=${DEBUG:-} -e TEST_CODE="${TEST_CODE:-}" --rm ${RUNC_OPTIONS:-} --volume `pwd`:/source:ro --workdir /source "$IMAGE" /bin/sh tests/run-$OS
