Skip to content

Instantly share code, notes, and snippets.

@rozd
Last active January 18, 2021 14:28
Show Gist options
  • Save rozd/bd0c1c1ef048649ffd36838ea9dff3a4 to your computer and use it in GitHub Desktop.
Save rozd/bd0c1c1ef048649ffd36838ea9dff3a4 to your computer and use it in GitHub Desktop.
pre-push for Swift projects
#!/bin/sh
# Prevent commits containing Tailor errors or warnings to be pushed to remote
remote="$1"
url="$2"
RED='\033[0;31m' # Red Color
NC='\033[0m' # No Color
tailor --max-severity error
tailor_exit_code=$?;
if [ $tailor_exit_code != 0 ]
then
echo >&2 "${RED}Tailor found some issues in your changes, please fix them before push.${NC}"
exit $tailor_exit_code;
fi
# Prevent commits didn't pass tests to be pushed to remote
xcodebuild -workspace ${PROJECT}.xcworkspace -scheme ${SCHEME} -config ${CONFIG} test -destination 'platform=iOS Simulator,name=iPhone 8 Plus,OS=12.0'
xcodebuild_exit_code=$?;
if [ $xcodebuild_exit_code != 0 ]
then
echo >&2 "${RED}Some tests didn't pass.${NC}"
exit $xcodebuild_exit_code;
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment