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
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ Prevents accidental usage of local Swift package dependencies.

#### Behavior

* Scans git-tracked `Package.swift` files only (ignores untracked files)
* Scans tracked and untracked `Package.swift` files (excluding ignored files)
* Detects `.package(path:)`
* Fails immediately on detection

Expand Down Expand Up @@ -345,7 +345,7 @@ Ensures Swift source files contain a consistent, standardized header.

* Enforces a strict 5-line header format
* Can optionally insert or update headers in-place
* Processes only git-tracked Swift files
* Processes tracked and untracked Swift files (excluding ignored files)
* Skips `Package.swift` explicitly
* Accepts `Created by ... on YYYY. MM. DD.` and legacy `..` suffix
* In `--fix` mode, normalizes legacy `..` to `.`
Expand Down Expand Up @@ -640,6 +640,7 @@ Runs `swift-format` to lint or format Swift source files.

#### Behavior

* Scans tracked and untracked Swift files (`--exclude-standard`), not only tracked files
* Downloads default configuration if missing
* Respects ignore rules
* Supports parallel execution
Expand Down Expand Up @@ -677,6 +678,7 @@ Runs `actionlint` to validate GitHub Actions workflows.
#### Behavior

* Verifies `actionlint` is installed before running
* Emits a clear upgrade hint when local `actionlint` does not recognize newer runner labels
* Runs from repository root for consistent workflow path resolution
* Passes through optional CLI arguments to `actionlint`

Expand All @@ -700,12 +702,12 @@ curl -s $(baseUrl)/run-actionlint.sh | bash

#### Purpose

Runs `shfmt` to check or fix formatting for tracked shell-related files.
Runs `shfmt` to check or fix formatting for shell-related files.

#### Behavior

* Verifies `shfmt` is installed before running
* Targets tracked `*.sh`, `*.bash`, and `*.bats` files
* Targets tracked and untracked `*.sh`, `*.bash`, and `*.bats` files (excluding ignored files)
* Default mode checks formatting and fails on drift
* `--fix` mode applies formatting in-place

Expand Down
10 changes: 5 additions & 5 deletions scripts/check-local-swift-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# - CI: fail fast if local dependencies are detected
# - Local: allow developers to verify their Package.swift before pushing
#
# The script checks ONLY tracked files to avoid false positives from
# uncommitted or generated files.
# The script checks tracked and untracked files, excluding files ignored
# by standard git ignore rules.

set -euo pipefail

Expand All @@ -37,13 +37,13 @@ REPO_ROOT="$(git -C "$PWD" rev-parse --show-toplevel)"
# Collect files to check
#
# We intentionally use `git ls-files` to:
# - Inspect only tracked files
# - Avoid scanning generated or uncommitted files
# - Inspect tracked and untracked files
# - Exclude ignored/generated files via `--exclude-standard`
#
# Currently, we only check Package.swift, since local package references
# are only valid in that file.
read -ra PATHS_TO_CHECK <<<"$(
git -C "${REPO_ROOT}" ls-files -z \
git -C "${REPO_ROOT}" ls-files -z --cached --others --exclude-standard \
"Package.swift" |
xargs -0
)"
Expand Down
2 changes: 1 addition & 1 deletion scripts/check-swift-headers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ fi
FILES=()
while IFS= read -r -d '' file; do
FILES+=("$file")
done < <(git ls-files -z "${EXCLUDE_PATTERNS[@]}")
done < <(git ls-files -z --cached --others --exclude-standard "${EXCLUDE_PATTERNS[@]}")

for file in "${FILES[@]}"; do
if ! check_or_fix_header "$file"; then
Expand Down
21 changes: 17 additions & 4 deletions scripts/run-actionlint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,26 @@ fatal() {
exit 1
}

REPO_ROOT="$(git -C "$PWD" rev-parse --show-toplevel 2>/dev/null || pwd)"
cd "$REPO_ROOT"

log "Running actionlint..."

if ! command -v actionlint >/dev/null 2>&1; then
fatal "actionlint is not installed. Install it first (e.g. 'brew install actionlint' or 'apt-get install actionlint')."
fi

REPO_ROOT="$(git -C "$PWD" rev-parse --show-toplevel 2>/dev/null || pwd)"
cd "$REPO_ROOT"
set +e
LOCAL_OUTPUT="$(actionlint "$@" 2>&1)"
LOCAL_RC=$?
set -e

if [ "$LOCAL_RC" -ne 0 ] && printf '%s' "$LOCAL_OUTPUT" | grep -q 'label ".*" is unknown'; then
error "Your installed actionlint is likely outdated and does not recognize newer runner labels."
error "Please upgrade actionlint and run this script again."
fi

[ -n "$LOCAL_OUTPUT" ] && printf '%s\n' "$LOCAL_OUTPUT"
[ "$LOCAL_RC" -ne 0 ] && exit "$LOCAL_RC"

log "Running actionlint..."
actionlint "$@"
log "✅ actionlint found no issues."
4 changes: 2 additions & 2 deletions scripts/run-swift-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ fi

# Run swift-format
#
# - Uses git to list all tracked Swift files
# - Uses git to list tracked and untracked Swift files
# - Applies exclusions defined in .swiftformatignore
# - Runs formatting in parallel for performance
#
# The exit code is captured explicitly to allow controlled error handling.
tr '\n' '\0' <.swiftformatignore |
xargs -0 -I% printf '":(exclude)%" ' |
xargs git ls-files -z '*.swift' |
xargs git ls-files -z --cached --others --exclude-standard '*.swift' |
xargs -0 swift format "${FORMAT_COMMAND[@]}" --parallel &&
SWIFT_FORMAT_RC=$? || SWIFT_FORMAT_RC=$?

Expand Down
2 changes: 1 addition & 1 deletion scripts/script-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fi
FILES=()
while IFS= read -r -d '' file; do
FILES+=("$file")
done < <(git ls-files -z '*.sh' '*.bash' '*.bats')
done < <(git ls-files -z --cached --others --exclude-standard '*.sh' '*.bash' '*.bats')

if [ "${#FILES[@]}" -eq 0 ]; then
log "No shell files found to format."
Expand Down
6 changes: 3 additions & 3 deletions tests/bats/check-local-swift-dependencies.bats
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ SWIFT
[[ "$output" == *"contains local Swift package reference"* ]]
}

@test "check-local-swift-dependencies ignores untracked Package.swift" {
@test "check-local-swift-dependencies checks untracked Package.swift" {
repo="$(make_temp_repo)"
copy_script_into_repo "$repo" "check-local-swift-dependencies.sh"

Expand All @@ -74,8 +74,8 @@ TXT

run bash -c "cd '$repo' && bash scripts/check-local-swift-dependencies.sh"

[ "$status" -eq 0 ]
[[ "$output" == *"Found 0 local Swift package dependency references"* ]]
[ "$status" -eq 1 ]
[[ "$output" == *"contains local Swift package reference"* ]]
}

@test "check-local-swift-dependencies passes when no Package.swift is tracked" {
Expand Down
5 changes: 3 additions & 2 deletions tests/bats/check-swift-headers.bats
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,13 @@ EOF2
run run_checker --fix
[ "$status" -eq 0 ]

cp "$TMPDIR/Address.swift" "$TMPDIR/once.swift"
before_content="$(cat "$TMPDIR/Address.swift")"

run run_checker --fix
[ "$status" -eq 0 ]

diff -u "$TMPDIR/once.swift" "$TMPDIR/Address.swift"
after_content="$(cat "$TMPDIR/Address.swift")"
[ "$before_content" = "$after_content" ]
}

@test "--author without value fails with clear error" {
Expand Down