Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 5 additions & 17 deletions scripts/ci/binary-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,38 +30,29 @@ set -euo pipefail
# - WebAssembly modules, compiled Java classes, .NET assemblies
#
# Runs in two contexts:
# pre-commit hook -- checks staged files (--check --staged)
# pre-commit hook -- checks filenames passed by pre-commit (--check files...)
# CI workflow -- checks PR diff files (--check --ci)
#
# Exit codes: 0 = clean, 1 = binary artifacts found or error.

FILE_MODE="staged"
FILE_MODE="all"
Comment thread
hubcio marked this conversation as resolved.
FILES=()

while [[ $# -gt 0 ]]; do
case "$1" in
--check)
shift
;;
--staged)
FILE_MODE="staged"
shift
;;
--ci)
FILE_MODE="ci"
shift
;;
--all)
FILE_MODE="all"
shift
;;
--help|-h)
echo "Usage: $0 [--check] [--staged|--ci|--all] [files...]"
echo "Usage: $0 [--check] [--ci] [files...]"
echo ""
echo "File selection:"
echo " --staged Check staged files (default, for git hooks)"
echo " [none] Check all tracked files (default)"
echo " --ci Check files changed in PR (for CI)"
echo " --all Check all tracked files"
echo " [files] Check specific files"
exit 0
;;
Expand All @@ -79,17 +70,14 @@ done

get_files() {
case "$FILE_MODE" in
staged)
git diff --cached --name-only --diff-filter=ACM
;;
ci)
if [ -n "${GITHUB_BASE_REF:-}" ]; then
git fetch --no-tags --depth=1 origin "${GITHUB_BASE_REF}:${GITHUB_BASE_REF}" 2>/dev/null || true
git diff --name-only --diff-filter=ACM "${GITHUB_BASE_REF}...HEAD"
elif [ -n "${CI:-}" ]; then
git diff --name-only --diff-filter=ACM HEAD~1
else
git diff --cached --name-only --diff-filter=ACM
git ls-files
fi
;;
all)
Expand Down
30 changes: 3 additions & 27 deletions scripts/ci/markdownlint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@
set -euo pipefail

MODE="check"
FILE_MODE="all"
FILES=()

# Accept mode flags plus optional file paths. In pre-commit, matching staged
# markdown files are passed as positional arguments.
# Accept mode flags plus optional file paths. Pre-commit passes matching
# markdown files as positional arguments.
while [[ $# -gt 0 ]]; do
case "$1" in
--check)
Expand All @@ -34,20 +33,10 @@ while [[ $# -gt 0 ]]; do
MODE="fix"
shift
;;
--staged)
FILE_MODE="staged"
shift
;;
--all)
FILE_MODE="all"
shift
;;
--help|-h)
echo "Usage: $0 [--check|--fix] [--staged|--all] [files...]"
echo "Usage: $0 [--check|--fix] [files...]"
echo " --check Check markdown files for issues (default)"
echo " --fix Automatically fix markdown issues"
echo " --staged Check staged markdown files"
echo " --all Check all markdown files (default)"
exit 0
;;
-*)
Expand All @@ -66,19 +55,6 @@ done
# helm/charts/iggy/README.md is auto-generated by helm-docs
IGNORE_ARGS=(--ignore "helm/charts/iggy/README.md")

