From e838d9dd34ea5b880124dd0286ec61e4679d720a Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Tue, 3 Nov 2020 19:14:32 +0000 Subject: [PATCH 1/3] Add `merge-prs.sh` script to contrib/ --- contrib/merge-prs.sh | 87 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100755 contrib/merge-prs.sh diff --git a/contrib/merge-prs.sh b/contrib/merge-prs.sh new file mode 100755 index 0000000000..c0453d6474 --- /dev/null +++ b/contrib/merge-prs.sh @@ -0,0 +1,87 @@ +#!/bin/sh + +echo 'Please copy this script to /tmp, remove this warning, and run it from the root of your Elements repo as `/tmp/merge-prs.sh go`.' +exit 1 + +set -eo pipefail + +BASE=merged-master + +if [[ "$1" == "" ]]; then + echo "Usage: $0 " + echo " go will try to merge every PR, building/testing each" + echo " continue assumes the first git-merge has already happened" + echo " list-only will simply list all the PRs yet to be done" + echo " step will try to merge/build/test a single PR" + exit 1 +fi + +if [[ "$1" != "list-only" ]]; then + if [[ -f ".git/MERGE_MSG" ]]; then + echo "It looks like you're in the middle of a merge. Finish fixing" + echo "things then run 'git commit' before running this program." + exit 1 + fi +fi + +if [[ "$1" == "continue" ]]; then + BASE="$BASE^1" + ECHO_CONTINUE=1 + DO_BUILD=1 +elif [[ "$1" == "go" ]]; then + ECHO_CONTINUE=0 + DO_BUILD=1 +else + ECHO_CONTINUE=0 + DO_BUILD=0 +fi + +## Get full list of merges +ELT_COMMITS=$(git log master --not $BASE --merges --first-parent --pretty='format:%ct %cI %h Elements %s') +BTC_COMMITS=$(git log bitcoin/master --not $BASE --merges --first-parent --pretty='format:%ct %cI %h Bitcoin %s') + +## Sort by unix timestamp and iterate over them +echo "$ELT_COMMITS" "$BTC_COMMITS" | sort -n -k1 | while read line +do + ## Extract data and output what we're doing + DATE=$(echo $line | cut -d ' ' -f 2) + HASH=$(echo $line | cut -d ' ' -f 3) + CHAIN=$(echo $line | cut -d ' ' -f 4) + PR_ID=$(echo $line | cut -d ' ' -f 6 | tr -d :) + echo -e "$CHAIN PR \e[37m$PR_ID \e[33m$HASH\e[0m on \e[32m$DATE\e[0m " + + ## Do it + if [[ "$1" == "list-only" ]]; then + continue + fi + + if [[ "$ECHO_CONTINUE" == "1" ]]; then + echo -e "Continuing build of \e[37m$PR_ID\e[0m at $(date -Is)" + else + echo -e "Start merge/build of \e[37m$PR_ID\e[0m at $(date -Is)" + git merge $HASH -m "Merge $HASH into merged_master ($CHAIN PR $PR_ID)" + fi + + if [[ "$DO_BUILD" == "1" ]]; then + # Skip autogen/configure/clean because it'd take way too long + #./autogen.sh + #./configure --with-incompatible-bdb + chronic git checkout -- src/secp256k1/src/ + # The following is an expansion of `make check` that skips the libsecp + # tests and also the benchmarks (though it does build them!) + chronic make -j8 + chronic make -j8 -C src/ check-TESTS + chronic ./test/util/bitcoin-util-test.py + chronic ./test/util/rpcauth-test.py + chronic make -C src/univalue/ check + chronic ./test/functional/test_runner.py --jobs=8 + fi + + if [[ "$1" == "step" ]]; then + exit 1 + fi + + ECHO_CONTINUE=0 +done + + From 28269c34d77808fa08a771dda3fb1317671106a0 Mon Sep 17 00:00:00 2001 From: Glenn Willen Date: Tue, 3 Nov 2020 12:21:22 -0800 Subject: [PATCH 2/3] do not assume we are already at git root --- contrib/merge-prs.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/contrib/merge-prs.sh b/contrib/merge-prs.sh index c0453d6474..4efcfb24ec 100755 --- a/contrib/merge-prs.sh +++ b/contrib/merge-prs.sh @@ -5,6 +5,8 @@ exit 1 set -eo pipefail +GITROOT=$(git rev-parse --show-toplevel) + BASE=merged-master if [[ "$1" == "" ]]; then @@ -17,7 +19,7 @@ if [[ "$1" == "" ]]; then fi if [[ "$1" != "list-only" ]]; then - if [[ -f ".git/MERGE_MSG" ]]; then + if [[ -f "${GITROOT}/.git/MERGE_MSG" ]]; then echo "It looks like you're in the middle of a merge. Finish fixing" echo "things then run 'git commit' before running this program." exit 1 From a449dcf8f6eece7bd8153bedfa429fe74f66808e Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Thu, 10 Dec 2020 20:35:34 +0000 Subject: [PATCH 3/3] add lint check and full `make check` --- contrib/merge-prs.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/merge-prs.sh b/contrib/merge-prs.sh index 4efcfb24ec..15b2406131 100755 --- a/contrib/merge-prs.sh +++ b/contrib/merge-prs.sh @@ -72,7 +72,8 @@ do # The following is an expansion of `make check` that skips the libsecp # tests and also the benchmarks (though it does build them!) chronic make -j8 - chronic make -j8 -C src/ check-TESTS + chronic make -j1 check + chronic ./ci/lint/06_script.sh chronic ./test/util/bitcoin-util-test.py chronic ./test/util/rpcauth-test.py chronic make -C src/univalue/ check