From 242e9d72e7d2217d6213f63f65d93c5ba3b01f7c Mon Sep 17 00:00:00 2001 From: Ricardo Martincoski Date: Sun, 23 Jan 2022 13:08:46 -0300 Subject: [PATCH] utils/docker-run: new script Add a small script to run commands in the same docker image used in the GitLab CI. For instance, one can run check-package unit tests without installing pytest directly in the host: $ ./utils/docker-run python3 -m pytest -v utils/checkpackagelib/ Signed-off-by: Ricardo Martincoski [Arnout: fix shellcheck errors; add exec] Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- utils/docker-run | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100755 utils/docker-run diff --git a/utils/docker-run b/utils/docker-run new file mode 100755 index 0000000000..0614f1325d --- /dev/null +++ b/utils/docker-run @@ -0,0 +1,10 @@ +#!/usr/bin/bash +set -o errexit -o pipefail +DIR=$(dirname "${0}") +MAIN_DIR=$(readlink -f "${DIR}/..") +# shellcheck disable=SC2016 +IMAGE=$(grep ^image: "${MAIN_DIR}/.gitlab-ci.yml" | \ + sed -e 's,^image: ,,g' | sed -e 's,\$CI_REGISTRY,registry.gitlab.com,g') + +set -x +exec docker run -v "${MAIN_DIR}:/home/br-user" -t "${IMAGE}" "$@"