Skip to content

Commit

Permalink
ci(e2e): fix e2e and add recent Flutter versions (#2486)
Browse files Browse the repository at this point in the history
  • Loading branch information
felangel authored Jan 3, 2025
1 parent 3a9d3b4 commit 4cc3f48
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 28 deletions.
19 changes: 15 additions & 4 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ on:

env:
SHOREBIRD_TOKEN: ${{ secrets.SHOREBIRD_TOKEN }}
FLUTTER_VERSION: 3.24.4
FLUTTER_VERSION: 3.27.1

jobs:
patch:
strategy:
fail-fast: false
matrix:
flutter-version: [3.24.1, 3.24.0, 3.22.3, 3.22.2, 3.19.6]
flutter-version: [3.27.1, 3.27.0, 3.24.5, 3.24.4, 3.24.3, 3.24.1, 3.24.0, 3.22.3, 3.22.2, 3.19.6]

runs-on: ubuntu-latest
timeout-minutes: 15
Expand Down Expand Up @@ -58,31 +58,42 @@ jobs:
flutter-version: ${{ matrix.flutter-version }}
cache: true

- name: 🚀 Enable KVM for Linux Runners
if: runner.os == 'Linux'
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: 🤖 AVD Cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-29
key: avd-29-${{ runner.os }}-${{ hashFiles('.github/workflows/e2e.yaml') }}

- name: 🤖 Cache AVD Snapshot
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
arch: x86_64
target: default
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
sdcard-path-or-size: 512M
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -no-snapshot
disable-animations: false
channel: canary
script: echo "Generated AVD Snapshot"

- name: 🧪 Run Patch E2E Tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
arch: x86_64
target: default
script: ./scripts/patch_e2e.sh ${{ matrix.flutter-version }}

cli:
Expand Down
42 changes: 25 additions & 17 deletions cspell.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,19 @@ version: "0.2"
ignorePaths:
["coverage", "bin/cache", "third_party", "build", "*.xcscheme", "fixtures"]
words:
- ANDROIDD
- Apks
- Azul
- Entra
- FLUSHALL
- LOCALAPPDATA
- NOAUTH
- Oltman
- PRNG
- RSAPKCS
- Retryable
- SIGSTOP
- USERPROFILE
- Unpatchable
- VCRUNTIME
- Verdana
- WRONGPASS
- aabs
- aapt
- aarch
- aars # Android Archive
- allprojects # From gradle files
- altool
- ANDROIDD
- apigee
- Apks
- appbundle
- archs
- armeabi
- Azul
- backboardd
- bintools
- bitcode
Expand All @@ -47,21 +33,29 @@ words:
- dyld
- dylib
- endtemplate
- Entra
- exitcode
- exportoptions
- felangel
- FLUSHALL
- genhtml
- genkey # From .github/workflows/e2e.yaml
- gradlew
- hotreload
- idevicesyslog
- iokit
- iphoneos
- keyalg # From .github/workflows/e2e.yaml
- keypass # From .github/workflows/e2e.yaml
- keysize # From .github/workflows/e2e.yaml
- keytool # From .github/workflows/e2e.yaml
- lerping
- libapp
- libflutter
- libimobiledevice
- libplist
- lldb
- LOCALAPPDATA
- logcat
- longpaths
- lproj
Expand All @@ -70,7 +64,9 @@ words:
- mocktail
- multioption
- noaudio # From .github dir, doesn't show up in "**" check?
- NOAUTH
- nserror
- Oltman
- orri # Arm64 instruction, Or Register with Immediate
- pana
- pkcs
Expand All @@ -79,6 +75,7 @@ words:
- pointycastle
- precache
- previewable
- PRNG
- propertylistserialization
- propertylistserialization
- pubspec
Expand All @@ -87,24 +84,35 @@ words:
- readlink
- reinit
- requirepass # From .github dir, doesn't show up in "**" check?
- Retryable
- RSAPKCS
- sdcard # From .github/workflows/e2e.yaml
- shorebirdtech
- sideload
- sideloadable
- sideloaded
- signup
- SIGSTOP
- storepass # From .github/workflows/e2e.yaml
- storyboardc
- subosito # From .github dir, doesn't show up in "**" check?
- swiftshader # From .github dir, doesn't show up in "**" check?
- sysroot
- temurin # From .github dir, doesn't show up in "**" check?
- udevadm # From .github/workflows/e2e.yaml
- udid # Unique Device Identifier
- unawaited
- unmockable
- Unpatchable
- unsets
- upvote
- usbmuxd
- USERPROFILE
- VCRUNTIME
- Verdana
- vmcode
- writeln
- WRONGPASS
- xcarchive
- xcarchives
- xcframework
Expand Down
25 changes: 18 additions & 7 deletions scripts/patch_e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ TEMP_DIR=$(mktemp -d -t 'shorebird workspace-XXXXX')
cd "$TEMP_DIR"

# Create a new empty flutter project
flutter create e2e_test --empty --platforms android
flutter create e2e_test --org com.example.e2e_test --empty --platforms android
cd e2e_test

# Replace the contents of "lib/main.dart" with a single print statement.
Expand All @@ -30,12 +30,23 @@ echo "void main() { print('hello world'); }" >lib/main.dart
# Initialize Shorebird
shorebird init --force -v

# Run Flutter & Shorebird doctor to ensure that the project is set up correctly.
flutter doctor --verbose
shorebird doctor --verbose

# Point to the development environment
echo "base_url: https://api-dev.shorebird.dev" >> shorebird.yaml
echo "base_url: https://api-dev.shorebird.dev" >>shorebird.yaml

# Extract the app_id from the "shorebird.yaml"
APP_ID=$(cat shorebird.yaml | grep 'app_id:' | awk '{print $2}')

# Create Debug Keystore
# Android Studio creates this keystore by default, but we need to create it manually for CI.
# See https://github.com/google/bundletool/blob/69c3e0947bab350fbe7cbd9af03a77b0204d6dc8/src/main/java/com/android/tools/build/bundletool/commands/BuildApksCommand.java
keytool -genkey -v -keystore ~/.android/debug.keystore -keyalg RSA \
-keysize 2048 -validity 10000 -alias AndroidDebugKey -storepass android -keypass android \
-dname "CN=Android Debug,O=Android,C=US"

# Create a new release on Android
shorebird release android --flutter-version=$FLUTTER_VERSION --split-debug-info=./build/symbols -v

Expand All @@ -46,7 +57,7 @@ while IFS= read line; do
echo "✅ 'hello world' was printed"
break
fi
done < <(shorebird preview --release-version 0.1.0+1 --app-id $APP_ID --platform android)
done < <(shorebird preview --release-version 0.1.0+1 --app-id $APP_ID --platform android -v)

# Replace lib/main.dart "hello world" to "hello shorebird"
sed -i 's/hello world/hello shorebird/g' lib/main.dart
Expand All @@ -55,20 +66,20 @@ echo "lib/main.dart is now:"
cat lib/main.dart

# Create a patch
shorebird patch android --split-debug-info=./build/symbols -v
shorebird patch android --release-version 0.1.0+1 --split-debug-info=./build/symbols -v

# Run the app on Android and ensure that the original print statement is printed.
while IFS= read line; do
if [[ "$line" == *"Patch 1 successfully"* ]]; then
# Kill the app so we can boot the patch
adb shell am force-stop com.example.e2e_test
adb shell am force-stop com.example.e2e_test.e2e_test
echo "✅ Patch 1 successfully installed"
break
fi
done < <(shorebird preview --release-version 0.1.0+1 --app-id $APP_ID --platform android)
done < <(shorebird preview --release-version 0.1.0+1 --app-id $APP_ID --platform android -v)

# Re-run the app, *not* using shorebird preview, as that installs the base release.
adb shell monkey -p com.example.e2e_test -c android.intent.category.LAUNCHER 1
adb shell monkey -p com.example.e2e_test.e2e_test -c android.intent.category.LAUNCHER 1

# Re-run the app on Android and ensure that the new print statement is printed,
# tailing adb logs and printing the last 10 seconds of logs in case the
Expand Down

0 comments on commit 4cc3f48

Please sign in to comment.