Skip to content

Commit

Permalink
Add script for running checkton locally
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
chmeliik committed Jul 24, 2024
1 parent 0f839fa commit 573b36a
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions hack/checkton-local.sh
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 573b36a

Please sign in to comment.