Skip to content
Browse files

pre-commit hook

  • Loading branch information...
1 parent f34bd3e commit fd5500eaaaba2d5d07dae66b4f32191480e8c662 @drewcrawford committed Feb 20, 2013
View
1 .gitignore
@@ -1,4 +1,3 @@
.DS_Store
-*.xcworkspace
*xcuserdata
build/*
View
6 CoreDataHelp.xcodeproj/project.pbxproj
@@ -516,7 +516,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n";
+ shellScript = "set -e\nif [ \"$RUN_UNIT_TEST_WITH_IOS_SIM\" = \"YES\" ]; then\ntest_bundle_path=\"$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.$WRAPPER_EXTENSION\"\nSOURCE_DIRECTORY=$SRCROOT\necho sim --sdk=6.1 $SDKROOT/Developer/usr/bin/otest -NSTreatUnknownArgumentsAsOpen NO -ApplePersistenceIgnoreState YES -SenTest Self $CODESIGNING_FOLDER_PATH\nsim --sdk=6.1 $SDKROOT/Developer/usr/bin/otest -NSTreatUnknownArgumentsAsOpen NO -ApplePersistenceIgnoreState YES -SenTest Self $CODESIGNING_FOLDER_PATH\nelse\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\nfi";
};
/* End PBXShellScriptBuildPhase section */
@@ -655,6 +655,7 @@
INFOPLIST_FILE = "CoreDataHelpTests/CoreDataHelpTests-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
+ TEST_HOST = "$(BUNDLE_LOADER)";
WRAPPER_EXTENSION = octest;
};
name = UnitTest;
@@ -758,6 +759,7 @@
INFOPLIST_FILE = "CoreDataHelpTests/CoreDataHelpTests-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
+ TEST_HOST = "$(BUNDLE_LOADER)";
WRAPPER_EXTENSION = octest;
};
name = "Daily Build";
@@ -877,6 +879,7 @@
INFOPLIST_FILE = "CoreDataHelpTests/CoreDataHelpTests-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
+ TEST_HOST = "$(BUNDLE_LOADER)";
WRAPPER_EXTENSION = octest;
};
name = Debug;
@@ -896,6 +899,7 @@
INFOPLIST_FILE = "CoreDataHelpTests/CoreDataHelpTests-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
+ TEST_HOST = "$(BUNDLE_LOADER)";
WRAPPER_EXTENSION = octest;
};
name = Release;
View
7 CoreDataHelp.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Workspace
+ version = "1.0">
+ <FileRef
+ location = "self:CoreDataHelp.xcodeproj">
+ </FileRef>
+</Workspace>
View
59 CoreDataHelp.xcodeproj/xcshareddata/xcschemes/CoreDataHelp.xcscheme
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+ LastUpgradeVersion = "0460"
+ version = "1.3">
+ <BuildAction
+ parallelizeBuildables = "YES"
+ buildImplicitDependencies = "YES">
+ <BuildActionEntries>
+ <BuildActionEntry
+ buildForTesting = "YES"
+ buildForRunning = "YES"
+ buildForProfiling = "YES"
+ buildForArchiving = "YES"
+ buildForAnalyzing = "YES">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "3A34EC1714DC975000C7CAC6"
+ BuildableName = "libCoreDataHelp.a"
+ BlueprintName = "CoreDataHelp"
+ ReferencedContainer = "container:CoreDataHelp.xcodeproj">
+ </BuildableReference>
+ </BuildActionEntry>
+ </BuildActionEntries>
+ </BuildAction>
+ <TestAction
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ buildConfiguration = "Debug">
+ <Testables>
+ </Testables>
+ </TestAction>
+ <LaunchAction
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ launchStyle = "0"
+ useCustomWorkingDirectory = "NO"
+ buildConfiguration = "Debug"
+ ignoresPersistentStateOnLaunch = "NO"
+ debugDocumentVersioning = "YES"
+ allowLocationSimulation = "YES">
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </LaunchAction>
+ <ProfileAction
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ savedToolIdentifier = ""
+ useCustomWorkingDirectory = "NO"
+ buildConfiguration = "Release"
+ debugDocumentVersioning = "YES">
+ </ProfileAction>
+ <AnalyzeAction
+ buildConfiguration = "Debug">
+ </AnalyzeAction>
+ <ArchiveAction
+ buildConfiguration = "Release"
+ revealArchiveInOrganizer = "YES">
+ </ArchiveAction>
+</Scheme>
View
69 CoreDataHelp.xcodeproj/xcshareddata/xcschemes/CoreDataHelpTests.xcscheme
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+ LastUpgradeVersion = "0460"
+ version = "1.3">
+ <BuildAction
+ parallelizeBuildables = "YES"
+ buildImplicitDependencies = "YES">
+ <BuildActionEntries>
+ <BuildActionEntry
+ buildForTesting = "YES"
+ buildForRunning = "YES"
+ buildForProfiling = "NO"
+ buildForArchiving = "NO"
+ buildForAnalyzing = "NO">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "3A34EC2714DC975000C7CAC6"
+ BuildableName = "CoreDataHelpTests.octest"
+ BlueprintName = "CoreDataHelpTests"
+ ReferencedContainer = "container:CoreDataHelp.xcodeproj">
+ </BuildableReference>
+ </BuildActionEntry>
+ </BuildActionEntries>
+ </BuildAction>
+ <TestAction
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ buildConfiguration = "Debug">
+ <Testables>
+ <TestableReference
+ skipped = "NO">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "3A34EC2714DC975000C7CAC6"
+ BuildableName = "CoreDataHelpTests.octest"
+ BlueprintName = "CoreDataHelpTests"
+ ReferencedContainer = "container:CoreDataHelp.xcodeproj">
+ </BuildableReference>
+ </TestableReference>
+ </Testables>
+ </TestAction>
+ <LaunchAction
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ launchStyle = "0"
+ useCustomWorkingDirectory = "NO"
+ buildConfiguration = "Debug"
+ ignoresPersistentStateOnLaunch = "NO"
+ debugDocumentVersioning = "YES"
+ allowLocationSimulation = "YES">
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </LaunchAction>
+ <ProfileAction
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ savedToolIdentifier = ""
+ useCustomWorkingDirectory = "NO"
+ buildConfiguration = "Release"
+ debugDocumentVersioning = "YES">
+ </ProfileAction>
+ <AnalyzeAction
+ buildConfiguration = "Debug">
+ </AnalyzeAction>
+ <ArchiveAction
+ buildConfiguration = "Release"
+ revealArchiveInOrganizer = "YES">
+ </ArchiveAction>
+</Scheme>
View
BIN develop-environment/appledoc
Binary file not shown.
View
BIN develop-environment/ios-sim
Binary file not shown.
View
52 develop-environment/terminal-notifier.app/Contents/Info.plist
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>BuildMachineOSBuild</key>
+ <string>12A269</string>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>en</string>
+ <key>CFBundleExecutable</key>
+ <string>terminal-notifier</string>
+ <key>CFBundleIconFile</key>
+ <string>Terminal</string>
+ <key>CFBundleIdentifier</key>
+ <string>nl.superalloy.oss.terminal-notifier</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>terminal-notifier</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.4.2</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>7</string>
+ <key>DTCompiler</key>
+ <string></string>
+ <key>DTPlatformBuild</key>
+ <string>4F243</string>
+ <key>DTPlatformVersion</key>
+ <string>GM</string>
+ <key>DTSDKBuild</key>
+ <string>12A264</string>
+ <key>DTSDKName</key>
+ <string>macosx10.8</string>
+ <key>DTXcode</key>
+ <string>0440</string>
+ <key>DTXcodeBuild</key>
+ <string>4F243</string>
+ <key>LSMinimumSystemVersion</key>
+ <string>10.8</string>
+ <key>LSUIElement</key>
+ <true/>
+ <key>NSHumanReadableCopyright</key>
+ <string>Copyright © 2012 Eloy Durán. All rights reserved.</string>
+ <key>NSMainNibFile</key>
+ <string>MainMenu</string>
+ <key>NSPrincipalClass</key>
+ <string>NSApplication</string>
+</dict>
+</plist>
View
BIN develop-environment/terminal-notifier.app/Contents/MacOS/terminal-notifier
Binary file not shown.
View
1 develop-environment/terminal-notifier.app/Contents/PkgInfo
@@ -0,0 +1 @@
+APPL????
View
BIN develop-environment/terminal-notifier.app/Contents/Resources/Terminal.icns
Binary file not shown.
View
29 develop-environment/terminal-notifier.app/Contents/Resources/en.lproj/Credits.rtf
@@ -0,0 +1,29 @@
+{\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;}
+{\colortbl;\red255\green255\blue255;}
+\paperw9840\paperh8400
+\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
+
+\f0\b\fs24 \cf0 Engineering:
+\b0 \
+ Some people\
+\
+
+\b Human Interface Design:
+\b0 \
+ Some other people\
+\
+
+\b Testing:
+\b0 \
+ Hopefully not nobody\
+\
+
+\b Documentation:
+\b0 \
+ Whoever\
+\
+
+\b With special thanks to:
+\b0 \
+ Mom\
+}
View
BIN develop-environment/terminal-notifier.app/Contents/Resources/en.lproj/InfoPlist.strings
Binary file not shown.
View
BIN develop-environment/terminal-notifier.app/Contents/Resources/en.lproj/MainMenu.nib
Binary file not shown.
View
61 develop-environment/terminal-notifier.app/Contents/_CodeSignature/CodeResources
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>files</key>
+ <dict>
+ <key>Resources/Terminal.icns</key>
+ <data>
+ Oq9GtJM1DqcGF1JCHiEgb0hoN6I=
+ </data>
+ <key>Resources/en.lproj/Credits.rtf</key>
+ <dict>
+ <key>hash</key>
+ <data>
+ YKJIFIsxneJuNkJNJQIcJIjiPOg=
+ </data>
+ <key>optional</key>
+ <true/>
+ </dict>
+ <key>Resources/en.lproj/InfoPlist.strings</key>
+ <dict>
+ <key>hash</key>
+ <data>
+ MiLKDDnrUKr4EmuvhS5VQwxHGK8=
+ </data>
+ <key>optional</key>
+ <true/>
+ </dict>
+ <key>Resources/en.lproj/MainMenu.nib</key>
+ <dict>
+ <key>hash</key>
+ <data>
+ N1QqAM17vgDk7XNtv27koaE4IhE=
+ </data>
+ <key>optional</key>
+ <true/>
+ </dict>
+ </dict>
+ <key>rules</key>
+ <dict>
+ <key>^Resources/</key>
+ <true/>
+ <key>^Resources/.*\.lproj/</key>
+ <dict>
+ <key>optional</key>
+ <true/>
+ <key>weight</key>
+ <real>1000</real>
+ </dict>
+ <key>^Resources/.*\.lproj/locversion.plist$</key>
+ <dict>
+ <key>omit</key>
+ <true/>
+ <key>weight</key>
+ <real>1100</real>
+ </dict>
+ <key>^version.plist$</key>
+ <true/>
+ </dict>
+</dict>
+</plist>
View
120 pre-commit.py
@@ -0,0 +1,120 @@
+#!/usr/bin/python
+# coding=utf8
+
+# Install with
+# ln -sf ../../pre-commit.py .git/hooks/pre-commit
+
+
+PROJECT_NAME = "CoreDataHelp"
+WORKSPACE_NAME = "CoreDataHelp.xcodeproj/project.xcworkspace"
+TEST_SCHEME = "CoreDataHelpTests"
+BUILD_SCHEME = "CoreDataHelp"
+TEST_SUITE_NAME = "CoreDataHelpTests"
+
+
+def getSO(cmd):
+ import subprocess
+ proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
+ output,stderr = proc.communicate()
+ proc.wait() # this might hang with a LOT of output
+ return (proc.returncode, output)
+
+
+def getO(cmd):
+ import subprocess
+ return subprocess.check_output(cmd, shell=True)
+
+
+def fail(subtitle, detail=""):
+ getO("""develop-environment/terminal-notifier.app/Contents/MacOS/terminal-notifier -group "{PROJECT_NAME}" -title "⛔ {PROJECT_NAME} commit failed " -subtitle "{SUBTITLE}" -message "{MESSAGE}" -activate "com.apple.Terminal" """.format(PROJECT_NAME=PROJECT_NAME, SUBTITLE=subtitle, MESSAGE=detail))
+ print subtitle
+ print detail
+
+ raise Exception("See previous errors")
+
+
+def success():
+ getO("""develop-environment/terminal-notifier.app/Contents/MacOS/terminal-notifier -group "{PROJECT_NAME}" -title "Commit succeeded {PROJECT_NAME}" -subtitle "{SUBTITLE}" -message "{MESSAGE}" -activate "com.apple.Terminal" """.format(PROJECT_NAME=PROJECT_NAME, SUBTITLE="", MESSAGE="😃"))
+
+#remove any old notification
+getO("""develop-environment/terminal-notifier.app/Contents/MacOS/terminal-notifier -remove "{PROJECT_NAME}" """.format(PROJECT_NAME=PROJECT_NAME))
+try:
+
+ print "Forgetting to check in files check..."
+ requireArray = [".m",".h"]
+ for ext in requireArray:
+ (s, o) = getSO("""git status --porcelain | grep "??.*$""" + ext + '"')
+ if s != 1:
+ print "You have untracked files with extension", ext
+ print "Commit these files, or add them to .gitgnore:"
+ print o.replace("?? ", "")
+ fail(subtitle="Untracked files", detail=o.replace("?? ", ""))
+
+
+ print "build/analyze/warning check"
+ (code,output) = getSO("xcodebuild -configuration Release -sdk iphonesimulator -workspace {WORKSPACE_NAME} -IDEBuildOperationMaxNumberOfConcurrentCompile=1 -scheme {SCHEME_NAME} RUN_CLANG_STATIC_ANALYZER=YES clean build ".format(SCHEME_NAME=BUILD_SCHEME,WORKSPACE_NAME=WORKSPACE_NAME))
+
+
+
+ if code != 0:
+ print output
+ fail("Build failed","Return code %d" % code)
+
+ import re
+
+ if not re.search("\*\* BUILD SUCCEEDED \*\*",output):
+ print output
+ fail("Build did not succeed","Can't find text ** BUILD SUCCEEDED ** in output. Can you?")
+
+
+ warnings = re.findall(r".*:\d+:\d+: warning.*(?=\n)",output)
+ if len(warnings) != 0:
+ print output
+ print "\n".join(warnings)
+ fail("You have warnings",warnings[0])
+
+ print "unit test check"
+ #run the unit tests
+ (code,output) = getSO("xcodebuild -sdk iphonesimulator -configuration UnitTest -workspace {WORKSPACE_NAME} -scheme {SCHEME_NAME} RUN_UNIT_TEST_WITH_IOS_SIM=YES clean build".format(SCHEME_NAME=TEST_SCHEME,WORKSPACE_NAME=WORKSPACE_NAME))
+
+ if code != 0:
+ print output
+ fail("Build failed","Return code %d" % code)
+
+
+ if not re.search("\*\* BUILD SUCCEEDED \*\*",output):
+ print output
+ fail("Build did not succeed","Can't find text ** BUILD SUCCEEDED ** in output. Can you?")
+
+
+ regex1 = r"Test Suite '"+TEST_SUITE_NAME + r"' finished at .*\nExecuted .* with (.*) failures"
+ spolsky_msg = re.search(regex1,output)
+ if not spolsky_msg:
+ print output
+ fail("Can't find the end of the app test in your build output","It looks like %s" % regex1)
+
+
+
+ if not spolsky_msg.groups()[0]=="0":
+ print output
+ fail("%s failed %s unit tests" % (PROJECT_NAME,spolsky_msg.groups()[0]))
+
+
+
+ success()
+
+finally:
+ try:
+ pass
+ #getO("""git stash pop""")
+ except:
+ if not stashed:
+ pass
+ else:
+ fail("failed to pop")
+
+
+
+
+
+

0 comments on commit fd5500e

Please sign in to comment.
Something went wrong with that request. Please try again.