-
Notifications
You must be signed in to change notification settings - Fork 36
223 lines (200 loc) · 8.49 KB
/
Copy pathdev-test-on-pr.yml
File metadata and controls
223 lines (200 loc) · 8.49 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
name: E2E Tests
on:
pull_request:
workflow_dispatch:
inputs:
docker_image_tag:
description: "Docker Image Tag of avaprotocol/avs-dev"
required: false
default: "latest"
# Shared env for all jobs that need secrets
env:
TEST_ENV: "dev"
DOCKER_IMAGE_TAG: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.docker_image_tag || 'latest' }}
jobs:
# ── Job 1: Check if tests should run ──────────────────────────────
setup:
name: Setup
runs-on: ubuntu-latest
outputs:
should_run: ${{ steps.resolve.outputs.should_run }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check source or test code changes
id: check
if: github.event_name == 'pull_request'
run: |
git fetch origin ${{ github.base_ref }} --depth=1
CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }} HEAD)
SOURCE_PATTERN='^(packages/sdk-js/src|packages/types/src|tests/|config/)'
MATCHING_FILES=$(echo "$CHANGED_FILES" | grep -E "$SOURCE_PATTERN" || echo "")
if [ -z "$MATCHING_FILES" ]; then
echo "should_run=false" >> $GITHUB_OUTPUT
echo "No source/test changes detected, skipping tests"
else
echo "should_run=true" >> $GITHUB_OUTPUT
echo "Changes detected:"
echo "$MATCHING_FILES"
fi
- name: Always run for workflow_dispatch
if: github.event_name == 'workflow_dispatch'
run: echo "should_run=true" >> $GITHUB_OUTPUT
id: dispatch_check
# Merge outputs: workflow_dispatch always runs, PR only if source changed
- name: Resolve should_run
id: resolve
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "should_run=true" >> $GITHUB_OUTPUT
else
echo "should_run=${{ steps.check.outputs.should_run || 'true' }}" >> $GITHUB_OUTPUT
fi
# ── Job 2: Parallel test suites ───────────────────────────────────
e2e-tests:
name: "E2E / ${{ matrix.suite }}"
needs: setup
if: needs.setup.outputs.should_run != 'false'
runs-on: ubuntu-latest
environment: dev
strategy:
fail-fast: false
matrix:
suite: [core, workflows, executions, triggers, nodes, templates]
env:
# Secrets
TEST_PRIVATE_KEY: ${{ secrets.TEST_PRIVATE_KEY }}
ECDSA_PRIVATE_KEY: ${{ secrets.ECDSA_PRIVATE_KEY }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
TENDERLY_ACCESS_KEY: ${{ secrets.TENDERLY_ACCESS_KEY }}
CONTROLLER_PRIVATE_KEY: ${{ secrets.CONTROLLER_PRIVATE_KEY }}
AP_NOTIFY_BOT_TOKEN: ${{ secrets.AP_NOTIFY_BOT_TOKEN }}
MORALIS_API_KEY: ${{ secrets.MORALIS_API_KEY }}
SENDGRID_KEY: ${{ secrets.SENDGRID_KEY }}
ETH_RPC_URL: ${{ secrets.ETH_RPC_URL }}
ETH_WS_URL: ${{ secrets.ETH_WS_URL }}
CHAIN_ENDPOINT: ${{ secrets.CHAIN_ENDPOINT }}
CONTEXT_MEMORY_API_KEY: ${{ secrets.CONTEXT_MEMORY_API_KEY }}
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
# Variables
TENDERLY_ACCOUNT: ${{ vars.TENDERLY_ACCOUNT }}
TENDERLY_PROJECT: ${{ vars.TENDERLY_PROJECT }}
THEGRAPH_API_KEY: ${{ vars.THEGRAPH_API_KEY }}
BUNDLER_URL: ${{ secrets.BUNDLER_URL }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
cache: "yarn"
- name: Install dependencies
run: yarn install
- name: Build SDK
run: yarn build
- name: Inject secrets into gateway + worker configs
run: |
export TEST_ENV ETH_RPC_URL ETH_WS_URL ECDSA_PRIVATE_KEY JWT_SECRET BUNDLER_URL CONTROLLER_PRIVATE_KEY TENDERLY_ACCOUNT TENDERLY_PROJECT TENDERLY_ACCESS_KEY AP_NOTIFY_BOT_TOKEN SENDGRID_KEY THEGRAPH_API_KEY MORALIS_API_KEY CONTEXT_MEMORY_API_KEY
for src in gateway worker-sepolia; do
envsubst < config/${src}.yaml > config/${src}.runtime.yaml
echo "Generated config/${src}.runtime.yaml: $(wc -l < config/${src}.runtime.yaml) lines"
if grep -q "\${.*}" config/${src}.runtime.yaml; then
echo "WARNING: Found unsubstituted variables in ${src}.runtime.yaml:"
grep "\${.*}" config/${src}.runtime.yaml
else
echo "All variables substituted correctly in ${src}.runtime.yaml."
fi
done
- name: Start gateway
run: |
docker compose up -d gateway
echo "Waiting for gateway to start..."
sleep 10
docker compose ps
docker compose logs gateway --tail=20
- name: Wait for gateway health
run: |
max_attempts=24
attempt=0
while [ $attempt -lt $max_attempts ]; do
if curl --output /dev/null --silent --fail --max-time 5 http://localhost:8080/up; then
echo "Gateway is ready!"
break
fi
echo "Attempt $((attempt + 1))/$max_attempts: not ready yet..."
docker compose logs gateway --tail=5
sleep 5
attempt=$((attempt + 1))
done
if [ $attempt -eq $max_attempts ]; then
echo "Gateway failed to start"
docker compose ps
docker compose logs gateway
exit 1
fi
- name: Start worker-sepolia
run: |
docker compose up -d worker-sepolia
echo "Waiting for worker-sepolia to start..."
sleep 5
docker compose ps
docker compose logs worker-sepolia --tail=20
- name: Wait for worker-sepolia health
run: |
max_attempts=24
attempt=0
while [ $attempt -lt $max_attempts ]; do
if curl --output /dev/null --silent --fail --max-time 5 http://localhost:8090/health; then
echo "Worker-sepolia is ready!"
break
fi
echo "Attempt $((attempt + 1))/$max_attempts: worker not ready yet..."
docker compose logs worker-sepolia --tail=5
sleep 5
attempt=$((attempt + 1))
done
if [ $attempt -eq $max_attempts ]; then
echo "Worker-sepolia failed to start"
docker compose ps
docker compose logs worker-sepolia
exit 1
fi
- name: Generate AVS API key
run: |
# IMPORTANT: -T disables TTY allocation. Without it, docker compose exec
# converts \n to \r\n on stdout, so the captured API key gets a trailing
# \r and the gateway rejects it as "API key invalid".
#
# Binary path is /ava — the published avaprotocol/avs-dev:latest image
# still ships the older binary name at root. The EigenLayer-AVS source
# Dockerfile has since renamed it to /app/ap (ENTRYPOINT ["./ap"]); flip
# this to "./ap" once a fresh image tag picks up that rebuild.
API_KEY=$(docker compose exec -T gateway /ava create-api-key --config /app/config/gateway.runtime.yaml --role=admin --subject=0x804e49e8C4eDb560AE7c48B554f6d2e27Bb81557)
echo "AVS_API_KEY=$API_KEY" >> $GITHUB_ENV
echo "API key generated (${#API_KEY} chars)"
- name: "Run test:${{ matrix.suite }}"
run: yarn test:${{ matrix.suite }}
# ── Job 3: Report results ─────────────────────────────────────────
report:
name: Report
needs: [setup, e2e-tests]
if: always()
runs-on: ubuntu-latest
steps:
- name: Summary
run: |
echo "## E2E Test Results" >> $GITHUB_STEP_SUMMARY
if [ "${{ needs.setup.outputs.should_run }}" = "false" ]; then
echo "Tests skipped — no source/test changes detected." >> $GITHUB_STEP_SUMMARY
exit 0
fi
if [ "${{ needs.e2e-tests.result }}" = "success" ]; then
echo "All test suites passed." >> $GITHUB_STEP_SUMMARY
elif [ "${{ needs.e2e-tests.result }}" = "skipped" ]; then
echo "Tests were skipped." >> $GITHUB_STEP_SUMMARY
else
echo "Some test suites failed. Check individual job logs for details." >> $GITHUB_STEP_SUMMARY
exit 1
fi