From 937ca474e55de7e9cb1380f9613fa36eee9ea7ac Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Mon, 22 Dec 2025 20:55:45 -0800 Subject: [PATCH 1/5] feat(linters): migrate bash linters/formatters to use mise --- .tool-versions | 2 -- shell/linters/bash.sh | 10 +++++++--- shell/shellcheck.sh | 11 ++++++----- shell/shfmt.sh | 10 +++++----- versions.yaml | 3 +++ 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/.tool-versions b/.tool-versions index 1bc6b84cc..12e6edce4 100644 --- a/.tool-versions +++ b/.tool-versions @@ -13,8 +13,6 @@ golang 1.23.4 # The most common case is nodejs. ## <> # The below tools are used by all repositories when using devbase -shellcheck 0.9.0 -shfmt 3.7.0 goreleaser 1.20.0 terraform 1.4.4 ## <> diff --git a/shell/linters/bash.sh b/shell/linters/bash.sh index 9d9825311..03468fa1d 100644 --- a/shell/linters/bash.sh +++ b/shell/linters/bash.sh @@ -16,15 +16,19 @@ find_shell_files() { } shellcheck_linter() { - find_shell_files | xargs -n40 "$SHELLCHECKPATH" -x -P SCRIPTDIR + # Wrapper script already sets external sources & script directory + # source path. + find_shell_files | xargs -n40 "$SHELLCHECKPATH" } shellfmt_linter() { - find_shell_files | xargs -n40 "$SHELLFMTPATH" -s -d + # Wrapper script already sets --simplify + find_shell_files | xargs -n40 "$SHELLFMTPATH" --diff } shellfmt_formatter() { - find_shell_files | xargs -n40 "$SHELLFMTPATH" -w -l + # Wrapper script already sets --simplify + find_shell_files | xargs -n40 "$SHELLFMTPATH" --write --list } linter() { diff --git a/shell/shellcheck.sh b/shell/shellcheck.sh index 7b9903be2..2f68b1b06 100755 --- a/shell/shellcheck.sh +++ b/shell/shellcheck.sh @@ -1,14 +1,15 @@ #!/usr/bin/env bash -# This is a wrapper around asdf to run shellcheck. +# This is a wrapper around mise to run shellcheck. # Useful for using the correct version of shellcheck # with your editor. set -e DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" -# shellcheck source=./lib/asdf.sh -source "$DIR/lib/asdf.sh" +# shellcheck source=./lib/mise/stub.sh +source "$DIR/lib/mise/stub.sh" # Always set the correct script directory. -args=("-P" "SCRIPTDIR" "-x" "$@") -asdf_devbase_exec shellcheck "${args[@]}" +args=(--external-sources --source-path=SCRIPTDIR "$@") + +mise_exec_tool shellcheck "${args[@]}" diff --git a/shell/shfmt.sh b/shell/shfmt.sh index 6faa653c5..4da0c83fa 100755 --- a/shell/shfmt.sh +++ b/shell/shfmt.sh @@ -1,15 +1,15 @@ #!/usr/bin/env bash -# This is a wrapper around asdf to run shfmt. +# This is a wrapper around mise to run shfmt. # Useful for using the correct version of shfmt # with your editor. set -e DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" -# shellcheck source=./lib/asdf.sh -source "$DIR/lib/asdf.sh" +# shellcheck source=./lib/mise/stub.sh +source "$DIR/lib/mise/stub.sh" # Always set simplify mode. -args=("-s" "$@") +args=("--simplify" "$@") -asdf_devbase_exec shfmt "${args[@]}" +mise_exec_tool shellcheck "${args[@]}" diff --git a/versions.yaml b/versions.yaml index 039fd95b4..0fd623c0f 100644 --- a/versions.yaml +++ b/versions.yaml @@ -13,6 +13,9 @@ mage: 1.14.0 ## Sync with templates/scripts/devbase.sh.tpl gojq: v0.12.18 +shellcheck: 0.9.0 +shfmt: 3.7.0 + # protobuf formatters/plugins/tools/etc buf: 1.60.0 protoc-gen-validate: 0.6.7 From c583802b37e0bd87cf942a893d1629a3ceaccf95 Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Wed, 24 Dec 2025 13:09:54 -0800 Subject: [PATCH 2/5] Fix cooy/paste error --- shell/shfmt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/shfmt.sh b/shell/shfmt.sh index 4da0c83fa..73a655c80 100755 --- a/shell/shfmt.sh +++ b/shell/shfmt.sh @@ -12,4 +12,4 @@ source "$DIR/lib/mise/stub.sh" # Always set simplify mode. args=("--simplify" "$@") -mise_exec_tool shellcheck "${args[@]}" +mise_exec_tool shfmt "${args[@]}" From 6f62859d6cb176c30f0bdcc30494f168b55b5b7f Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Thu, 25 Dec 2025 16:18:53 -0800 Subject: [PATCH 3/5] fix(mise): remove asdf shim in CI --- shell/lib/mise.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/shell/lib/mise.sh b/shell/lib/mise.sh index 65c3ca0af..adf4ec724 100644 --- a/shell/lib/mise.sh +++ b/shell/lib/mise.sh @@ -252,6 +252,14 @@ mise_exec_tool_with_bin() { shift local binName="$1" shift + + # asdf shims take precedence in the PATH, + # so remove it in CI before execution. + local asdfShim="${ASDF_DIR:-$HOME/.asdf}/shims/$binName" + if in_ci_environment && [[ -f "$asdfShim" ]]; then + rm "$asdfShim" + fi + local version version="$(get_tool_version "$binName")" MISE_GITHUB_TOKEN=$(github_token) run_mise exec "$toolName@$version" -- "$binName" "$@" From e294f067f4dc787643cdd3ca540a32d18eaa1c2a Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Thu, 25 Dec 2025 23:07:32 -0800 Subject: [PATCH 4/5] Fix lint error --- shell/lib/mise.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/lib/mise.sh b/shell/lib/mise.sh index adf4ec724..da74c9f2b 100644 --- a/shell/lib/mise.sh +++ b/shell/lib/mise.sh @@ -256,7 +256,7 @@ mise_exec_tool_with_bin() { # asdf shims take precedence in the PATH, # so remove it in CI before execution. local asdfShim="${ASDF_DIR:-$HOME/.asdf}/shims/$binName" - if in_ci_environment && [[ -f "$asdfShim" ]]; then + if in_ci_environment && [[ -f $asdfShim ]]; then rm "$asdfShim" fi From 9883beae6d72282dedbc433b208eb826d4cd5d0a Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Mon, 5 Jan 2026 11:57:57 -0800 Subject: [PATCH 5/5] Remove unused functions --- shell/lib/asdf.sh | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/shell/lib/asdf.sh b/shell/lib/asdf.sh index c7df770e8..17a48d597 100644 --- a/shell/lib/asdf.sh +++ b/shell/lib/asdf.sh @@ -58,43 +58,6 @@ asdf_get_version_from_devbase() { grep -E "^$tool_name " "$devbase_dir/.tool-versions" | head -n1 | awk '{print $2}' } -# asdf_devbase_exec runs asdf_devbase_run but execs the command instead -# of running it as a subprocess. -asdf_devbase_exec() { - asdf_tool_env_var "$1" - exec "$@" -} - -# asdf_devbase_run executes a command with the versions from the devbase -# .tool-versions file. This will fail if the tool isn't installed, so callers -# should invoke asdf_devbase_ensure first. -asdf_devbase_run() { - asdf_tool_env_var "$1" - "$@" -} - -# asdf_tool_env_var exports an environment variable to have the provided -# tool version be used in asdf. This mutates the current shell's -# environment variables by exporting the variable. -# -# See: https://asdf-vm.com/manage/versions.html#set-current-version -asdf_tool_env_var() { - local tool="$1" - # Why: We're OK with this being the way it is. - # shellcheck disable=SC2155 - local tool_env_var="$(tr '[:lower:]-' '[:upper:]_' <<<"$tool")" - - # Why: We're OK with this being the way it is. - # shellcheck disable=SC2155 - local version="$(asdf_get_version_from_devbase "$tool")" - if [[ -z $version ]]; then - echo "No version found for $tool in devbase .tool-versions file" - return 1 - fi - - export "ASDF_${tool_env_var}_VERSION"="${version}" -} - # asdf_devbase_ensure ensures that all versions of tools are installed from # .tool-version files in the current directory and all subdirectories. asdf_devbase_ensure() {