From dec1ed911b5d377991536fd125c9f69846c9c063 Mon Sep 17 00:00:00 2001 From: Juraj Piar Date: Tue, 7 May 2024 18:17:44 +0100 Subject: [PATCH] feat(ci): makes services work --- .../bitcoind.conf} | 0 .../bitcoind.conf} | 0 .github/workflows/build_and_test.yml | 91 +++++++++++++++---- 3 files changed, 74 insertions(+), 17 deletions(-) rename .github/mining-test/{bitcoind01.conf => bitcoind01/bitcoind.conf} (100%) rename .github/mining-test/{bitcoind02.conf => bitcoind02/bitcoind.conf} (100%) diff --git a/.github/mining-test/bitcoind01.conf b/.github/mining-test/bitcoind01/bitcoind.conf similarity index 100% rename from .github/mining-test/bitcoind01.conf rename to .github/mining-test/bitcoind01/bitcoind.conf diff --git a/.github/mining-test/bitcoind02.conf b/.github/mining-test/bitcoind02/bitcoind.conf similarity index 100% rename from .github/mining-test/bitcoind02.conf rename to .github/mining-test/bitcoind02/bitcoind.conf diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 9d0849101d8..73c71bb51b5 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -167,33 +167,102 @@ jobs: bitcoind01: image: kylemanna/bitcoind:latest volumes: - - ${{ github.workspace }}/.github/mining-test/bitcoind01.conf:/etc/bitcoind/bitcoind.conf + - ${{ github.workspace }}/.github/mining-test/bitcoind01:/bitcoin/.bitcoin/ env: DISABLEWALLET: "0" ports: - 31591:31591 + - 32591:32591 options: >- --entrypoint "/usr/local/bin/bitcoind" - --conf "/etc/bitcoind/bitcoind.conf" + --name bitcoind01 bitcoind02: image: kylemanna/bitcoind:latest volumes: - - ${{ github.workspace }}/.github/mining-test/bitcoind02.conf:/etc/bitcoind/bitcoind.conf + - ${{ github.workspace }}/.github/mining-test/bitcoind02:/bitcoin/.bitcoin/ env: DISABLEWALLET: "0" ports: - 31592:31592 + - 32592:32592 options: >- --entrypoint "/usr/local/bin/bitcoind" - --conf "/etc/bitcoind/bitcoind.conf" + --name bitcoind02 + steps: - uses: actions/checkout@v2 + - name: Setup System Tools run: | apt-get update -y - apt-get install -y jq + apt-get install -y jq lsof + +# - name: Verify bitcoind01 and bitcoind02 are running +# uses: docker://docker +# with: +# args: | +# docker ps -all +# +# - name: Verify all required ports are used by bitcoind01 and bitcoind02 +# shell: bash +# run: | +# ports=(31591 32591 31592 32592) +# for port in "${ports[@]}"; do +# if ! lsof -i:$port -sTCP:LISTEN > /dev/null; then +# echo "Error: No process is listening on port $port" +# exit 1 +# fi +# done +# echo "Success: All specified ports are being listened to." + + - name: Restart bitcoin nodes + uses: docker://docker + with: + args: docker restart bitcoind01 bitcoind02 + + - name: Attach bitcoind01 container to the network + uses: docker://docker + with: + args: docker network connect bridge bitcoind01 + + - name: Attach bitcoind02 container to the network + uses: docker://docker + with: + args: docker network connect bridge bitcoind02 + + - name: Check that bitcoind01 and bitcoind02 are attached to the network + uses: docker://docker + with: + args: | + docker network inspect bridge + + - name: Verify bitcoind01 and bitcoind02 are running + uses: docker://docker + with: + args: | + docker ps -all + + - name: Verify all required ports are used by bitcoind01 and bitcoind02 + shell: bash + run: | + ports=(31591 32591 31592 32592) + for port in "${ports[@]}"; do + if ! lsof -i:$port -sTCP:LISTEN > /dev/null; then + echo "Error: No process is listening on port $port" + exit 1 + fi + done + echo "Success: All specified ports are being listened to." + + - name: Test bitcoin nodes + run: | + echo Test bitcoin node 1 + curl -v -s -u admin:admin --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"getblockchaininfo","params":[]}' -H 'content-type:text/plain;' http://bitcoind01:32591 + echo Test bitcoin node 2 + curl -v -s -u admin:admin --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"getblockchaininfo","params":[]}' -H 'content-type:text/plain;' http://bitcoind02:32592 + - name: Setup Node.js uses: actions/setup-node@v2 @@ -234,18 +303,6 @@ jobs: # # - - name: Restart bitcoin nodes - uses: docker://docker - with: - args: docker restart bitcoind01 bitcoind02 - - - name: Test bitcoin nodes - run: | - echo Test bitcoin node 1 - curl -s -u admin:admin --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"getblockchaininfo","params":[]}' -H 'content-type:text/plain;' http://bitcoind01:32591 - echo Test bitcoin node 2 - curl -s -u admin:admin --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"getblockchaininfo","params":[]}' -H 'content-type:text/plain;' http://localhost:32592 - - name: Generate BTC blocks working-directory: mining-integration-tests run: |