DEVICE_LIST #133
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: flutter drive | |
on: [push, pull_request] | |
jobs: | |
drive: | |
strategy: | |
matrix: | |
devices: | |
- "iPhone 12" | |
# - "iPad Air (5th generation)" | |
fail-fast: false | |
runs-on: macOS-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Set latest Xcode version | |
run: | | |
echo "Available Xcode versions:" | |
XCODE_PATH=$(ls /Applications | grep Xcode | sort -V | tail -n 1) | |
echo "Selected Xcode version: $XCODE_PATH" | |
sudo xcode-select -switch /Applications/$XCODE_PATH/Contents/Developer | |
# - name: List devices | |
# run: xcrun simctl list devices | grep -v "Unavailable" | grep -v "unavailable" | |
- name: Set environment variable | |
run: echo "DEVICE_LIST=$(xcrun simctl list devices | grep -v 'Unavailable' | grep -v 'unavailable' | sed -E 's/ \(([A-Z0-9\-]+)\) / -- (\1) /g')" >> $GITHUB_ENV | |
- name: "Install flutter" | |
uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: '3.10.3' | |
channel: 'stable' | |
cache: true | |
cache-key: flutter-3.10.3 | |
cache-path: ${{ runner.tool_cache }}/flutter-3.10.3 | |
- name: Cache Dart SDK | |
uses: actions/cache@v2 | |
with: | |
path: ~/.pub-cache | |
key: ${{ runner.os }}-dart-${{ hashFiles('**/pubspec.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-dart- | |
- name: flutter pub get | |
run: flutter pub get | |
- name: Check CocoaPods installation | |
run: | | |
if ! command -v pod &> /dev/null | |
then | |
sudo gem install cocoapods | |
fi | |
- name: Cache Pod | |
uses: actions/cache@v2 | |
with: | |
path: ios/Pods | |
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }} | |
restore-keys: | | |
${{ runner.os }}-pods- | |
- name: Install Pods | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: cd ios && pod install | |
- name: "Start Simulator" | |
# UUID=$(xcrun simctl list devices | grep -v "Unavailable" | grep -v "unavailable" | sed -E 's/ \(([A-Z0-9\-]+)\) / -- (\1) /g' | grep "${{ matrix.devices }} -- " | awk -F '[()]' '{print $(NF-3)}') | |
run: | | |
UUID=$($DEVICE_LIST | grep "${{ matrix.devices }} -- " | awk -F '[()]' '{print $(NF-3)}') | |
echo $UUID | |
echo "UUID=$UUID" >> $GITHUB_ENV | |
xcrun simctl boot $UUID | |
- name: "Wait for Simulator to boot" | |
run: | | |
MAX_TRIES=30 | |
try_count=0 | |
until xcrun simctl list devices | grep $UUID | grep "Booted" || [[ "$try_count" -eq "$MAX_TRIES" ]]; do | |
echo "Waiting for Simulator to boot ($try_count/$MAX_TRIES)..." | |
try_count=$((try_count + 1)) | |
sleep 5 | |
done | |
if [[ "$try_count" -eq "$MAX_TRIES" ]]; then | |
echo "Simulator failed to boot in time!" | |
exit 1 | |
fi | |
- name: "Run Flutter Driver tests" | |
run: flutter drive --target=test_driver/app.dart -d $UUID --observatory-port=9200 | |
# run: sh flutter_drive.sh $UUID | |
# - name: "Shutdown Simulator" | |
# if: always() | |
# run: xcrun simctl shutdown $UUID |