Skip to content

Commit

Permalink
Merge pull request #44 from OffchainLabs/testnode-ci
Browse files Browse the repository at this point in the history
Add CI for testnode that starts up nitro test node and rans l2 transactions
  • Loading branch information
tsahee authored Mar 5, 2024
2 parents 3922df9 + b9588a1 commit 76c0616
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CI
run-name: CI triggered from @${{ github.actor }} of ${{ github.head_ref }}

on:
workflow_dispatch:
merge_group:
pull_request:
push:
branches:
- master
- develop


jobs:
build_and_run:
runs-on: ubuntu-8

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: network=host

- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('Dockerfile') }}
restore-keys: ${{ runner.os }}-buildx-

- name: Startup Nitro testnode
run: ${{ github.workspace }}/.github/workflows/testnode.bash
40 changes: 40 additions & 0 deletions .github/workflows/testnode.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash
# The script starts up the test node and waits until the timeout (10min) or
# until send-l2 succeeds.

# Start the test node and get PID, to terminate it once send-l2 is done.
${GITHUB_WORKSPACE}/test-node.bash --init > output.log 2>&1 &
PID=$!

sleep 5m

START=$(date +%s)
SUCCEDED=0

while true; do
if ${GITHUB_WORKSPACE}/test-node.bash script send-l2 --ethamount 100 --to user_l2user --wait; then
echo "Sending l2 transaction succeeded"
SUCCEDED=1
break
fi

# Check if the timeout (10 min) has been reached.
NOW=$(date +%s)
DIFF=$((NOW - START))
if [ "$DIFF" -ge 600 ]; then
echo "Timed out"
break
fi

sleep 10
done

# Shut down the test node and wait for it to terminate.
kill $PID
wait $PID

if [ "$SUCCEDED" -eq 0 ]; then
exit 1
fi

exit 0

0 comments on commit 76c0616

Please sign in to comment.