Skip to content

Commit ce618c6

Browse files
test: create initial workflow for swiftui test runner
1 parent 85d3ff5 commit ce618c6

File tree

2 files changed

+112
-0
lines changed

2 files changed

+112
-0
lines changed

.github/workflows/swiftui-auth.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: SwiftUI Auth
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths:
7+
- '.github/workflows/swiftui-auth.yml'
8+
- 'samples/swiftui/**'
9+
- 'FirebaseSwiftUI/**'
10+
- 'Package.swift'
11+
pull_request:
12+
branches: [ main ]
13+
paths:
14+
- '.github/workflows/swiftui-auth.yml'
15+
- 'samples/swiftui/**'
16+
- 'FirebaseSwiftUI/**'
17+
- 'Package.swift'
18+
19+
workflow_dispatch:
20+
21+
jobs:
22+
swiftui-auth:
23+
runs-on: macOS-latest
24+
timeout-minutes: 30
25+
steps:
26+
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
27+
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a
28+
name: Install Node.js 20
29+
with:
30+
node-version: '20'
31+
- uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b
32+
with:
33+
distribution: 'temurin'
34+
java-version: '17'
35+
- name: Install Firebase
36+
run: |
37+
sudo npm i -g firebase-tools
38+
- name: Start Firebase Emulator
39+
run: |
40+
sudo chown -R 501:20 && cd ./samples/swiftui/FirebaseSwiftUIExample/FirebaseSwiftUIExample && ./start-firebase-emulator.sh
41+
- name: Select Xcode version
42+
run: |
43+
sudo xcode-select -switch /Applications/Xcode_16.1.app/Contents/Developer
44+
- name: Disable iOS Simulator hardware keyboard
45+
# needed for SecureFields otherwise the UI flow tests will fail
46+
run: |
47+
defaults delete com.apple.iphonesimulator ConnectHardwareKeyboard || true
48+
- name: Run Integration Tests
49+
run: |
50+
cd ./samples/swiftui/FirebaseSwiftUIExample/FirebaseSwiftUIExample
51+
xcodebuild test -scheme FirebaseSwiftUIExampleTests -destination 'platform=iOS Simulator,name=iPhone 16 Plus' -enableCodeCoverage YES
52+
- name: Run View UI Tests
53+
run: |
54+
cd ./samples/swiftui/FirebaseSwiftUIExample/FirebaseSwiftUIExample
55+
xcodebuild test -scheme FirebaseSwiftUIExampleUITests -destination 'platform=iOS Simulator,name=iPhone 16 Plus' -enableCodeCoverage YES
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
if ! [ -x "$(command -v firebase)" ]; then
3+
echo "❌ Firebase tools CLI is missing."
4+
exit 1
5+
fi
6+
7+
if ! [ -x "$(command -v node)" ]; then
8+
echo "❌ Node.js is missing."
9+
exit 1
10+
fi
11+
12+
if ! [ -x "$(command -v npm)" ]; then
13+
echo "❌ NPM is missing."
14+
exit 1
15+
fi
16+
17+
EMU_START_COMMAND="firebase emulators:start --only auth --project flutterfire-e2e-tests"
18+
19+
MAX_RETRIES=3
20+
MAX_CHECKATTEMPTS=60
21+
CHECKATTEMPTS_WAIT=1
22+
23+
RETRIES=1
24+
while [ $RETRIES -le $MAX_RETRIES ]; do
25+
26+
if [[ -z "${CI}" ]]; then
27+
echo "Starting Firebase Emulator in foreground."
28+
$EMU_START_COMMAND
29+
exit 0
30+
else
31+
echo "Starting Firebase Emulator in background."
32+
$EMU_START_COMMAND &
33+
CHECKATTEMPTS=1
34+
while [ $CHECKATTEMPTS -le $MAX_CHECKATTEMPTS ]; do
35+
sleep $CHECKATTEMPTS_WAIT
36+
if curl --output /dev/null --silent --fail http://localhost:8080; then
37+
# Check again since it can exit before the emulator is ready.
38+
sleep 15
39+
if curl --output /dev/null --silent --fail http://localhost:8080; then
40+
echo "Firebase Emulator is online!"
41+
exit 0
42+
else
43+
echo "❌ Firebase Emulator exited after startup."
44+
exit 1
45+
fi
46+
fi
47+
echo "Waiting for Firebase Emulator to come online, check $CHECKATTEMPTS of $MAX_CHECKATTEMPTS..."
48+
((CHECKATTEMPTS = CHECKATTEMPTS + 1))
49+
done
50+
fi
51+
52+
echo "Firebase Emulator did not come online in $MAX_CHECKATTEMPTS checks. Try $RETRIES of $MAX_RETRIES."
53+
((RETRIES = RETRIES + 1))
54+
55+
done
56+
echo "Firebase Emulator did not come online after $MAX_RETRIES attempts."
57+
exit 1

0 commit comments

Comments
 (0)