Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7c6a9e7

Browse files
Add a soundness --fix flag (#22)
Add a soundness --fix flag ### Motivation When running `./scripts/soundness.sh` produces swift-format warnings, we ask adopters to manually copy/paste a call to swift format to fix the warnings up. This is tedious and unnecessary. ### Modifications Add a `--fix` option on the `soundness.sh` script to actually apply the fixes as well, avoiding the need to copy/paste long commands. ### Result Easier fixing up of formatting warnings. ### Test Plan Manually tested the workflow locally. Reviewed by: glbrntt Builds: ✔︎ pull request validation (5.10) - Build finished. ✔︎ pull request validation (5.8) - Build finished. ✔︎ pull request validation (5.9) - Build finished. ✔︎ pull request validation (nightly) - Build finished. ✔︎ pull request validation (soundness) - Build finished. #22
1 parent 2e72905 commit 7c6a9e7

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

‎scripts/run-swift-format.sh

100644100755
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,17 @@ fatal() { error "$@"; exit 1; }
2121
CURRENT_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
2222
REPO_ROOT="$(git -C "${CURRENT_SCRIPT_DIR}" rev-parse --show-toplevel)"
2323

24+
FORMAT_COMMAND=(lint --strict)
25+
for arg in "$@"; do
26+
if [ "$arg" == "--fix" ]; then
27+
FORMAT_COMMAND=(format --in-place)
28+
fi
29+
done
30+
2431
SWIFTFORMAT_BIN=${SWIFTFORMAT_BIN:-$(command -v swift-format)} || fatal "❌ SWIFTFORMAT_BIN unset and no swift-format on PATH"
2532

26-
"${SWIFTFORMAT_BIN}" lint \
27-
--parallel --recursive --strict \
33+
"${SWIFTFORMAT_BIN}" "${FORMAT_COMMAND[@]}" \
34+
--parallel --recursive \
2835
"${REPO_ROOT}/Sources" "${REPO_ROOT}/Tests" \
2936
&& SWIFT_FORMAT_RC=$? || SWIFT_FORMAT_RC=$?
3037

@@ -33,7 +40,7 @@ if [ "${SWIFT_FORMAT_RC}" -ne 0 ]; then
3340
3441
To fix, run the following command:
3542
36-
% swift-format format --parallel --recursive --in-place Sources Tests
43+
% ./scripts/run-swift-format.sh --fix
3744
"
3845
exit "${SWIFT_FORMAT_RC}"
3946
fi

‎scripts/soundness.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,17 @@ CURRENT_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
2222
NUM_CHECKS_FAILED=0
2323
export DOCC_TARGET=OpenAPIAsyncHTTPClient
2424

25+
FIX_FORMAT=""
26+
for arg in "$@"; do
27+
if [ "$arg" == "--fix" ]; then
28+
FIX_FORMAT="--fix"
29+
fi
30+
done
31+
2532
SCRIPT_PATHS=(
2633
"${CURRENT_SCRIPT_DIR}/check-for-broken-symlinks.sh"
2734
"${CURRENT_SCRIPT_DIR}/check-for-unacceptable-language.sh"
2835
"${CURRENT_SCRIPT_DIR}/check-license-headers.sh"
29-
"${CURRENT_SCRIPT_DIR}/run-swift-format.sh"
3036
"${CURRENT_SCRIPT_DIR}/check-for-docc-warnings.sh"
3137
)
3238

@@ -37,6 +43,13 @@ for SCRIPT_PATH in "${SCRIPT_PATHS[@]}"; do
3743
fi
3844
done
3945

46+
log "Running swift-format..."
47+
bash "${CURRENT_SCRIPT_DIR}"/run-swift-format.sh $FIX_FORMAT > /dev/null
48+
FORMAT_EXIT_CODE=$?
49+
if [ $FORMAT_EXIT_CODE -ne 0 ]; then
50+
((NUM_CHECKS_FAILED+=1))
51+
fi
52+
4053
if [ "${NUM_CHECKS_FAILED}" -gt 0 ]; then
4154
fatal "${NUM_CHECKS_FAILED} soundness check(s) failed."
4255
fi

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /