Skip to content

Commit 0cd5cfb

Browse files
committed
workflow changes moving templates under the same job
1 parent b00ac3e commit 0cd5cfb

File tree

2 files changed

+209
-19
lines changed

2 files changed

+209
-19
lines changed

.github/workflows/ios-build-and-test.yml

Lines changed: 187 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -243,23 +243,191 @@ jobs:
243243
echo "❌ **Build Status:** Failed" >> $GITHUB_STEP_SUMMARY
244244
fi
245245
246-
install-ios:
247-
name: Install iOS App
246+
install-and-test-ios:
247+
name: Install and Test iOS App
248248
needs: build-ios
249-
uses: ./.github/workflows/ios-install-template.yml
250-
with:
251-
artifact_name: ${{ needs.build-ios.outputs.artifact_name }}
252-
ios_version: ${{ inputs.platform-version || '26.0' }}
253-
device_name: ${{ inputs.device-name || 'iPhone 16' }}
254-
255-
test-ios:
256-
needs: install-ios
257-
uses: ./.github/workflows/ios-testing-template.yml
258-
with:
259-
device_uuid: ${{ needs.install-ios.outputs.device_udid }}
260-
ios_version: ${{ inputs.platform-version || '26.0' }}
261-
device_name: ${{ inputs.device-name || 'iPhone 16' }}
262-
node_version: '20'
263-
appium_version: '3.1.1'
264-
secrets:
265-
APP_BUNDLE_ID: com.softwareone.marketplaceMobile
249+
runs-on: macos-latest
250+
timeout-minutes: 60
251+
252+
env:
253+
PLATFORM_VERSION: ${{ inputs.platform-version || '26.0' }}
254+
DEVICE_NAME: ${{ inputs.device-name || 'iPhone 16' }}
255+
256+
steps:
257+
- name: Checkout code
258+
uses: actions/checkout@v4
259+
260+
# === INSTALL PHASE (from ios-install-template.yml) ===
261+
- name: Download iOS app from artifact
262+
uses: actions/download-artifact@v4
263+
with:
264+
name: ${{ needs.build-ios.outputs.artifact_name }}
265+
path: ./downloaded-app
266+
267+
- name: Unzip app bundle
268+
run: |
269+
echo "📦 Extracting app bundle..."
270+
271+
if [ -f "./downloaded-app/app_bundle.zip" ]; then
272+
unzip "./downloaded-app/app_bundle.zip" -d ./downloaded-app/
273+
echo "✅ App bundle extracted"
274+
else
275+
echo "❌ ERROR: app_bundle.zip not found"
276+
ls -la ./downloaded-app/
277+
exit 1
278+
fi
279+
280+
- name: Verify app bundle
281+
id: verify-app
282+
run: |
283+
echo "🔍 Verifying .app bundle..."
284+
APP_PATH=$(find ./downloaded-app -name "*.app" -type d -maxdepth 2 | head -n 1)
285+
286+
if [ -z "$APP_PATH" ]; then
287+
echo "❌ ERROR: .app bundle not found"
288+
find ./downloaded-app -name "*.app" -type d
289+
exit 1
290+
fi
291+
292+
BUNDLE_ID=$(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "$APP_PATH/Info.plist")
293+
echo "📱 Found app: $(basename "$APP_PATH")"
294+
echo "📋 Bundle ID: $BUNDLE_ID"
295+
296+
echo "APP_PATH=$APP_PATH" >> $GITHUB_ENV
297+
echo "BUNDLE_ID=$BUNDLE_ID" >> $GITHUB_ENV
298+
299+
- name: Find and boot iOS Simulator
300+
id: boot-simulator
301+
run: |
302+
echo "🔍 Looking for: ${{ env.DEVICE_NAME }} with iOS ${{ env.PLATFORM_VERSION }}"
303+
304+
UDID=$(xcrun simctl list devices available -j | python3 -c "
305+
import json, sys
306+
data = json.load(sys.stdin)
307+
target_device = '${{ env.DEVICE_NAME }}'
308+
target_version = '${{ env.PLATFORM_VERSION }}'
309+
formatted_version = 'iOS-' + target_version.replace(' ', '-').replace('.', '-')
310+
311+
for runtime_key, devices in data.get('devices', {}).items():
312+
if formatted_version in runtime_key:
313+
for device in devices:
314+
if device.get('name') == target_device and device.get('isAvailable', False):
315+
print(device['udid'])
316+
sys.exit(0)
317+
sys.exit(1)
318+
" 2>/dev/null)
319+
320+
if [ -z "$UDID" ]; then
321+
echo "❌ ERROR: Could not find ${{ env.DEVICE_NAME }} with iOS ${{ env.PLATFORM_VERSION }}"
322+
xcrun simctl list devices available
323+
exit 1
324+
fi
325+
326+
echo "DEVICE_UDID=$UDID" >> $GITHUB_ENV
327+
echo "✅ Found simulator: ${{ env.DEVICE_NAME }} ($UDID)"
328+
329+
# Boot simulator
330+
echo "🚀 Booting simulator..."
331+
xcrun simctl boot $UDID 2>/dev/null || echo "Already booted"
332+
333+
# Wait for boot (simple approach)
334+
echo "⏳ Waiting for simulator to boot..."
335+
for i in $(seq 1 120); do
336+
if xcrun simctl list devices | grep "$UDID" | grep -q "(Booted)"; then
337+
echo "✅ Simulator booted after ${i} seconds"
338+
break
339+
fi
340+
if [ $i -eq 120 ]; then
341+
echo "❌ ERROR: Simulator failed to boot"
342+
exit 1
343+
fi
344+
sleep 1
345+
done
346+
347+
- name: Install and launch app
348+
run: |
349+
echo "📲 Installing app on simulator..."
350+
xcrun simctl install "${{ env.DEVICE_UDID }}" "${{ env.APP_PATH }}"
351+
352+
echo "🚀 Launching app..."
353+
xcrun simctl launch "${{ env.DEVICE_UDID }}" "${{ env.BUNDLE_ID }}"
354+
sleep 5
355+
356+
echo "✅ App installed and ready for testing"
357+
358+
# === TEST PHASE (from ios-testing-template.yml) ===
359+
- name: Setup Node.js
360+
uses: actions/setup-node@v4
361+
with:
362+
node-version: '20'
363+
cache: 'npm'
364+
cache-dependency-path: app/package-lock.json
365+
366+
- name: Install dependencies
367+
run: npm ci
368+
working-directory: ./app
369+
370+
- name: Install Appium
371+
run: |
372+
npm install -g appium@3.1.1
373+
appium driver install xcuitest
374+
appium --version
375+
376+
- name: Start Appium Server
377+
run: |
378+
echo "Starting Appium server..."
379+
appium --log-level info --log appium.log &
380+
APPIUM_PID=$!
381+
echo ${APPIUM_PID} > appium.pid
382+
383+
# Wait for Appium to start
384+
for i in $(seq 1 60); do
385+
if curl -s "http://localhost:4723/status" > /dev/null; then
386+
echo "✅ Appium server ready"
387+
break
388+
fi
389+
if [ $i -eq 60 ]; then
390+
echo "❌ ERROR: Appium failed to start"
391+
cat appium.log
392+
exit 1
393+
fi
394+
sleep 1
395+
done
396+
397+
- name: Run Appium Tests
398+
env:
399+
APPIUM_HOST: localhost
400+
APPIUM_PORT: 4723
401+
DEVICE_UDID: ${{ env.DEVICE_UDID }}
402+
DEVICE_NAME: ${{ env.DEVICE_NAME }}
403+
PLATFORM_VERSION: ${{ env.PLATFORM_VERSION }}
404+
APP_BUNDLE_ID: ${{ env.BUNDLE_ID }}
405+
AUTOMATION_NAME: XCUITest
406+
PLATFORM_NAME: iOS
407+
run: |
408+
echo "🧪 Running Appium tests..."
409+
echo "Device: ${{ env.DEVICE_NAME }} (${{ env.DEVICE_UDID }})"
410+
echo "App: ${{ env.BUNDLE_ID }}"
411+
412+
npm test -- --testNamePattern="Appium"
413+
working-directory: ./app
414+
415+
- name: Stop Appium Server
416+
if: always()
417+
run: |
418+
if [ -f appium.pid ]; then
419+
APPIUM_PID=$(cat appium.pid)
420+
kill $APPIUM_PID || true
421+
echo "Appium server stopped"
422+
fi
423+
424+
- name: Upload test results
425+
if: always()
426+
uses: actions/upload-artifact@v4
427+
with:
428+
name: ios-test-results-${{ github.sha }}
429+
path: |
430+
app/test-results/
431+
appium.log
432+
retention-days: 7
433+
if-no-files-found: warn

.github/workflows/ios-install-template.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,28 @@ jobs:
8585
file "./downloaded-app/app_bundle.zip"
8686
echo "File contents (first 100 bytes as hex):"
8787
xxd -l 100 "./downloaded-app/app_bundle.zip" || hexdump -C "./downloaded-app/app_bundle.zip" | head -10
88+
89+
# Check for common Azure blob storage errors
90+
if grep -q "PublicAccessNotPermitted" "./downloaded-app/app_bundle.zip" 2>/dev/null; then
91+
echo ""
92+
echo "🔍 DIAGNOSIS: Azure blob storage access denied"
93+
echo "The URL appears to be an Azure blob storage link that requires authentication."
94+
echo "Possible issues:"
95+
echo " 1. SAS token has expired"
96+
echo " 2. URL is not publicly accessible"
97+
echo " 3. URL requires different authentication"
98+
echo ""
99+
echo "💡 SOLUTION: Please check that:"
100+
echo " - The blob storage URL is publicly accessible, OR"
101+
echo " - The SAS token in the URL is still valid, OR"
102+
echo " - Use a different download method that supports authentication"
103+
elif grep -q "<Error>" "./downloaded-app/app_bundle.zip" 2>/dev/null; then
104+
echo ""
105+
echo "🔍 DIAGNOSIS: Server returned an error response instead of the file"
106+
echo "The server responded with an XML error message instead of the ZIP file."
107+
echo "Please check the URL and ensure it points directly to the downloadable file."
108+
fi
109+
88110
exit 1
89111
else
90112
echo "✅ ZIP file validation successful"

0 commit comments

Comments
 (0)