Skip to content

Commit

Permalink
feat(ci): makes services work
Browse files Browse the repository at this point in the history
  • Loading branch information
jurajpiar committed May 8, 2024
1 parent 663124b commit aec221b
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 34 deletions.
File renamed without changes.
File renamed without changes.
153 changes: 119 additions & 34 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,33 +167,133 @@ 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:/bitcoin/.bitcoin/
# env:
# DISABLEWALLET: "0"
# ports:
# - 31592:31592
# - 32592:32592
# options: >-
# --entrypoint "/usr/local/bin/bitcoind"
# --name bitcoind02

bitcoind02:
image: kylemanna/bitcoind:latest
volumes:
- ${{ github.workspace }}/.github/mining-test/bitcoind02.conf:/etc/bitcoind/bitcoind.conf
env:
DISABLEWALLET: "0"
ports:
- 31592:31592
options: >-
--entrypoint "/usr/local/bin/bitcoind"
--conf "/etc/bitcoind/bitcoind.conf"
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: bitcoind01 logs
uses: docker://docker
with:
args: |
docker logs bitcoind01
- 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: Print content of /bitcoin/.bitcoin/
uses: docker://docker
with:
args: |
docker exec bitcoind01 ls -la /bitcoin/.bitcoin
- name: Print content of /bitcoin/.bitcoin/
run: |
ls -la .github/mining-test/bitcoind01
- name: Print content of /bitcoin/.bitcoin/bitcoin.conf
uses: docker://docker
with:
args: |
docker exec bitcoind01 cat /bitcoin/.bitcoin/bitcoind.conf
- name: bitcoind01 logs
uses: docker://docker
with:
args: |
docker logs bitcoind01
- name: Wait for Bitcoin nodes to initialize
run: sleep 30

- 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
Expand Down Expand Up @@ -234,18 +334,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: |
Expand Down Expand Up @@ -304,13 +392,10 @@ jobs:
run: |
npm test
- name: Stop RSKj
if: always()
run: |
kill $rskpid
- name: Stop and Remove Docker Containers
uses: docker://docker
if: always()
run: |
/usr/bin/docker stop bitcoind01 bitcoind02
/usr/bin/docker rm bitcoind01 bitcoind02
with:
args: |
docker stop bitcoind01 bitcoind02
docker rm bitcoind01 bitcoind02

0 comments on commit aec221b

Please sign in to comment.