# Keep --staged for manual runs; pre-commit normally passes matching staged
# files directly through pass_filenames.
if [ ${#FILES[@]} -eq 0 ] && [ "$FILE_MODE" = "staged" ]; then
while IFS= read -r file; do
[ -n "$file" ] && FILES+=("$file")
done < <(git diff --cached --name-only --diff-filter=ACM -- '*.md')

if [ ${#FILES[@]} -eq 0 ]; then
echo "✅ No staged markdown files to check"
exit 0
fi
fi

# Default to the full repository for CI/manual runs, but use the explicit file
# list when pre-commit or a caller passes paths directly.
if [ ${#FILES[@]} -gt 0 ]; then
Expand Down
45 changes: 7 additions & 38 deletions scripts/ci/shellcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@
set -euo pipefail

MODE="check"
FILE_MODE="all"
FILES=()

# Accept mode flags plus optional file paths. In pre-commit, matching staged
# shell files are passed as positional arguments.
# Accept mode flags plus optional file paths. Pre-commit passes matching shell
# files as positional arguments.
while [[ $# -gt 0 ]]; do
case "$1" in
--check)
Expand All @@ -36,20 +35,10 @@ while [[ $# -gt 0 ]]; do
MODE="fix"
shift
;;
--staged)
FILE_MODE="staged"
shift
;;
--all)
FILE_MODE="all"
shift
;;
--help|-h)
echo "Usage: $0 [--check|--fix] [--staged|--all] [files...]"
echo "Usage: $0 [--check|--fix] [files...]"
echo " --check Check shell scripts for issues (default)"
echo " --fix Show detailed suggestions for fixes"
echo " --staged Check staged shell scripts"
echo " --all Check all shell scripts (default)"
exit 0
;;
-*)
Expand Down Expand Up @@ -88,26 +77,6 @@ for path in "${EXCLUDE_PATHS[@]}"; do
FIND_EXCLUDE_ARGS+=("-not" "-path" "$path")
done

# Keep --staged for manual runs; pre-commit normally passes matching staged
# files directly through pass_filenames.
if [ ${#FILES[@]} -eq 0 ] && [ "$FILE_MODE" = "staged" ]; then
while IFS= read -r script; do
if [ ! -f "$script" ]; then
continue
fi

# Match normal .sh files and executable scripts with shell shebangs.
if [[ "$script" == *.sh ]] || head -n 1 "$script" | grep -qE '^#!.*[^[:alnum:]_](bash|dash|ksh|zsh|sh)([[:space:]]|$)'; then
FILES+=("$script")
fi
done < <(git diff --cached --name-only --diff-filter=ACM)

if [ ${#FILES[@]} -eq 0 ]; then
echo "✅ No staged shell scripts to check"
exit 0
fi
fi

# Check if shellcheck is installed
if ! command -v shellcheck &> /dev/null; then
echo "❌ shellcheck command not found"
Expand All @@ -128,8 +97,8 @@ if [ "$MODE" = "fix" ]; then
echo ""

FAILED=0
# Use staged or explicitly provided files when present; otherwise keep the
# historical full-repository behavior for CI/manual all-file checks.
# Use file arguments from pre-commit or the caller when present; otherwise
# keep the historical full-repository behavior for CI/manual checks.
if [ ${#FILES[@]} -gt 0 ]; then
for script in "${FILES[@]}"; do
[ -f "$script" ] || continue
Expand Down Expand Up @@ -159,8 +128,8 @@ if [ "$MODE" = "fix" ]; then
else
echo "🔍 Checking shell scripts..."

# Use staged or explicitly provided files when present; otherwise keep the
# historical full-repository behavior for CI/manual all-file checks.
# Use file arguments from pre-commit or the caller when present; otherwise
# keep the historical full-repository behavior for CI/manual checks.
if [ ${#FILES[@]} -gt 0 ]; then
if shellcheck -x "${FILES[@]}"; then
echo "✅ All shell scripts passed shellcheck"
Expand Down
30 changes: 6 additions & 24 deletions scripts/ci/taplo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ set -euo pipefail

# Default values
MODE="check"
FILE_MODE="staged"
FILE_MODE="all"
FILES=()

# Parse arguments
Expand All @@ -34,29 +34,20 @@ while [[ $# -gt 0 ]]; do
MODE="fix"
shift
;;
--staged)
FILE_MODE="staged"
shift
;;
--ci)
FILE_MODE="ci"
shift
;;
--all)
FILE_MODE="all"
shift
;;
--help|-h)
echo "Usage: $0 [--check|--fix] [--staged|--ci|--all] [files...]"
echo "Usage: $0 [--check|--fix] [--ci] [files...]"
echo ""
echo "Modes:"
echo " --check Check TOML formatting (default)"
echo " --fix Format TOML files"
echo ""
echo "File selection:"
echo " --staged Check staged files (default, for git hooks)"
echo " [none] Check all tracked TOML files (default)"
echo " --ci Check files changed in PR (for CI)"
echo " --all Check all TOML files"
echo " [files] Check specific files"
exit 0
;;
Expand Down Expand Up @@ -87,10 +78,6 @@ fi
# Get files to check based on mode
get_files() {
case "$FILE_MODE" in
staged)
# Get staged TOML files for git hooks
git diff --cached --name-only --diff-filter=ACM -- '*.toml'
;;
ci)
# Get TOML files changed in PR for CI
if [ -n "${GITHUB_BASE_REF:-}" ]; then
Expand All @@ -101,18 +88,13 @@ get_files() {
# Generic CI - compare with HEAD~1
git diff --name-only --diff-filter=ACM HEAD~1 -- '*.toml'
else
# Fallback to staged files
git diff --cached --name-only --diff-filter=ACM -- '*.toml'
# Local fallback: check all tracked TOML files
git ls-files -- '*.toml'
fi
;;
all)
# Get all TOML files (excluding common build directories)
find . -name '*.toml' \
-not -path './target/*' \
-not -path './node_modules/*' \
-not -path './.git/*' \
-not -path './venv/*' \
-type f
git ls-files -- '*.toml'
;;
esac
}
Expand Down
23 changes: 5 additions & 18 deletions scripts/ci/trailing-newline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ set -euo pipefail

# Default values
MODE="check"
FILE_MODE="staged"
FILE_MODE="all"
FILES=()

# Parse arguments
Expand All @@ -34,29 +34,20 @@ while [[ $# -gt 0 ]]; do
MODE="fix"
shift
;;
--staged)
FILE_MODE="staged"
shift
;;
--ci)
FILE_MODE="ci"
shift
;;
--all)
FILE_MODE="all"
shift
;;
--help|-h)
echo "Usage: $0 [--check|--fix] [--staged|--ci|--all] [files...]"
echo "Usage: $0 [--check|--fix] [--ci] [files...]"
echo ""
echo "Modes:"
echo " --check Check for missing trailing newlines (default)"
echo " --fix Add trailing newlines to files"
echo ""
echo "File selection:"
echo " --staged Check staged files (default, for git hooks)"
echo " [none] Check all tracked files (default)"
echo " --ci Check files changed in PR (for CI)"
echo " --all Check all tracked files"
echo " [files] Check specific files"
exit 0
;;
Expand All @@ -76,10 +67,6 @@ done
# Get files to check based on mode
get_files() {
case "$FILE_MODE" in
staged)
# Get staged files for git hooks
git diff --cached --name-only --diff-filter=ACM
;;
ci)
# Get files changed in PR for CI
if [ -n "${GITHUB_BASE_REF:-}" ]; then
Expand All @@ -90,8 +77,8 @@ get_files() {
# Generic CI - compare with HEAD~1
git diff --name-only --diff-filter=ACM HEAD~1
else
# Fallback to staged files
git diff --cached --name-only --diff-filter=ACM
# Local fallback: check all tracked files
git ls-files
fi
;;
all)
Expand Down
Loading
Loading