Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: timeout wait script and print log #33

Draft
wants to merge 24 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/run-nitro-test-node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v4
- uses: ./run-nitro-test-node

run-with-token-bridge:
run-without-token-bridge:
name: "Run without token bridge deployment"
runs-on: ubuntu-latest
steps:
Expand All @@ -28,7 +28,7 @@ jobs:
- uses: actions/checkout@v4
- uses: ./run-nitro-test-node
with:
args: --detach
args: --pos

run-with-simple:
name: "Run in simple mode"
Expand Down
9 changes: 3 additions & 6 deletions run-nitro-test-node/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ inputs:
description: "Additional args that can be supplied to the test node script"
nitro-testnode-ref:
required: false
default: "release"
default: "gz-debug"
description: "The nitro-testnode branch to use"
l3-node:
required: false
Expand All @@ -44,9 +44,6 @@ runs:

- name: Start background nitro-testnode test-node.bash
shell: bash
# Currently, you can't run parallel steps, so we add the "&" to run this step in the background
#
# See https://stackoverflow.com/a/72203688 for more info
run: |
cd nitro-testnode

Expand All @@ -57,11 +54,11 @@ runs:
export TOKEN_BRIDGE_BRANCH="${{ inputs.token-bridge-branch }}"
fi

./test-node.bash --init ${{ inputs.no-simple == 'true' && '--no-simple' || '' }} \
./test-node.bash --init-force ${{ inputs.no-simple == 'true' && '--no-simple' || '' }} \
${{ inputs.l3-node == 'true' && '--l3node' || '' }} \
${{ inputs.no-token-bridge == 'true' && '--no-tokenbridge' || '--tokenbridge' }} \
${{ inputs.l3-node == 'true' && inputs.no-l3-token-bridge != 'true' && '--l3-token-bridge' || '' }} \
${{ inputs.args }} &
${{ inputs.args }} --detach --nowait

- name: Wait for nitro startup
shell: bash
Expand Down
10 changes: 8 additions & 2 deletions run-nitro-test-node/waitForNitro.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@

PORT=${1:-8547}

while true
# timeout after around 1 minutes, should be enough because test-node.bash only detach after everything is ready
for i in {1..6}
do
curl -X POST -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":45678,"method":"eth_chainId","params":[]}' "http://localhost:$PORT"
curl --silent -X POST -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":45678,"method":"eth_chainId","params":[]}' "http://localhost:$PORT"
if [ "$?" -eq "0" ]; then
echo "nitro ready at port $PORT"
exit 0
else
echo "nitro not ready yet at port $PORT"
sleep 10
fi
done
echo "exiting: printing docker logs for everything"
docker compose -f ./nitro-testnode/docker-compose.yaml logs
exit 1
7 changes: 6 additions & 1 deletion run-nitro-test-node/waitForTokenBridge.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# poll the token bridge deployment file until we get a 0 return code
while true
# timeout after around 1 minutes, should be enough because test-node.bash only detach after everything is ready
for i in {1..6}
do
docker compose -f ./nitro-testnode/docker-compose.yaml run --entrypoint sh tokenbridge -c "cat $1"
if [ "$?" -eq "0" ]; then
exit 0
else
echo "token bridge not ready yet $1"
sleep 10
fi
done
echo "exiting: printing docker logs for tokenbridge deployment"
docker compose -f ./nitro-testnode/docker-compose.yaml logs tokenbridge
exit 1