diff mbox series

[v2,4/4] utils/docker-run: new script

Message ID 20220123160847.2653086-4-ricardo.martincoski@gmail.com
State Accepted
Headers show
Series [v2,1/4] utils/checkpackagelib: add unit tests | expand

Commit Message

Ricardo Martincoski Jan. 23, 2022, 4:08 p.m. UTC
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 <ricardo.martincoski@gmail.com>
---
Changes v1 -> v2:
  - none

NOTE: see also this other series for another use of this script: to call
shellcheck from check-package with stable results, not depending on:
- the developer having the tool shellcheck installed;
- the version of the tool that is installed;
http://patchwork.ozlabs.org/project/buildroot/patch/20211226184919.2753591-6-ricardo.martincoski@gmail.com/
---
 utils/docker-run | 7 +++++++
 1 file changed, 7 insertions(+)
 create mode 100755 utils/docker-run

Comments

Arnout Vandecappelle Feb. 6, 2022, 2 p.m. UTC | #1
On 23/01/2022 17:08, Ricardo Martincoski wrote:
> 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 <ricardo.martincoski@gmail.com>
> ---
> Changes v1 -> v2:
>    - none
> 
> NOTE: see also this other series for another use of this script: to call
> shellcheck from check-package with stable results, not depending on:
> - the developer having the tool shellcheck installed;
> - the version of the tool that is installed;
> http://patchwork.ozlabs.org/project/buildroot/patch/20211226184919.2753591-6-ricardo.martincoski@gmail.com/
> ---
>   utils/docker-run | 7 +++++++
>   1 file changed, 7 insertions(+)
>   create mode 100755 utils/docker-run
> 
> diff --git a/utils/docker-run b/utils/docker-run
> new file mode 100755
> index 0000000000..499c194d13
> --- /dev/null
> +++ b/utils/docker-run
> @@ -0,0 +1,7 @@
> +#!/usr/bin/bash
> +set -o errexit -o pipefail
> +DIR=$(dirname "${0}")
> +MAIN_DIR=$(readlink -f "${DIR}/..")
> +IMAGE=$(grep ^image: "${MAIN_DIR}/.gitlab-ci.yml" | sed -e 's,^image: ,,g' | sed -e 's,\$CI_REGISTRY,registry.gitlab.com,g')
> +set -x
> +docker run -v ${MAIN_DIR}:/home/br-user -t "${IMAGE}" $*

  This should be "$@" instead of $*, right?

  There was another shellcheck error as well, for which I added an exception. 
And I also added an exec to the last line.

  Regards,
  Arnout
diff mbox series

Patch

diff --git a/utils/docker-run b/utils/docker-run
new file mode 100755
index 0000000000..499c194d13
--- /dev/null
+++ b/utils/docker-run
@@ -0,0 +1,7 @@ 
+#!/usr/bin/bash
+set -o errexit -o pipefail
+DIR=$(dirname "${0}")
+MAIN_DIR=$(readlink -f "${DIR}/..")
+IMAGE=$(grep ^image: "${MAIN_DIR}/.gitlab-ci.yml" | sed -e 's,^image: ,,g' | sed -e 's,\$CI_REGISTRY,registry.gitlab.com,g')
+set -x
+docker run -v ${MAIN_DIR}:/home/br-user -t "${IMAGE}" $*