Skip to content

Commit

Permalink
add testnet4 ci
Browse files Browse the repository at this point in the history
  • Loading branch information
gartnera committed Nov 21, 2024
1 parent 31246e8 commit badc4b7
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 4 deletions.
39 changes: 38 additions & 1 deletion .github/workflows/build.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,41 @@ jobs:
with:
subject-name: ${{ env.IMAGE_BASE }}
subject-digest: ${{ steps.build.outputs.digest }}
push-to-registry: true
push-to-registry: true
test:
runs-on: ubuntu-latest
needs: build
timeout-minutes: 45
env:
CONTAINER_NAME: testnet4
steps:
- run: |
docker pull ${{ needs.build.outputs.IMAGE }}
docker tag ${{ needs.build.outputs.IMAGE }} bitcoin-core-docker
- uses: actions/checkout@v4
- run: ./examples/${CONTAINER_NAME}.sh
- name: Wait for healthy
run: |
while docker exec -i ${CONTAINER_NAME} /opt/wallet-health.sh; do
if ! docker ps | grep ${CONTAINER_NAME}; then
echo "Container stopped?"
exit 1
fi
echo "waiting for ${CONTAINER_NAME} health"
echo "Last log: $(docker logs -n1 ${CONTAINER_NAME})"
sleep 15
done
- name: Restart container
run: |
docker restart ${CONTAINER_NAME}
- name: Wait for healthy after restart
run: |
while docker exec -i ${CONTAINER_NAME} /opt/wallet-health.sh; do
if ! docker ps | grep ${CONTAINER_NAME}; then
echo "Container stopped?"
exit 1
fi
echo "waiting for ${CONTAINER_NAME} health"
echo "Last log: $(docker logs -n1 ${CONTAINER_NAME})"
sleep 15
done
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ VOLUME ["/root/.bitcoin"]

RUN bitcoind -version | grep "Bitcoin Core version v${BITCOIN_VERSION}"

COPY wallet.sh /opt/wallet.sh
COPY wallet.sh wallet-health.sh /opt/

CMD ["bitcoind"]
2 changes: 1 addition & 1 deletion examples/testnet4.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ docker run -d \
-e RPC_USER=default \
-e RPC_PASSWORD=default \
-e WALLET_NAME=default \
-e WALLET_ADDRESS=110yMxB69Fp5kYQtdA7lpQWZWCMna2dtjl \
-e WALLET_ADDRESS=tb1qfm8a8pxer0kmfa4xlk34e44xpr8g46ae0v04dw \
bitcoin-core-docker /opt/wallet.sh
13 changes: 13 additions & 0 deletions wallet-health.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -eo pipefail

# this script checks if a wallet exists and is not scanning

echo "Getting wallet info"
wallet_info=$(bitcoin-cli -rpcwallet=$1 getwalletinfo)

if [[ $(echo "$wallet_info" | jq -r '.scanning') == "true" ]]; then
echo "Error: Wallet is currently scanning" >&2
exit 1
fi
2 changes: 1 addition & 1 deletion wallet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ load_wallet() {
sleep 5
bitcoin-cli loadwallet ${WALLET_NAME} || echo "wallet already loaded"
sleep 5
bitcoin-cli importaddress "${WALLET_ADDRESS}" "${WALLET_NAME}" true || echo "address already exists"
bitcoin-cli -rpcwallet "${WALLET_NAME}" importaddress "${WALLET_ADDRESS}" "${WALLET_NAME}" true || echo "importaddress failed"
}

snapshot_restore() {
Expand Down

0 comments on commit badc4b7

Please sign in to comment.