Skip to content

Commit 42c0242

Browse files
committed
test: add e2e test workflow
1 parent 3f86328 commit 42c0242

File tree

2 files changed

+252
-1
lines changed

2 files changed

+252
-1
lines changed

.github/workflows/e2e-tests.yml

Lines changed: 251 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,251 @@
1+
name: e2e-tests
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
e2e_branch:
7+
description: "Branch of synonymdev/bitkit-e2e-tests to use"
8+
required: false
9+
default: "ios-preparation"
10+
# push:
11+
# branches: [master]
12+
# pull_request:
13+
# branches: [master]
14+
15+
env:
16+
TERM: xterm-256color
17+
FORCE_COLOR: 1
18+
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.ref }}
21+
cancel-in-progress: true
22+
23+
jobs:
24+
build:
25+
runs-on: [self-hosted, macOS]
26+
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
31+
- name: System Information
32+
run: |
33+
echo "=== System Information ==="
34+
echo "macOS Version:"
35+
sw_vers
36+
echo ""
37+
echo "Xcode Version:"
38+
xcodebuild -version
39+
40+
- name: Setup iOS Simulator
41+
run: |
42+
# Set simulator name
43+
SIMULATOR_NAME="iPhone 17"
44+
echo "SIMULATOR_NAME=$SIMULATOR_NAME" >> $GITHUB_ENV
45+
46+
# Boot the iPhone 17 simulator if not already running
47+
if ! xcrun simctl list devices | grep "iPhone 17" | grep -q "Booted"; then
48+
echo "Booting $SIMULATOR_NAME..."
49+
xcrun simctl boot "$SIMULATOR_NAME"
50+
51+
# Wait for simulator to boot
52+
for i in {1..30}; do
53+
if xcrun simctl list devices | grep "$SIMULATOR_NAME" | grep -q "Booted"; then
54+
echo "$SIMULATOR_NAME is booted!"
55+
break
56+
fi
57+
echo "Waiting for $SIMULATOR_NAME boot... ($i/30)"
58+
sleep 5
59+
done
60+
else
61+
echo "$SIMULATOR_NAME is already booted!"
62+
fi
63+
64+
# Wait for simulator to be fully ready
65+
sleep 15
66+
67+
# Launch simulator app
68+
open -a Simulator
69+
70+
- name: Clean build environment
71+
run: |
72+
# Clean any existing build artifacts
73+
rm -rf DerivedData
74+
rm -rf ~/Library/Developer/Xcode/DerivedData
75+
76+
# Clean Swift Package Manager caches
77+
rm -rf ~/Library/Caches/org.swift.swiftpm
78+
rm -rf ~/Library/org.swift.swiftpm
79+
80+
# Reset package caches
81+
xcodebuild -resolvePackageDependencies -workspace Bitkit.xcodeproj/project.xcworkspace -scheme Bitkit
82+
83+
- name: Build iOS app
84+
env:
85+
GITHUB_ACTOR: ${{ github.actor }}
86+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87+
CHATWOOT_API: ${{ secrets.CHATWOOT_API }}
88+
E2E: true
89+
run: |
90+
echo "=== Building iOS app ==="
91+
92+
# Ensure iOS Simulator platform is available
93+
xcodebuild -downloadPlatform iOS || echo "iOS platform already installed"
94+
95+
# Build for iOS Simulator
96+
xcodebuild -workspace Bitkit.xcodeproj/project.xcworkspace \
97+
-scheme Bitkit \
98+
-configuration Debug \
99+
-destination "platform=iOS Simulator,name=$SIMULATOR_NAME" \
100+
-derivedDataPath DerivedData \
101+
-allowProvisioningUpdates \
102+
build
103+
104+
- name: Prepare app for E2E tests
105+
run: |
106+
# Copy the .app bundle to the expected location and name
107+
mkdir -p e2e-app
108+
cp -r DerivedData/Build/Products/Debug-iphonesimulator/Bitkit.app e2e-app/bitkit.app
109+
110+
- name: Upload iOS app
111+
uses: actions/upload-artifact@v4
112+
with:
113+
name: bitkit-e2e-ios_${{ github.run_number }}
114+
path: e2e-app/
115+
116+
e2e-tests:
117+
runs-on: [self-hosted, macOS]
118+
needs: build
119+
120+
strategy:
121+
fail-fast: false
122+
matrix:
123+
shard:
124+
# - { name: onboarding_backup_numberpad, grep: "@onboarding|@backup|@numberpad" }
125+
# - { name: onchain_boost_receive_widgets, grep: "@onchain|@boost|@receive|@widgets" }
126+
# - { name: settings, grep: "@settings" }
127+
# - { name: security, grep: "@security" }
128+
- { name: onboarding, grep: "@onboarding" }
129+
130+
name: e2e-tests - ${{ matrix.shard.name }}
131+
132+
steps:
133+
- name: Show selected E2E branch
134+
env:
135+
E2E_BRANCH: ${{ github.event.inputs.e2e_branch || 'ios-preparation' }}
136+
run: echo $E2E_BRANCH
137+
138+
- name: Clone E2E tests
139+
uses: actions/checkout@v4
140+
with:
141+
repository: synonymdev/bitkit-e2e-tests
142+
path: bitkit-e2e-tests
143+
ref: ${{ github.event.inputs.e2e_branch || 'ios-preparation' }}
144+
145+
- name: Download iOS app
146+
uses: actions/download-artifact@v4
147+
with:
148+
name: bitkit-e2e-ios_${{ github.run_number }}
149+
path: bitkit-e2e-tests/aut
150+
151+
- name: List iOS app directory contents
152+
run: ls -l bitkit-e2e-tests/aut
153+
154+
- name: Setup Node.js
155+
uses: actions/setup-node@v4
156+
with:
157+
node-version: 22
158+
159+
- name: Cache npm cache
160+
uses: actions/cache@v3
161+
with:
162+
path: ~/.npm
163+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
164+
restore-keys: |
165+
${{ runner.os }}-node-
166+
167+
- name: Install dependencies
168+
working-directory: bitkit-e2e-tests
169+
run: npm ci
170+
171+
- name: Docker info
172+
run: |
173+
docker --version
174+
docker info
175+
docker ps
176+
docker compose version
177+
178+
- name: Reset regtest environment
179+
working-directory: bitkit-e2e-tests
180+
continue-on-error: true
181+
timeout-minutes: 10
182+
run: |
183+
cd docker && docker compose --verbose down -v -t 300
184+
185+
- name: Run regtest setup
186+
working-directory: bitkit-e2e-tests
187+
run: |
188+
cd docker
189+
mkdir lnd && chmod 777 lnd
190+
docker compose --verbose up --force-recreate -d
191+
192+
- name: Wait for electrum server
193+
working-directory: bitkit-e2e-tests
194+
timeout-minutes: 10
195+
run: |
196+
echo "Waiting for Electrum server..."
197+
while ! nc -z '127.0.0.1' 60001; do
198+
echo "Electrum server not ready, waiting..."
199+
sleep 5
200+
done
201+
echo "Electrum server is ready!"
202+
203+
- name: Setup iOS Simulator
204+
run: |
205+
# Boot iOS Simulator
206+
xcrun simctl boot "iPhone 17" || true
207+
xcrun simctl bootstatus "iPhone 17" -b
208+
209+
# Install the app
210+
xcrun simctl install "iPhone 17" bitkit-e2e-tests/aut/bitkit.app
211+
212+
- name: Run E2E Tests (${{ matrix.shard.name }})
213+
run: |
214+
cd bitkit-e2e-tests
215+
216+
# Setup logging
217+
LOGDIR="./artifacts"
218+
mkdir -p "$LOGDIR"
219+
LOGFILE="$LOGDIR/simulator.log"
220+
221+
# Start simulator logging
222+
xcrun simctl spawn "iPhone 17" log stream --predicate 'process == "Bitkit"' --style compact > "$LOGFILE" &
223+
LOG_PID=$!
224+
225+
# Setup port forwarding for regtest and LND
226+
xcrun simctl spawn "iPhone 17" launchctl load -w /System/Library/LaunchDaemons/com.apple.usbmuxd.plist || true
227+
228+
# Cleanup function
229+
cleanup() {
230+
kill "$LOG_PID" 2>/dev/null || true
231+
wait "$LOG_PID" 2>/dev/null || true
232+
}
233+
trap cleanup EXIT INT TERM
234+
235+
# Pass everything through to WDIO/Mocha
236+
npm run e2e:ios -- "$@"
237+
env:
238+
RECORD_VIDEO: true
239+
240+
- name: Upload E2E Artifacts (${{ matrix.shard.name }})
241+
if: failure()
242+
uses: actions/upload-artifact@v4
243+
with:
244+
name: e2e-artifacts_${{ matrix.shard.name }}_${{ github.run_number }}
245+
path: bitkit-e2e-tests/artifacts/
246+
247+
- name: Cleanup Docker containers
248+
if: always()
249+
working-directory: bitkit-e2e-tests
250+
run: |
251+
cd docker && docker compose down -v || true

.github/workflows/ios-tests.yml renamed to .github/workflows/unit-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: iOS Tests
1+
name: unit-tests
22

33
on:
44
push:

0 commit comments

Comments
 (0)