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 : " main"
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 || 'main' }}
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 || 'main' }}
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 : Install Docker
172+ run : |
173+ # Install Docker Desktop for Mac
174+ brew install --cask docker
175+ # Start Docker Desktop
176+ open -a Docker
177+ # Wait for Docker to be ready (with longer timeout)
178+ echo "Waiting for Docker to start..."
179+ timeout 120 bash -c 'until docker info >/dev/null 2>&1; do echo "Waiting for Docker..."; sleep 5; done'
180+ echo "Docker is ready!"
181+
182+ - name : Install Docker Compose
183+ run : |
184+ # Install docker-compose via pip (more reliable than brew on macOS runners)
185+ python3 -m pip install docker-compose
186+
187+ - name : Docker info
188+ run : |
189+ docker --version
190+ docker info
191+ docker ps
192+
193+ - name : Run regtest setup
194+ working-directory : bitkit-e2e-tests
195+ run : |
196+ cd docker
197+ mkdir lnd && chmod 777 lnd
198+ docker compose pull --quiet
199+ docker compose up -d
200+
201+ - name : Wait for electrum server and LND
202+ working-directory : bitkit-e2e-tests
203+ timeout-minutes : 10
204+ run : |
205+ while ! nc -z '127.0.0.1' 60001; do sleep 1; done
206+ sudo bash -c "while [ ! -f docker/lnd/data/chain/bitcoin/regtest/admin.macaroon ]; do sleep 1; done"
207+ sudo chmod -R 777 docker/lnd
208+
209+ - name : Setup iOS Simulator
210+ run : |
211+ # Boot iOS Simulator
212+ xcrun simctl boot "iPhone 17" || true
213+ xcrun simctl bootstatus "iPhone 17" -b
214+
215+ # Install the app
216+ xcrun simctl install "iPhone 17" bitkit-e2e-tests/aut/bitkit.app
217+
218+ - name : Run E2E Tests (${{ matrix.shard.name }})
219+ run : |
220+ cd bitkit-e2e-tests
221+
222+ # Setup logging
223+ LOGDIR="./artifacts"
224+ mkdir -p "$LOGDIR"
225+ LOGFILE="$LOGDIR/simulator.log"
226+
227+ # Start simulator logging
228+ xcrun simctl spawn "iPhone 17" log stream --predicate 'process == "Bitkit"' --style compact > "$LOGFILE" &
229+ LOG_PID=$!
230+
231+ # Setup port forwarding for regtest and LND
232+ xcrun simctl spawn "iPhone 17" launchctl load -w /System/Library/LaunchDaemons/com.apple.usbmuxd.plist || true
233+
234+ # Cleanup function
235+ cleanup() {
236+ kill "$LOG_PID" 2>/dev/null || true
237+ wait "$LOG_PID" 2>/dev/null || true
238+ }
239+ trap cleanup EXIT INT TERM
240+
241+ # Pass everything through to WDIO/Mocha
242+ npm run e2e:ios -- "$@"
243+ env :
244+ RECORD_VIDEO : true
245+
246+ - name : Upload E2E Artifacts (${{ matrix.shard.name }})
247+ if : failure()
248+ uses : actions/upload-artifact@v4
249+ with :
250+ name : e2e-artifacts_${{ matrix.shard.name }}_${{ github.run_number }}
251+ path : bitkit-e2e-tests/artifacts/
252+
253+ - name : Dump docker logs on failure (${{ matrix.shard.name }})
254+ if : failure()
255+ uses : jwalton/gh-docker-logs@v2
256+
0 commit comments