-
Notifications
You must be signed in to change notification settings - Fork 2
270 lines (229 loc) · 8 KB
/
e2e.yml
File metadata and controls
270 lines (229 loc) · 8 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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
name: E2E Tests
on:
workflow_dispatch:
push:
branches: [develop, main]
paths:
- 'frontend/**'
- 'services/**'
- '.github/workflows/e2e.yml'
pull_request:
branches: [develop, main]
paths:
- 'frontend/**'
- 'services/**'
- '.github/workflows/e2e.yml'
permissions:
contents: read
jobs:
# ===========================================================================
# Build: compile backend binary and frontend assets once, share via artifacts
# ===========================================================================
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.26.0'
cache: true
- name: Set up buf
uses: bufbuild/buf-setup-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Generate protobuf files
run: buf generate
- name: Build proto FileDescriptorSet
run: buf build api/proto -o cmd/meridian/descriptor.binpb
- name: Build meridian binary
run: CGO_ENABLED=0 go build -o ./dist/meridian ./cmd/meridian/
- name: Build seed-dev binary
run: CGO_ENABLED=0 go build -o ./dist/seed-dev ./cmd/seed-dev/
- name: Install frontend dependencies
working-directory: frontend
run: npm ci
- name: Generate frontend protobuf files
working-directory: frontend
run: npm run generate
- name: Build frontend
working-directory: frontend
env:
VITE_E2E_MODE: 'true'
VITE_API_BASE_URL: 'http://localhost:5173'
run: npx vite build
- name: Upload backend binaries
uses: actions/upload-artifact@v7
with:
name: meridian-binary
path: |
dist/meridian
dist/seed-dev
retention-days: 1
- name: Upload frontend build
uses: actions/upload-artifact@v7
with:
name: frontend-dist
path: frontend/dist/
retention-days: 1
# ===========================================================================
# E2E Shards: run Playwright tests in parallel across 4 runners
# ===========================================================================
e2e:
name: 'E2E Shard ${{ matrix.shardIndex }}/4'
runs-on: ubuntu-latest
timeout-minutes: 25
needs: build
strategy:
fail-fast: false
matrix:
shardIndex: [1, 2, 3, 4]
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Download backend binary
uses: actions/download-artifact@v8
with:
name: meridian-binary
path: dist/
- name: Make binaries executable
run: chmod +x dist/meridian dist/seed-dev
- name: Download frontend build
uses: actions/download-artifact@v8
with:
name: frontend-dist
path: frontend/dist/
- name: Start CockroachDB
run: |
docker run -d \
--name cockroachdb \
-p 26257:26257 \
cockroachdb/cockroach:latest-v24.1 \
start-single-node --insecure
# Wait for CockroachDB to be ready (up to 60s)
for i in $(seq 1 30); do
if docker exec cockroachdb cockroach sql --insecure -e 'SELECT 1' >/dev/null 2>&1; then
echo "CockroachDB is ready"
break
fi
if [ "$i" -eq 30 ]; then
echo "ERROR: CockroachDB did not become ready after 60s"
exit 1
fi
sleep 2
done
- name: Run database migrations
run: |
./dist/meridian \
--migrate \
--database-url "postgres://root@localhost:26257/defaultdb?sslmode=disable"
- name: Start meridian backend
run: |
DATABASE_URL="postgres://root@localhost:26257/defaultdb?sslmode=disable" \
LOCAL_DEV_MODE=true \
SAGA_ASSET_DIR="$(pwd)" \
./dist/meridian >/tmp/meridian.log 2>&1 &
- name: Seed dev tenant and apply manifest
run: |
./dist/seed-dev \
--gateway-url=http://localhost:8090 \
--grpc-addr=localhost:50051 \
--manifest=examples/manifests/energy.json \
--tenant-id=dev_tenant \
--tenant-slug=dev-tenant
- name: Create additional test tenants
run: |
GATEWAY_URL="http://localhost:8090"
create_tenant() {
local TENANT_ID=$1
local PAYLOAD=$2
HTTP_CODE=$(curl -sS -o /tmp/tenant_resp.txt -w "%{http_code}" \
-X POST "${GATEWAY_URL}/v1/tenants" \
-H "Content-Type: application/json" \
-H "X-Tenant-Slug: dev-tenant" \
-d "$PAYLOAD")
echo "${TENANT_ID}: HTTP ${HTTP_CODE}"
if [ "$HTTP_CODE" != "200" ] && [ "$HTTP_CODE" != "201" ] && [ "$HTTP_CODE" != "409" ]; then
echo "ERROR: Unexpected response for ${TENANT_ID}:"
cat /tmp/tenant_resp.txt
exit 1
fi
}
create_tenant "acme_corp" '{"tenantId":"acme_corp","displayName":"ACME Corporation","settlementAsset":"GBP","slug":"acme-corp"}'
create_tenant "energy_co" '{"tenantId":"energy_co","displayName":"Energy Co Ltd","settlementAsset":"KWH","slug":"energy-co"}'
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install frontend dependencies
working-directory: frontend
run: npm ci
- name: Install Playwright browsers
working-directory: frontend
run: npx playwright install --with-deps chromium
- name: Run Playwright tests (shard ${{ matrix.shardIndex }}/4)
working-directory: frontend
env:
CI: 'true'
run: npx playwright test --shard=${{ matrix.shardIndex }}/4 --reporter=blob
- name: Upload blob report
uses: actions/upload-artifact@v7
if: always()
with:
name: blob-report-${{ matrix.shardIndex }}
path: frontend/blob-report/
retention-days: 1
- name: Upload Playwright traces
uses: actions/upload-artifact@v7
if: failure()
with:
name: playwright-traces-${{ matrix.shardIndex }}
path: frontend/test-results/
retention-days: 30
# ===========================================================================
# Merge: combine shard reports into a single HTML report
# ===========================================================================
merge-reports:
name: Merge E2E Reports
runs-on: ubuntu-latest
needs: e2e
if: ${{ always() && needs.e2e.result != 'skipped' }}
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install frontend dependencies
working-directory: frontend
run: npm ci
- name: Download blob reports
uses: actions/download-artifact@v8
with:
pattern: blob-report-*
path: frontend/all-blob-reports
merge-multiple: true
- name: Merge reports
working-directory: frontend
run: npx playwright merge-reports --reporter=html all-blob-reports
- name: Upload merged report
uses: actions/upload-artifact@v7
if: always()
with:
name: playwright-report
path: frontend/playwright-report/
retention-days: 30