-
Notifications
You must be signed in to change notification settings - Fork 1
229 lines (206 loc) · 7.58 KB
/
e2e-tests.yml
File metadata and controls
229 lines (206 loc) · 7.58 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
name: E2E Test Binaries
on:
push:
branches: ['**']
pull_request:
branches: ['**']
workflow_dispatch:
jobs:
test:
name: Test ${{ matrix.platform }} ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
max-parallel: 6
matrix:
include:
- os: windows-latest
platform: win
arch: x64
output: flashforge-webui-win-x64.exe
can_execute: true
- os: macos-15-intel
platform: mac
arch: x64
output: flashforge-webui-macos-x64.bin
can_execute: true
- os: macos-latest
platform: mac
arch: arm64
output: flashforge-webui-macos-arm64.bin
can_execute: true
- os: ubuntu-latest
platform: linux
arch: x64
output: flashforge-webui-linux-x64.bin
can_execute: true
- os: ubuntu-24.04-arm
platform: linux
arch: arm64
output: flashforge-webui-linux-arm64.bin
can_execute: true
- os: ubuntu-latest
platform: linux
arch: armv7
output: flashforge-webui-linux-armv7.bin
can_execute: false
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- name: Cache pkg fetch
uses: actions/cache@v4
with:
path: ~/.pkg-cache
key: ${{ runner.os }}-pkg-${{ hashFiles('package.json') }}
restore-keys: |
${{ runner.os }}-pkg-
- name: Configure GitHub Packages
shell: bash
run: |
echo "@ghosttypes:registry=https://npm.pkg.github.com" >> .npmrc
echo "@parallel-7:registry=https://npm.pkg.github.com" >> .npmrc
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> .npmrc
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install dependencies
run: npm ci
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Pre-download ARMv7 Node.js Binary
if: matrix.arch == 'armv7'
run: |
mkdir -p ~/.pkg-cache/v3.5
curl -L -o ~/.pkg-cache/v3.5/fetched-v20.18.0-linuxstatic-armv7 \
https://github.com/yao-pkg/pkg-binaries/releases/download/node20/node-v20.18.0-linuxstatic-armv7
chmod +x ~/.pkg-cache/v3.5/fetched-v20.18.0-linuxstatic-armv7
- name: Build application
shell: bash
run: |
npm run build
if [[ "${{ matrix.platform }}" == "win" ]]; then
npx @yao-pkg/pkg . --targets node20-win-${{ matrix.arch }} --output dist/${{ matrix.output }}
elif [[ "${{ matrix.platform }}" == "mac" ]]; then
npx @yao-pkg/pkg . --targets node20-macos-${{ matrix.arch }} --output dist/${{ matrix.output }}
elif [[ "${{ matrix.arch }}" == "armv7" ]]; then
npx @yao-pkg/pkg . --targets node20-linuxstatic-armv7 --output dist/${{ matrix.output }}
else
npx @yao-pkg/pkg . --targets node20-linux-${{ matrix.arch }} --output dist/${{ matrix.output }}
fi
- name: Verify binary size
shell: bash
run: |
if [[ "${{ runner.os }}" == "macOS" ]] || [[ "${{ runner.os }}" == "macos-latest" ]] || [[ "${{ runner.os }}" == "macos-15-intel" ]]; then
size=$(stat -f%z "dist/${{ matrix.output }}")
elif [[ "${{ runner.os }}" == "Windows" ]]; then
size=$(powershell -Command "(Get-Item 'dist/${{ matrix.output }}').length")
else
size=$(stat -c%s "dist/${{ matrix.output }}")
fi
if [ $size -lt 40000000 ]; then
echo "::error::Binary size ($size bytes) is too small - assets may not be embedded"
exit 1
fi
echo "✓ Binary size: $size bytes"
- name: Start binary in background
if: matrix.can_execute == true
shell: bash
run: |
if [[ "${{ runner.os }}" == "Windows" ]]; then
powershell -Command "Start-Process -FilePath '.\dist\${{ matrix.output }}' -ArgumentList '--no-printers' -WindowStyle Hidden"
else
chmod +x dist/${{ matrix.output }}
./dist/${{ matrix.output }} --no-printers > startup.log 2>&1 &
echo $! > binary.pid
fi
- name: Wait for startup
if: matrix.can_execute == true
shell: bash
run: sleep 15
- name: Validate startup
if: matrix.can_execute == true
shell: bash
run: |
if [[ "${{ runner.os }}" != "Windows" ]]; then
if grep -iE "\[Error\]|\[Fatal\]|exception" startup.log; then
echo "::error::Errors detected during startup"
cat startup.log
exit 1
fi
if ! grep -q "\[Ready\] FlashForgeWebUI is ready" startup.log; then
echo "::error::Startup did not complete - missing ready marker"
tail -n 50 startup.log
exit 1
fi
echo "✓ Startup successful"
fi
- name: Test API endpoints
if: matrix.can_execute == true
shell: bash
run: |
response=$(curl -s http://localhost:3000/api/auth/status)
if ! echo "$response" | jq '.' > /dev/null 2>&1; then
echo "::error::Auth status API returned invalid JSON: $response"
exit 1
fi
if ! curl -s http://localhost:3000/ | grep -q "FlashForge Web UI"; then
echo "::error::Failed to serve index.html"
exit 1
fi
login_response=$(curl -s -X POST http://localhost:3000/api/auth/login \
-H "Content-Type: application/json" \
-d '{"password":"changeme"}')
success=$(echo "$login_response" | jq -r '.success')
if [ "$success" != "true" ]; then
echo "::error::Login API failed: $login_response"
exit 1
fi
echo "✓ All API tests passed"
- name: Stop binary
if: matrix.can_execute == true
shell: bash
run: |
if [[ "${{ runner.os }}" == "Windows" ]]; then
taskkill /F /IM "${{ matrix.output }}" 2>/dev/null || true
else
if [ -f binary.pid ]; then
kill -TERM $(cat binary.pid) || true
rm binary.pid
fi
pkill -TERM -f "${{ matrix.output }}" || true
fi
sleep 3
- name: Verify cleanup
if: matrix.can_execute == true
shell: bash
run: |
if [[ "${{ runner.os }}" != "Windows" ]]; then
if pgrep -f "${{ matrix.output }}"; then
echo "::error::Binary left zombie processes"
exit 1
fi
fi
echo "✓ Cleanup successful"
- name: Upload test binary
uses: actions/upload-artifact@v4
if: always()
with:
name: ${{ matrix.output }}
path: dist/${{ matrix.output }}
retention-days: 7
compression-level: 6
- name: Generate summary
if: always()
shell: bash
run: |
echo "## ${{ matrix.platform }} ${{ matrix.arch }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [[ "${{ job.status }}" == "success" ]]; then
echo "✅ All tests passed" >> $GITHUB_STEP_SUMMARY
else
echo "❌ Tests failed" >> $GITHUB_STEP_SUMMARY
fi