diff --git a/Jakefile b/Jakefile index 4687216af..36a6da3eb 100644 --- a/Jakefile +++ b/Jakefile @@ -188,47 +188,68 @@ task("test-only", function() OS.exit(code); }); -task("push-packages", ["CommonJS", "push-cappuccino", "push-objective-j"]); +task("push-packages", ["push-cappuccino", "push-objective-j"]); task("push-cappuccino", function() { pushPackage( $BUILD_CJS_CAPPUCCINO, - "git@github.com:280north/cappuccino-package.git" + "git@github.com:280north/cappuccino-package.git", + SYSTEM.env["PACKAGE_BRANCH"] ); }); task("push-objective-j", function() { pushPackage( $BUILD_CJS_OBJECTIVE_J, - "git@github.com:280north/objective-j-package.git" + "git@github.com:280north/objective-j-package.git", + SYSTEM.env["PACKAGE_BRANCH"] ); }); -function pushPackage(path, remote) +function pushPackage(path, remote, branch) { - stream.print("Pushing \0blue(" + path + "\0) to \0blue(" + remote + "\0)"); + branch = branch || "master"; + + stream.print("Pushing \0blue(" + path + "\0) to "+branch+" of \0blue(" + remote + "\0)"); FILE.mkdirs(".push-package"); var pushPackageDir = FILE.join(".push-package", remote.replace(/[^\w]/g, "_")); if (FILE.exists(pushPackageDir)) - OS.system(buildCommandString([["cd", pushPackageDir], ["git", "pull"]])); + OS.system(buildCmd([["cd", pushPackageDir], ["git", "fetch"]])); else OS.system(["git", "clone", remote, pushPackageDir]); - OS.system("cd "+OS.enquote(pushPackageDir)+" && git rm --ignore-unmatch -r * && rm -rf *"); - OS.system("cp -R "+OS.enquote(path)+"/* "+OS.enquote(pushPackageDir)+"/."); + if (OS.system(buildCmd([["cd", pushPackageDir], ["git", "checkout", "origin/"+branch]]))) { + if (OS.system(buildCmd([ + ["cd", pushPackageDir], + ["git", "symbolic-ref", "HEAD", "refs/heads/"+branch], + ["rm", ".git/index"], + ["git", "clean", "-fdx"] + ]))) + throw "pushPackage failed"; + } - OS.system(buildCommandString([ + if (OS.system("cd "+OS.enquote(pushPackageDir)+" && git rm --ignore-unmatch -r * && rm -rf *")) + throw "pushPackage failed"; + if (OS.system("cp -R "+OS.enquote(path)+"/* "+OS.enquote(pushPackageDir)+"/.")) + throw "pushPackage failed"; + + OS.system(buildCmd([ ["cd", pushPackageDir], ["git", "add", "."], - ["git", "commit", "-m", "Pushed on " + new Date()], - ["git", "push", "origin", "master"] + ["git", "commit", "-m", "Pushed on " + new Date()] ])); + + if (OS.system(buildCmd([ + ["cd", pushPackageDir], + ["git", "push", "origin", "HEAD:"+branch] + ]))) + throw "pushPackage failed"; } -function buildCommandString(arrayOfCommands) +function buildCmd(arrayOfCommands) { return arrayOfCommands.map(function(cmd) { return cmd.map(OS.enquote).join(" "); diff --git a/Tools/Scripts/ci.sh b/Tools/Scripts/ci.sh new file mode 100755 index 000000000..4bc798a70 --- /dev/null +++ b/Tools/Scripts/ci.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +project_home="$(dirname "$PWD")" + +export PATH="$HOME/narwhal/bin:$PATH" + +export CAPP_BUILD=$project_home/build_incremental +time jake test +code=$? +if [ $code -ne 0 ]; then + echo "INCREMENTAL BUILD FAILED ($code)" + exit $code +else + echo "INCREMENTAL BUILD SUCCEEDED" +fi + +export CAPP_BUILD=$project_home/build_clean +rm -rf $CAPP_BUILD + +time jake CommonJS test +code=$? +if [ $code -ne 0 ]; then + echo "CLEAN BUILD FAILED ($code)" + exit $code +else + echo "CLEAN BUILD SUCCEEDED" +fi + +PACKAGE_BRANCH="nightly" jake push-packages +code=$? +if [ $code -ne 0 ]; then + echo "NIGHTLY BUILD PUSH FAILED ($code)" + exit $code +else + echo "NIGHTLY BUILD PUSH SUCCEEDED" +fi + +exit 0 \ No newline at end of file diff --git a/Tools/githooks/pre-commit b/Tools/Scripts/githooks/pre-commit similarity index 100% rename from Tools/githooks/pre-commit rename to Tools/Scripts/githooks/pre-commit