-
Notifications
You must be signed in to change notification settings - Fork 78
85 lines (72 loc) · 2.54 KB
/
e2e-docker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Run e2e tests against Docker node
on:
workflow_call:
push:
branches:
- main
pull_request:
jobs:
test-docker-image:
name: e2e tests on Docker node
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image locally
id: docker_build
uses: docker/build-push-action@v6
with:
context: .
push: false
load: true
tags: test-anvil-zksync:latest
- name: Start Docker container
run: |
echo "Starting Docker container with test-anvil-zksync image..."
docker run --rm -d -p 8011:8011 -v $PWD/logs:/logs --name test_anvil_zksync test-anvil-zksync:latest
- name: Wait for the node to be ready
run: |
echo "Waiting for the node to be ready..."
MAX_RETRIES=10
COUNTER=0
URL="http://localhost:8011"
DATA='{"jsonrpc": "2.0", "id": "1", "method": "eth_chainId", "params": []}'
while [ $COUNTER -lt $MAX_RETRIES ]; do
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" -X POST -H "content-type: application/json" -d "$DATA" $URL || true)
if [ "$RESPONSE" -eq 200 ]; then
echo "Node is running!"
break
else
echo "Node not ready, retrying in 1 second..."
COUNTER=$((COUNTER + 1))
sleep 1
fi
done
if [ $COUNTER -eq $MAX_RETRIES ]; then
echo "Failed to contact node after $MAX_RETRIES attempts. Are you sure the node is running at $URL ?"
docker stop test_anvil_zksync
exit 1
fi
- name: Install dependencies for e2e tests
working-directory: ./e2e-tests
run: |
echo "Installing e2e test dependencies..."
yarn install --frozen-lockfile
- name: Compile contracts and run e2e tests
working-directory: ./e2e-tests
env:
ANVIL_LOG_PATH: "${{ github.workspace }}/logs/anvil-zksync.log"
run: |
echo "Compiling contracts and running e2e tests..."
yarn hardhat compile
yarn test
- name: Stop Docker container
if: always()
run: |
echo "Stopping Docker container..."
docker stop test_anvil_zksync
- name: Print test result summary
run: |
echo "Tests completed successfully!"