Skip to content

Commit

Permalink
Update validate script/GH action
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-fowler committed Nov 23, 2024
1 parent bed16b1 commit f9dd857
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,5 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Install Dependencies
run: |
brew install mint
mint install NickLockwood/[email protected] --no-link
- name: run script
run: ./scripts/validate.sh
1 change: 1 addition & 0 deletions .swift-format
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"maximumBlankLines" : 1,
"respectsExistingLineBreaks" : true,
"prioritizeKeepingFunctionOutputTogether" : true,
"multiElementCollectionTrailingCommas" : true,
"rules" : {
"AllPublicDeclarationsHaveDocumentation" : false,
"AlwaysUseLiteralForEmptyCollectionInit" : false,
Expand Down
13 changes: 3 additions & 10 deletions scripts/validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,16 @@ SWIFT_FORMAT_VERSION=0.53.10
set -eu
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

which swiftformat > /dev/null 2>&1 || (echo "swiftformat not installed. You can install it using 'brew install swiftformat'" ; exit -1)

function replace_acceptable_years() {
# this needs to replace all acceptable forms with 'YEARS'
sed -e 's/20[12][0-9]-20[12][0-9]/YEARS/' -e 's/20[12][0-9]/YEARS/' -e '/^#!/ d'
}

printf "=> Checking format... "
FIRST_OUT="$(git status --porcelain)"
if [[ -n "${CI-""}" ]]; then
printf "(using v$(mint run NickLockwood/SwiftFormat@"$SWIFT_FORMAT_VERSION" --version)) "
mint run NickLockwood/SwiftFormat@"$SWIFT_FORMAT_VERSION" . > /dev/null 2>&1
else
printf "(using v$(swiftformat --version)) "
swiftformat . > /dev/null 2>&1
fi
git ls-files -z '*.swift' | xargs -0 swift format format --parallel --in-place
git diff --exit-code '*.swift'

SECOND_OUT="$(git status --porcelain)"
if [[ "$FIRST_OUT" != "$SECOND_OUT" ]]; then
printf "\033[0;31mformatting issues!\033[0m\n"
Expand All @@ -55,7 +49,6 @@ if [[ "$FIRST_OUT" != "$SECOND_OUT" ]]; then
else
printf "\033[0;32mokay.\033[0m\n"
fi
exit
printf "=> Checking license headers... "
tmp=$(mktemp /tmp/.soto-core-sanity_XXXXXX)

Expand Down

0 comments on commit f9dd857

Please sign in to comment.