aboutsummaryrefslogtreecommitdiff
path: root/scripts/git
diff options
context:
space:
mode:
authorteor <teor@torproject.org>2019-08-08 12:33:42 +1000
committerteor <teor@torproject.org>2019-08-08 18:59:44 +1000
commitd6202d3128db259c1051eeef3e304459bcee8b53 (patch)
tree8ba006a667c1145160855d66e190da15a41ded34 /scripts/git
parent35cfe2e77679e1df5c3ae4b71112fa252acafdca (diff)
downloadtor-d6202d3128db259c1051eeef3e304459bcee8b53.tar.gz
tor-d6202d3128db259c1051eeef3e304459bcee8b53.zip
scripts/git: add TOR_PUSH_DELAY to git-push-all.sh
Add a TOR_PUSH_DELAY variable to git-push-all.sh, which makes the script push master and maint branches with a delay between each branch. These delays trigger the CI jobs in a set order, which should show the most likely failures first. Also: * make pushes atomic by default, and * make the script pass any command-line arguments to git push. Closes ticket 29879.
Diffstat (limited to 'scripts/git')
-rwxr-xr-xscripts/git/git-push-all.sh51
1 files changed, 42 insertions, 9 deletions
diff --git a/scripts/git/git-push-all.sh b/scripts/git/git-push-all.sh
index 2030a600ff..1ae310eca4 100755
--- a/scripts/git/git-push-all.sh
+++ b/scripts/git/git-push-all.sh
@@ -1,11 +1,44 @@
#!/usr/bin/env bash
-# The remote upstream branch on which git.torproject.org/tor.git points to.
-UPSTREAM_BRANCH=${TOR_UPSTREAM_REMOTE_NAME:-"upstream"}
-
-git push "$UPSTREAM_BRANCH" \
- master \
- {release,maint}-0.4.1 \
- {release,maint}-0.4.0 \
- {release,maint}-0.3.5 \
- {release,maint}-0.2.9
+# Usage: git-push-all.sh
+# env vars: TOR_UPSTREAM_REMOTE_NAME=upstream TOR_PUSH_DELAY=0
+# options: --no-atomic --dry-run (any other git push option)
+#
+# TOR_PUSH_DELAY pushes the master and maint branches separately, so that CI
+# runs in a sensible order.
+# push --atomic is the default when TOR_PUSH_DELAY=0, and for release branches.
+
+set -e
+
+# The upstream remote which git.torproject.org/tor.git points to.
+UPSTREAM_REMOTE=${TOR_UPSTREAM_REMOTE_NAME:-"upstream"}
+# Add a delay between pushes, so CI runs on the most important branches first
+PUSH_DELAY=${TOR_PUSH_DELAY:-0}
+
+PUSH_BRANCHES=`echo \
+ master \
+ {release,maint}-0.4.1 \
+ {release,maint}-0.4.0 \
+ {release,maint}-0.3.5 \
+ {release,maint}-0.2.9 \
+ `
+
+if [ "$PUSH_DELAY" -le 0 ]; then
+ echo "Pushing $PUSH_BRANCHES"
+ git push --atomic "$@" "$UPSTREAM_REMOTE" $PUSH_BRANCHES
+else
+ PUSH_BRANCHES=`echo "$PUSH_BRANCHES" | tr " " "\n" | sort -V`
+ MASTER_BRANCH=`echo "$PUSH_BRANCHES" | tr " " "\n" | grep master`
+ MAINT_BRANCHES=`echo "$PUSH_BRANCHES" | tr " " "\n" | grep maint`
+ RELEASE_BRANCHES=`echo "$PUSH_BRANCHES" | tr " " "\n" | grep release | \
+ tr "\n" " "`
+ printf "Pushing with %ss delays, so CI runs in this order:\n%s\n%s\n%s\n" \
+ "$PUSH_DELAY" "$MASTER_BRANCH" "$MAINT_BRANCHES" "$RELEASE_BRANCHES"
+ git push "$@" "$UPSTREAM_REMOTE" $MASTER_BRANCH
+ sleep "$PUSH_DELAY"
+ for b in $MAINT_BRANCHES; do
+ git push "$@" "$UPSTREAM_REMOTE" $b
+ sleep "$PUSH_DELAY"
+ done
+ git push --atomic "$@" "$UPSTREAM_REMOTE" $RELEASE_BRANCHES
+fi