Skip SwiftLint and SwiftFormat runs on CI build
Unfortunately, there seems to be no simpler way to tell a script in Xcode that it runs on CI.
This commit is contained in:
parent
ea304f963c
commit
9b38cc0437
5 changed files with 62 additions and 8 deletions
24
scripts/swiftformat.sh
Executable file
24
scripts/swiftformat.sh
Executable file
|
|
@ -0,0 +1,24 @@
|
|||
SWIFTFORMAT_VERSION="0.45.*"
|
||||
|
||||
if [[ -f "${SRCROOT}/.ci-env" ]]; then
|
||||
echo "Running in a Continuous Integration environment. Formatting is skipped."
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ "${CONFIGURATION}" != "Debug" ]]; then
|
||||
echo "Running during a release build. Formatting is skipped."
|
||||
return
|
||||
fi
|
||||
|
||||
if which swiftformat > /dev/null; then
|
||||
if [[ "$(swiftformat --version)" == $SWIFTFORMAT_VERSION ]]; then
|
||||
swiftformat .
|
||||
else
|
||||
echo "Failure: SwiftFormat $SWIFTFORMAT_VERSION is required. Install it or update the build script to use a newer version."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Failure: SwiftFormat not installed. Get it via 'brew install swiftformat'."
|
||||
exit 2
|
||||
fi
|
||||
|
||||
24
scripts/swiftlint.sh
Executable file
24
scripts/swiftlint.sh
Executable file
|
|
@ -0,0 +1,24 @@
|
|||
SWIFTLINT_VERSION="0.40.*"
|
||||
|
||||
if [[ -f "${SRCROOT}/.ci-env" ]]; then
|
||||
echo "Running in a Continuous Integration environment. Linting is skipped."
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ "${CONFIGURATION}" != "Debug" ]]; then
|
||||
echo "Running during a release build. Linting is skipped."
|
||||
return
|
||||
fi
|
||||
|
||||
if which swiftlint > /dev/null; then
|
||||
if [[ "$(swiftlint version)" == $SWIFTLINT_VERSION ]]; then
|
||||
swiftlint --strict
|
||||
else
|
||||
echo "Failure: SwiftLint $SWIFTLINT_VERSION is required. Install it or update the build script to use a newer version."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Failure: SwiftLint not installed. Get it via 'brew install swiftlint'."
|
||||
exit 2
|
||||
fi
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue