ci: add android patch e2e test (#1471)
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
name: Patch E2E Tests
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
# At the end of every day
|
||||
- cron: "0 0 * * *"
|
||||
|
||||
jobs:
|
||||
android:
|
||||
runs-on: macos-latest
|
||||
|
||||
env:
|
||||
SHOREBIRD_TOKEN: ${{ secrets.SHOREBIRD_TOKEN }}
|
||||
SHOREBIRD_HOSTED_URL: https://api-dev.shorebird.dev
|
||||
|
||||
steps:
|
||||
- name: 📚 Git Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: 🖥️ Add Shorebird to PATH
|
||||
shell: bash
|
||||
run: echo "${GITHUB_WORKSPACE}/bin/" >> $GITHUB_PATH
|
||||
|
||||
- name: 🐦 Verify Shorebird Installation
|
||||
run: |
|
||||
if [[ $(shorebird --version) =~ "Engine • revision" ]]; then
|
||||
echo '✅ Shorebird CLI is installed!'
|
||||
else
|
||||
echo '❌ Shorebird CLI is not installed.'
|
||||
exit 1
|
||||
fi
|
||||
shell: bash
|
||||
|
||||
- name: ☕ Set up Java
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: "17"
|
||||
|
||||
- name: 🎯 Set up Flutter
|
||||
uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: stable
|
||||
flutter-version: 3.13.9
|
||||
cache: true
|
||||
|
||||
- name: 🤖 AVD Cache
|
||||
uses: actions/cache@v3
|
||||
id: avd-cache
|
||||
with:
|
||||
path: |
|
||||
~/.android/avd/*
|
||||
~/.android/adb*
|
||||
key: avd-29
|
||||
|
||||
- name: 🤖 Cache AVD Snapshot
|
||||
if: steps.avd-cache.outputs.cache-hit != 'true'
|
||||
uses: reactivecircus/android-emulator-runner@v2
|
||||
with:
|
||||
api-level: 29
|
||||
force-avd-creation: false
|
||||
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
|
||||
disable-animations: false
|
||||
script: echo "Generated AVD Snapshot"
|
||||
|
||||
- name: 🧪 Patch E2E Tests
|
||||
uses: reactivecircus/android-emulator-runner@v2
|
||||
with:
|
||||
api-level: 29
|
||||
script: ./scripts/patch_e2e.sh
|
||||
Executable
+74
@@ -0,0 +1,74 @@
|
||||
#!/bin/bash -ex
|
||||
|
||||
# This script tests the patching functionality of Shorebird.
|
||||
# It creates a new empty, flutter project, initializes Shorebird,
|
||||
# creates a new release, patches the release, and then ensures
|
||||
# that the patch was applied correctly.
|
||||
#
|
||||
# Pre-requisites:
|
||||
# - Flutter must be installed.
|
||||
# - Android SDK must be installed.
|
||||
# - ADB must be installed and be part of PATH.
|
||||
# - Android emulator must be running.
|
||||
# - Shorebird must be installed.
|
||||
#
|
||||
# Usage: ./patch_e2e.sh
|
||||
|
||||
TEMP_DIR=$(mktemp -d)
|
||||
cd $TEMP_DIR
|
||||
|
||||
# Create a new empty flutter project
|
||||
flutter create e2e_test --empty --platforms android
|
||||
cd e2e_test
|
||||
|
||||
# Replace the contents of "lib/main.dart" with a single print statement.
|
||||
echo "void main() { print('hello world'); }" >lib/main.dart
|
||||
|
||||
# Initialize Shorebird
|
||||
shorebird init --force -v
|
||||
|
||||
# Point to the development environment
|
||||
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 a new release on Android
|
||||
shorebird release android --force -v
|
||||
|
||||
# Run the app on Android and ensure that the print statement is printed.
|
||||
while IFS= read -r line; do
|
||||
if [[ "$line" == *"I flutter : hello world"* ]]; then
|
||||
adb kill-server
|
||||
echo "✅ 'hello world' was printed"
|
||||
break
|
||||
fi
|
||||
done < <(shorebird preview --release-version 0.1.0+1 --app-id $APP_ID --platform android)
|
||||
|
||||
# Replace lib/main.dart "hello world" to "hello shorebird"
|
||||
sed -i '' 's/hello world/hello shorebird/g' lib/main.dart
|
||||
|
||||
# Create a patch
|
||||
shorebird patch android --force -v
|
||||
|
||||
# Run the app on Android and ensure that the original print statement is printed.
|
||||
while IFS= read -r line; do
|
||||
if [[ "$line" == *"I flutter : hello world"* ]]; then
|
||||
sleep 5 # Wait for the patch to be installed.
|
||||
adb kill-server
|
||||
echo "✅ 'hello world' was printed"
|
||||
break
|
||||
fi
|
||||
done < <(shorebird preview --release-version 0.1.0+1 --app-id $APP_ID --platform android)
|
||||
|
||||
# Re-run the app on Android and ensure that the new print statement is printed.
|
||||
while IFS= read -r line; do
|
||||
if [[ "$line" == *"I flutter : hello shorebird"* ]]; then
|
||||
adb kill-server
|
||||
echo "✅ 'hello shorebird' was printed"
|
||||
break
|
||||
fi
|
||||
done < <(shorebird preview --release-version 0.1.0+1 --app-id $APP_ID --platform android)
|
||||
|
||||
echo "✅ All tests passed!"
|
||||
exit 0
|
||||
Reference in New Issue
Block a user