Skip to content

Commit 8da040c

Browse files
committed
WIP
1 parent 3f86328 commit 8da040c

File tree

9 files changed

+1691
-11
lines changed

9 files changed

+1691
-11
lines changed

.github/workflows/debug-docker.yml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: Debug Docker Setup
2+
3+
# on:
4+
# workflow_dispatch:
5+
# pull_request:
6+
7+
jobs:
8+
debug-docker:
9+
runs-on: macos-13
10+
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
15+
- name: Check system info
16+
run: |
17+
echo "=== System Information ==="
18+
uname -a
19+
sw_vers
20+
echo "=== Available commands ==="
21+
which brew
22+
which python3
23+
which docker || echo "Docker not found"
24+
25+
- name: Install Docker CLI only
26+
run: |
27+
echo "=== Installing Docker CLI (no GUI) ==="
28+
# Install just the Docker CLI, not the full Desktop app
29+
brew install docker
30+
echo "Docker CLI installed"
31+
32+
- name: Set up Docker
33+
uses: docker/setup-docker-action@v4
34+
id: docker-official
35+
continue-on-error: true
36+
with:
37+
install: false # We already installed it
38+
daemon-config: |
39+
{
40+
"experimental": false,
41+
"debug": true,
42+
"log-driver": "json-file",
43+
"log-opts": {
44+
"max-size": "10m",
45+
"max-file": "3"
46+
}
47+
}
48+
49+
# - name: Setup Docker Colima (Fallback)
50+
# uses: douglascamata/setup-docker-macos-action@v1-alpha
51+
# id: docker-colima
52+
# continue-on-error: true
53+
54+
- name: Check Docker setup results
55+
run: |
56+
echo "=== Docker Setup Results ==="
57+
echo "Official Docker action result: ${{ steps.docker-official.outcome }}"
58+
# echo "Colima action result: ${{ steps.docker-colima.outcome }}"
59+
60+
- name: Wait for Docker to start
61+
run: |
62+
echo "=== Waiting for Docker to start ==="
63+
# Use a for loop instead of timeout (macOS doesn't have timeout command)
64+
for i in {1..18}; do
65+
if docker info >/dev/null 2>&1; then
66+
echo "Docker is ready!"
67+
break
68+
fi
69+
echo "Waiting for Docker... ($(date)) (attempt $i/18)"
70+
sleep 10
71+
done
72+
73+
# Final check
74+
if ! docker info >/dev/null 2>&1; then
75+
echo "Docker failed to start after 3 minutes"
76+
exit 1
77+
fi
78+
79+
- name: Test Docker functionality
80+
run: |
81+
echo "=== Testing Docker ==="
82+
docker --version
83+
docker info
84+
docker ps
85+
echo "=== Testing Docker Compose V2 ==="
86+
docker compose version || echo "docker compose not found"
87+
88+
- name: Install Docker Compose V2
89+
run: |
90+
echo "=== Installing Docker Compose V2 ==="
91+
# Install Docker Compose V2 plugin via Homebrew
92+
brew install docker-compose
93+
echo "Docker Compose V2 installed"
94+
docker compose version
95+
96+
- name: Test simple Docker command
97+
run: |
98+
echo "=== Testing simple Docker command ==="
99+
docker run --rm hello-world
100+
echo "Docker test successful!"
101+
102+
- name: Test Docker Compose V2
103+
run: |
104+
echo "=== Testing Docker Compose V2 ==="
105+
mkdir -p test-compose
106+
cat > test-compose/docker-compose.yml << 'EOF'
107+
version: '3.8'
108+
services:
109+
test:
110+
image: hello-world
111+
command: echo "Docker Compose V2 test successful!"
112+
EOF
113+
cd test-compose
114+
docker compose up
115+
echo "Docker Compose V2 test successful!"
Lines changed: 256 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,256 @@
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

Comments
 (0)