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

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

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

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