From 573b36a88ef80f661d4aa29d5d9bc1e7f178d96b Mon Sep 17 00:00:00 2001 From: Adam Cmiel Date: Mon, 22 Jul 2024 18:06:23 +0200 Subject: [PATCH] Add script for running checkton locally If you don't want to push to a PR just to re-run the linter, you can use this script. Won't work on ARM Macs, sorry! Signed-off-by: Adam Cmiel --- hack/checkton-local.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 hack/checkton-local.sh diff --git a/hack/checkton-local.sh b/hack/checkton-local.sh new file mode 100755 index 0000000000..e078d94056 --- /dev/null +++ b/hack/checkton-local.sh @@ -0,0 +1,31 @@ +#!/bin/bash +set -o errexit -o nounset -o pipefail + +get_checkton_image_based_on_action_version() { + sed -nE \ + 's;^\s*uses: (.*)/checkton.*(v[0-9]\S*);ghcr.io/\1/checkton:\2;p' \ + .github/workflows/checkton.yaml +} + +mapfile -t checkton_env_vars < <( + env CHECKTON_FIND_COPIES_HARDER="${CHECKTON_FIND_COPIES_HARDER:-true}" | grep '^CHECKTON_' +) +CHECKTON_IMAGE=${CHECKTON_IMAGE:-$(get_checkton_image_based_on_action_version)} + +{ + echo "Checkton image: $CHECKTON_IMAGE" + + echo "CHECKTON_* variables:" + printf " %s\n" "${checkton_env_vars[@]}" +} >&2 + + +if command -v getenforce >/dev/null && [[ "$(getenforce)" == Enforcing ]]; then + z=":z" +else + z="" +fi + +mapfile -t env_flags < <(printf -- "--env=%s\n" "${checkton_env_vars[@]}") + +podman run --rm --tty -v "$PWD:/code${z}" -w /code "${env_flags[@]}" "$CHECKTON_IMAGE"