-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from OffchainLabs/testnode-ci
Add CI for testnode that starts up nitro test node and rans l2 transactions
- Loading branch information
Showing
2 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |