Changeset View
Changeset View
Standalone View
Standalone View
contrib/source-control-tools/automated-commits.sh
- This file was added.
Property | Old Value | New Value |
---|---|---|
File Mode | null | 100755 |
#!/usr/bin/env bash | |||||
# Note: Any bot running this script must have the appropriate permissions to | |||||
# push commits upstream. When running locally, this script will git push in a | |||||
# dry run by default. | |||||
export LC_ALL=C.UTF-8 | |||||
set -euxo pipefail | |||||
: "${DIFF_NAME:=}" | |||||
if [ -z "$DIFF_NAME" ]; then | |||||
Fabien: Nit: consistency between `$DIFF_NAME` and `${DIFF_NAME}` | |||||
echo "Error: Environment variable DIFF_NAME must be set" | |||||
FabienUnsubmitted Not Done Inline ActionsDIFF_NAME is a not a meaningful name, since it's not a diff (in the sense of phabricator) and you're not setting a name. Fabien: `DIFF_NAME` is a not a meaningful name, since it's not a diff (in the sense of phabricator) and… | |||||
exit 1 | |||||
fi | |||||
echo "Building automated commit '${DIFF_NAME}'..." | |||||
BOT_PREFIX="[Automated]" | |||||
TOPLEVEL=$(git rev-parse --show-toplevel) | |||||
CHAINPARAMS_SCRIPTS_DIR="${TOPLEVEL}"/contrib/devtools/chainparams | |||||
TEAMCITY_SCRIPTS_DIR="${TOPLEVEL}"/contrib/teamcity | |||||
# Make sure tree is clean | |||||
git checkout master | |||||
git reset --hard origin/master | |||||
case "$DIFF_NAME" in | |||||
FabienUnsubmitted Not Done Inline ActionsDito Fabien: Dito | |||||
update-chainparams) | |||||
# Assumes bitcoind instances are already running on mainnet and testnet | |||||
pushd "${CHAINPARAMS_SCRIPTS_DIR}" | |||||
CHAINPARAMS_MAINNET_TXT="chainparams_main.txt" | |||||
./make_chainparams.py > "${CHAINPARAMS_MAINNET_TXT}" | |||||
git add "${CHAINPARAMS_MAINNET_TXT}" | |||||
CHAINPARAMS_TESTNET_TXT="chainparams_test.txt" | |||||
./make_chainparams.py -a 127.0.0.1:18332 > "${CHAINPARAMS_TESTNET_TXT}" | |||||
git add "${CHAINPARAMS_TESTNET_TXT}" | |||||
CHAINPARAMS_CONSTANTS="${TOPLEVEL}"/src/chainparamsconstants.h | |||||
./generate_chainparams_constants.py . > "${CHAINPARAMS_CONSTANTS}" | |||||
git add "${CHAINPARAMS_CONSTANTS}" | |||||
popd | |||||
# Sanity check that the new chainparams build | |||||
ABC_BUILD_NAME=build-werror "${TEAMCITY_SCRIPTS_DIR}"/build-configurations.sh | |||||
git commit -m "${BOT_PREFIX} Update chainparams" | |||||
;; | |||||
*) | |||||
echo "Error: Invalid commit name '${DIFF_NAME}'" | |||||
exit 2 | |||||
;; | |||||
esac | |||||
echo "Pushing automated commit '${DIFF_NAME}'..." | |||||
FabienUnsubmitted Not Done Inline ActionsIDK how complicated it could be, but it would be nice to run the linters before committing to prevent the bot from adding some formatting errors that would need to be fixed by users. Fabien: IDK how complicated it could be, but it would be nice to run the linters before committing to… | |||||
GIT_PUSH_OPTIONS=("--verbose") | |||||
case ${DRY_RUN:=yes} in | |||||
no|NO|false|FALSE) | |||||
# Do nothing | |||||
;; | |||||
*) | |||||
GIT_PUSH_OPTIONS+=("--dry-run") | |||||
;; | |||||
esac | |||||
# Make sure master is up-to-date. If there is a merge conflict, this script | |||||
# will not attempt to resolve it and simply fail. | |||||
git fetch origin master | |||||
git rebase origin/master | |||||
git push "${GIT_PUSH_OPTIONS[@]}" origin master |
Nit: consistency between $DIFF_NAME and ${DIFF_NAME}