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
13 changes: 10 additions & 3 deletions scripts/run-swift-format.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,17 @@ fatal() { error "$@"; exit 1; }
CURRENT_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
REPO_ROOT="$(git -C "${CURRENT_SCRIPT_DIR}" rev-parse --show-toplevel)"

FORMAT_COMMAND=(lint --strict)
for arg in "$@"; do
if [ "$arg" == "--fix" ]; then
FORMAT_COMMAND=(format --in-place)
fi
done

SWIFTFORMAT_BIN=${SWIFTFORMAT_BIN:-$(command -v swift-format)} || fatal "❌ SWIFTFORMAT_BIN unset and no swift-format on PATH"

"${SWIFTFORMAT_BIN}" lint \
--parallel --recursive --strict \
"${SWIFTFORMAT_BIN}" "${FORMAT_COMMAND[@]}" \
--parallel --recursive \
"${REPO_ROOT}/Sources" "${REPO_ROOT}/Tests" \
&& SWIFT_FORMAT_RC=$? || SWIFT_FORMAT_RC=$?

Expand All @@ -33,7 +40,7 @@ if [ "${SWIFT_FORMAT_RC}" -ne 0 ]; then

To fix, run the following command:

% swift-format format --parallel --recursive --in-place Sources Tests
% ./scripts/run-swift-format.sh --fix
"
exit "${SWIFT_FORMAT_RC}"
fi
Expand Down
15 changes: 14 additions & 1 deletion scripts/soundness.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,17 @@ fatal() { error "$@"; exit 1; }
CURRENT_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
NUM_CHECKS_FAILED=0

FIX_FORMAT=""
for arg in "$@"; do
if [ "$arg" == "--fix" ]; then
FIX_FORMAT="--fix"
fi
done

SCRIPT_PATHS=(
"${CURRENT_SCRIPT_DIR}/check-for-broken-symlinks.sh"
"${CURRENT_SCRIPT_DIR}/check-for-unacceptable-language.sh"
"${CURRENT_SCRIPT_DIR}/check-license-headers.sh"
"${CURRENT_SCRIPT_DIR}/run-swift-format.sh"
)

for SCRIPT_PATH in "${SCRIPT_PATHS[@]}"; do
Expand All @@ -35,6 +41,13 @@ for SCRIPT_PATH in "${SCRIPT_PATHS[@]}"; do
fi
done

log "Running swift-format..."
bash "${CURRENT_SCRIPT_DIR}"/run-swift-format.sh $FIX_FORMAT > /dev/null
FORMAT_EXIT_CODE=$?
if [ $FORMAT_EXIT_CODE -ne 0 ]; then
((NUM_CHECKS_FAILED+=1))
fi

if [ "${NUM_CHECKS_FAILED}" -gt 0 ]; then
fatal "❌ ${NUM_CHECKS_FAILED} soundness check(s) failed."
fi
Expand Down