Skip to content
Open
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
21 changes: 4 additions & 17 deletions scripts/ci/binary-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,38 +30,28 @@ 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"
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 " --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 +69,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
26 changes: 1 addition & 25 deletions scripts/ci/markdownlint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
set -euo pipefail

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

# Accept mode flags plus optional file paths. In pre-commit, matching staged
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
33 changes: 1 addition & 32 deletions scripts/ci/shellcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
set -euo pipefail

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

# Accept mode flags plus optional file paths. In pre-commit, matching staged
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 Down
29 changes: 5 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,19 @@ 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 " --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 +77,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 +87,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
22 changes: 4 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,19 @@ 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 " --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 +66,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 +76,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
22 changes: 4 additions & 18 deletions scripts/ci/trailing-whitespace.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,19 @@ 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 trailing whitespace (default)"
echo " --fix Remove trailing whitespace"
echo ""
echo "File selection:"
echo " --staged Check staged files (default, for git hooks)"
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 +66,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 +76,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