From d411266fed1bea42b6d665dc32f4998c2a1dd68d Mon Sep 17 00:00:00 2001 From: Tsubasa SEKIGUCHI Date: Fri, 11 Jul 2025 04:02:59 +0900 Subject: [PATCH 01/10] =?UTF-8?q?Android=E5=90=91=E3=81=91E2E=E3=83=86?= =?UTF-8?q?=E3=82=B9=E3=83=88=E6=BA=96=E5=82=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/android_e2e.yml | 161 ++++++++++++++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 .github/workflows/android_e2e.yml diff --git a/.github/workflows/android_e2e.yml b/.github/workflows/android_e2e.yml new file mode 100644 index 0000000000..3aa1e16b3c --- /dev/null +++ b/.github/workflows/android_e2e.yml @@ -0,0 +1,161 @@ +name: Android E2E + +on: + pull_request: + +env: + TZ: "Asia/Tokyo" + +# 並列実行の制御 +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + e2e: + runs-on: ubuntu-latest + timeout-minutes: 45 # タイムアウト設定 + + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + ssh-key: ${{ secrets.FONTS_SSH_KEY }} + + - uses: pnpm/action-setup@v4 + with: + version: 10 + + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: "pnpm" + + - uses: actions/setup-java@v4 + with: + distribution: "temurin" + java-version: "21" + + - name: Install dependencies + run: pnpm i + + - name: Restore .env.local + shell: bash + run: echo "$DOTENV_LOCAL" | tr -d '\r' > ./.env.local + env: + DOTENV_LOCAL: ${{ secrets.DOTENV_LOCAL }} + + - name: Restore google-services.json + shell: bash + run: echo "$GOOGLE_SERVICES_JSON" | tr -d '\r' > ./android/app/src/dev/google-services.json + env: + GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }} + + - name: Restore play-store-credentials.json + shell: bash + run: echo "$PLAY_STORE_CREDENTIALS_JSON" | tr -d '\r' > ./android/play-store-credentials.json + env: + PLAY_STORE_CREDENTIALS_JSON: ${{ secrets.PLAY_STORE_CREDENTIALS_JSON }} + + - name: Restore release.keystore + shell: bash + run: echo "${{ secrets.RELEASE_KEYSTORE }}" | base64 --decode > ./android/app/release.keystore + env: + RELEASE_KEYSTORE: ${{ secrets.RELEASE_KEYSTORE }} + + - name: Restore sentry.properties + shell: bash + run: echo "${{ secrets.SENTRY_PROPERTIES_BASE64 }}" | base64 --decode > ./android/sentry.properties + env: + SENTRY_PROPERTIES_BASE64: ${{ secrets.SENTRY_PROPERTIES_BASE64 }} + + - name: Install maestro + run: | + curl -fsSL "https://get.maestro.mobile.dev" | bash + echo "$HOME/.maestro/bin" >> $GITHUB_PATH + $HOME/.maestro/bin/maestro --version + + - name: Setup Android SDK + emulator + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: 31 + script: | + # エラーハンドリングの設定 + set -e + + # Metro Bundlerを起動 + echo "🌐 Starting Metro Bundler..." + nohup pnpm start --reset-cache > metro.log 2>&1 & + METRO_PID=$! + + # Metro Bundlerの起動を待つ(最大60秒) + echo "⏳ Waiting for Metro Bundler..." + for i in {1..12}; do + if curl -f http://localhost:8081/status > /dev/null 2>&1; then + echo "✅ Metro Bundler is ready" + break + fi + if [ $i -eq 12 ]; then + echo "❌ Metro Bundler failed to start after 60 seconds" + cat metro.log + kill $METRO_PID 2>/dev/null || true + exit 1 + fi + echo "Waiting... ($i/12)" + sleep 5 + done + + # Androidアプリをビルド・インストール + echo "📱 Building and installing Android app..." + adb devices + + # ビルドのタイムアウト設定 + timeout 600 pnpm run android -- --variant devRelease || { + echo "❌ Android build failed or timed out" + exit 1 + } + + # アプリの起動を待つ + echo "⏳ Waiting for app to start..." + sleep 15 + + # Maestroテストを実行(スクリーンショット付き) + echo "🧪 Running Maestro tests..." + timeout 300 maestro test Flow.yaml --format junit --output maestro-results.xml || { + echo "❌ Maestro test failed or timed out" + exit 1 + } + + # クリーンアップ + echo "🧹 Cleaning up..." + kill $METRO_PID 2>/dev/null || true + pkill -f "metro" 2>/dev/null || true + + - name: Upload Metro logs + if: always() + uses: actions/upload-artifact@v4 + with: + name: metro-logs-${{ github.run_number }} + path: metro.log + + - name: Upload Maestro screenshots + if: always() + uses: actions/upload-artifact@v4 + with: + name: maestro-screenshots-${{ github.run_number }} + path: maestro-screenshots/ + retention-days: 30 + + - name: Upload Maestro test results + if: always() + uses: actions/upload-artifact@v4 + with: + name: maestro-test-results-${{ github.run_number }} + path: maestro-results.xml + retention-days: 30 + + - name: Cleanup + if: always() + run: | + pkill -f "pnpm start" || true + pkill -f "metro" || true \ No newline at end of file From 79ec287f70a110b10fa75d7672df7d16d5104f97 Mon Sep 17 00:00:00 2001 From: Tsubasa SEKIGUCHI Date: Fri, 11 Jul 2025 04:10:04 +0900 Subject: [PATCH 02/10] =?UTF-8?q?=E3=82=BF=E3=82=A4=E3=83=A0=E3=82=A2?= =?UTF-8?q?=E3=82=A6=E3=83=88=E5=87=A6=E7=90=86=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/android_e2e.yml | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/.github/workflows/android_e2e.yml b/.github/workflows/android_e2e.yml index 3aa1e16b3c..6b98cdc44c 100644 --- a/.github/workflows/android_e2e.yml +++ b/.github/workflows/android_e2e.yml @@ -110,10 +110,7 @@ jobs: adb devices # ビルドのタイムアウト設定 - timeout 600 pnpm run android -- --variant devRelease || { - echo "❌ Android build failed or timed out" - exit 1 - } + pnpm run android -- --variant devRelease # アプリの起動を待つ echo "⏳ Waiting for app to start..." @@ -121,15 +118,16 @@ jobs: # Maestroテストを実行(スクリーンショット付き) echo "🧪 Running Maestro tests..." - timeout 300 maestro test Flow.yaml --format junit --output maestro-results.xml || { - echo "❌ Maestro test failed or timed out" - exit 1 - } + maestro test Flow.yaml --format junit --output maestro-results.xml # クリーンアップ echo "🧹 Cleaning up..." kill $METRO_PID 2>/dev/null || true pkill -f "metro" 2>/dev/null || true + + # エミュレーター終了時のエラーハンドリング + echo "🔄 Shutting down emulator..." + adb emu kill 2>/dev/null || echo "⚠️ Emulator already stopped" - name: Upload Metro logs if: always() @@ -157,5 +155,13 @@ jobs: - name: Cleanup if: always() run: | + # Metro Bundlerのクリーンアップ pkill -f "pnpm start" || true - pkill -f "metro" || true \ No newline at end of file + pkill -f "metro" || true + + # エミュレーター関連プロセスのクリーンアップ + pkill -f "emulator" || true + pkill -f "qemu" || true + + # adbプロセスのクリーンアップ + adb kill-server 2>/dev/null || true \ No newline at end of file From 7cba1727ca180da10586ee5f138e4c0e0e6ff37a Mon Sep 17 00:00:00 2001 From: Tsubasa SEKIGUCHI Date: Fri, 11 Jul 2025 04:20:12 +0900 Subject: [PATCH 03/10] =?UTF-8?q?=E3=83=A1=E3=83=88=E3=83=AD=E3=83=90?= =?UTF-8?q?=E3=83=B3=E3=83=89=E3=83=A9=E3=82=BF=E3=82=A4=E3=83=A0=E3=82=A2?= =?UTF-8?q?=E3=82=A6=E3=83=88=E5=BB=B6=E9=95=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/android_e2e.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/android_e2e.yml b/.github/workflows/android_e2e.yml index 6b98cdc44c..47239fa513 100644 --- a/.github/workflows/android_e2e.yml +++ b/.github/workflows/android_e2e.yml @@ -88,20 +88,20 @@ jobs: nohup pnpm start --reset-cache > metro.log 2>&1 & METRO_PID=$! - # Metro Bundlerの起動を待つ(最大60秒) + # Metro Bundlerの起動を待つ(最大120秒) echo "⏳ Waiting for Metro Bundler..." - for i in {1..12}; do + for i in {1..24}; do if curl -f http://localhost:8081/status > /dev/null 2>&1; then echo "✅ Metro Bundler is ready" break fi - if [ $i -eq 12 ]; then - echo "❌ Metro Bundler failed to start after 60 seconds" + if [ $i -eq 24 ]; then + echo "❌ Metro Bundler failed to start after 120 seconds" cat metro.log kill $METRO_PID 2>/dev/null || true exit 1 fi - echo "Waiting... ($i/12)" + echo "Waiting... ($i/24)" sleep 5 done From 7c61d56122d5343e8cf2e1a548591d576c37c2fa Mon Sep 17 00:00:00 2001 From: Tsubasa SEKIGUCHI Date: Fri, 11 Jul 2025 04:27:35 +0900 Subject: [PATCH 04/10] update yml --- .github/workflows/android_e2e.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/android_e2e.yml b/.github/workflows/android_e2e.yml index 47239fa513..0a4d848d33 100644 --- a/.github/workflows/android_e2e.yml +++ b/.github/workflows/android_e2e.yml @@ -37,7 +37,7 @@ jobs: java-version: "21" - name: Install dependencies - run: pnpm i + run: pnpm install --frozen-lockfile - name: Restore .env.local shell: bash @@ -88,20 +88,20 @@ jobs: nohup pnpm start --reset-cache > metro.log 2>&1 & METRO_PID=$! - # Metro Bundlerの起動を待つ(最大120秒) + # Metro Bundlerの起動を待つ(最大60秒) echo "⏳ Waiting for Metro Bundler..." for i in {1..24}; do if curl -f http://localhost:8081/status > /dev/null 2>&1; then echo "✅ Metro Bundler is ready" break fi - if [ $i -eq 24 ]; then - echo "❌ Metro Bundler failed to start after 120 seconds" + if [ $i -eq 12 ]; then + echo "❌ Metro Bundler failed to start after 60 seconds" cat metro.log kill $METRO_PID 2>/dev/null || true exit 1 fi - echo "Waiting... ($i/24)" + echo "Waiting... ($i/12)" sleep 5 done @@ -114,7 +114,7 @@ jobs: # アプリの起動を待つ echo "⏳ Waiting for app to start..." - sleep 15 + sleep 45 # Maestroテストを実行(スクリーンショット付き) echo "🧪 Running Maestro tests..." From eecbdb3ee2fca770cf4d7acf5a746423507cccb8 Mon Sep 17 00:00:00 2001 From: Tsubasa SEKIGUCHI Date: Fri, 11 Jul 2025 04:30:43 +0900 Subject: [PATCH 05/10] fix --- .github/workflows/android_e2e.yml | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/workflows/android_e2e.yml b/.github/workflows/android_e2e.yml index 0a4d848d33..9d173a6312 100644 --- a/.github/workflows/android_e2e.yml +++ b/.github/workflows/android_e2e.yml @@ -75,10 +75,18 @@ jobs: echo "$HOME/.maestro/bin" >> $GITHUB_PATH $HOME/.maestro/bin/maestro --version + - name: List available system images + run: | + echo "📋 Available system images:" + sdkmanager --list | grep "system-images" | head -20 + - name: Setup Android SDK + emulator uses: reactivecircus/android-emulator-runner@v2 with: - api-level: 31 + api-level: 29 + target: google_apis + arch: x86_64 + profile: Nexus 6 script: | # エラーハンドリングの設定 set -e @@ -88,20 +96,20 @@ jobs: nohup pnpm start --reset-cache > metro.log 2>&1 & METRO_PID=$! - # Metro Bundlerの起動を待つ(最大60秒) + # Metro Bundlerの起動を待つ echo "⏳ Waiting for Metro Bundler..." for i in {1..24}; do if curl -f http://localhost:8081/status > /dev/null 2>&1; then echo "✅ Metro Bundler is ready" break fi - if [ $i -eq 12 ]; then - echo "❌ Metro Bundler failed to start after 60 seconds" + if [ $i -eq 24 ]; then + echo "❌ Metro Bundler failed to start after 120 seconds" cat metro.log kill $METRO_PID 2>/dev/null || true exit 1 fi - echo "Waiting... ($i/12)" + echo "Waiting... ($i/24)" sleep 5 done @@ -109,14 +117,13 @@ jobs: echo "📱 Building and installing Android app..." adb devices - # ビルドのタイムアウト設定 pnpm run android -- --variant devRelease # アプリの起動を待つ echo "⏳ Waiting for app to start..." sleep 45 - # Maestroテストを実行(スクリーンショット付き) + # Maestroテストを実行 echo "🧪 Running Maestro tests..." maestro test Flow.yaml --format junit --output maestro-results.xml From 512769b1faf665cbe198c11d206cdbfc2a7ec2d0 Mon Sep 17 00:00:00 2001 From: Tsubasa SEKIGUCHI Date: Fri, 11 Jul 2025 04:36:46 +0900 Subject: [PATCH 06/10] no-packager --- .github/workflows/android_e2e.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/android_e2e.yml b/.github/workflows/android_e2e.yml index 9d173a6312..b02e9bda86 100644 --- a/.github/workflows/android_e2e.yml +++ b/.github/workflows/android_e2e.yml @@ -117,7 +117,7 @@ jobs: echo "📱 Building and installing Android app..." adb devices - pnpm run android -- --variant devRelease + pnpm run android -- --variant devRelease --no-packager # アプリの起動を待つ echo "⏳ Waiting for app to start..." From 2767c1204dff3ed08d821647db4645a80868bb85 Mon Sep 17 00:00:00 2001 From: Tsubasa SEKIGUCHI Date: Fri, 11 Jul 2025 16:05:11 +0900 Subject: [PATCH 07/10] =?UTF-8?q?script:=20=E3=81=AE=E3=82=B3=E3=83=A1?= =?UTF-8?q?=E3=83=B3=E3=83=88=E5=85=A8=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/android_e2e.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/android_e2e.yml b/.github/workflows/android_e2e.yml index b02e9bda86..42a49f99ef 100644 --- a/.github/workflows/android_e2e.yml +++ b/.github/workflows/android_e2e.yml @@ -88,15 +88,12 @@ jobs: arch: x86_64 profile: Nexus 6 script: | - # エラーハンドリングの設定 set -e - # Metro Bundlerを起動 echo "🌐 Starting Metro Bundler..." nohup pnpm start --reset-cache > metro.log 2>&1 & METRO_PID=$! - # Metro Bundlerの起動を待つ echo "⏳ Waiting for Metro Bundler..." for i in {1..24}; do if curl -f http://localhost:8081/status > /dev/null 2>&1; then @@ -113,26 +110,21 @@ jobs: sleep 5 done - # Androidアプリをビルド・インストール echo "📱 Building and installing Android app..." adb devices pnpm run android -- --variant devRelease --no-packager - # アプリの起動を待つ echo "⏳ Waiting for app to start..." sleep 45 - # Maestroテストを実行 echo "🧪 Running Maestro tests..." maestro test Flow.yaml --format junit --output maestro-results.xml - # クリーンアップ echo "🧹 Cleaning up..." kill $METRO_PID 2>/dev/null || true pkill -f "metro" 2>/dev/null || true - # エミュレーター終了時のエラーハンドリング echo "🔄 Shutting down emulator..." adb emu kill 2>/dev/null || echo "⚠️ Emulator already stopped" From d300c078aaf38f4b2844e61d566d09542f687064 Mon Sep 17 00:00:00 2001 From: Tsubasa SEKIGUCHI Date: Fri, 11 Jul 2025 16:13:58 +0900 Subject: [PATCH 08/10] emulator-options: -no-window -gpu swiftshader_indirect --- .github/workflows/android_e2e.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/android_e2e.yml b/.github/workflows/android_e2e.yml index 42a49f99ef..7774c6e0cb 100644 --- a/.github/workflows/android_e2e.yml +++ b/.github/workflows/android_e2e.yml @@ -87,6 +87,7 @@ jobs: target: google_apis arch: x86_64 profile: Nexus 6 + emulator-options: -no-window -gpu swiftshader_indirect script: | set -e From 65bdb8b0f078727dfa6eb52c28af8ef77d16b3e9 Mon Sep 17 00:00:00 2001 From: Tsubasa SEKIGUCHI Date: Fri, 11 Jul 2025 16:23:57 +0900 Subject: [PATCH 09/10] bash --- .github/workflows/android_e2e.yml | 115 ++++++++++++++++-------------- 1 file changed, 61 insertions(+), 54 deletions(-) diff --git a/.github/workflows/android_e2e.yml b/.github/workflows/android_e2e.yml index 7774c6e0cb..be890d07ad 100644 --- a/.github/workflows/android_e2e.yml +++ b/.github/workflows/android_e2e.yml @@ -73,62 +73,69 @@ jobs: run: | curl -fsSL "https://get.maestro.mobile.dev" | bash echo "$HOME/.maestro/bin" >> $GITHUB_PATH - $HOME/.maestro/bin/maestro --version - - name: List available system images + - name: Update cmdline-tools run: | - echo "📋 Available system images:" - sdkmanager --list | grep "system-images" | head -20 - - - name: Setup Android SDK + emulator - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: 29 - target: google_apis - arch: x86_64 - profile: Nexus 6 - emulator-options: -no-window -gpu swiftshader_indirect - script: | - set -e - - echo "🌐 Starting Metro Bundler..." - nohup pnpm start --reset-cache > metro.log 2>&1 & - METRO_PID=$! - - echo "⏳ Waiting for Metro Bundler..." - for i in {1..24}; do - if curl -f http://localhost:8081/status > /dev/null 2>&1; then - echo "✅ Metro Bundler is ready" - break - fi - if [ $i -eq 24 ]; then - echo "❌ Metro Bundler failed to start after 120 seconds" - cat metro.log - kill $METRO_PID 2>/dev/null || true - exit 1 - fi - echo "Waiting... ($i/24)" - sleep 5 - done - - echo "📱 Building and installing Android app..." - adb devices - - pnpm run android -- --variant devRelease --no-packager - - echo "⏳ Waiting for app to start..." - sleep 45 - - echo "🧪 Running Maestro tests..." - maestro test Flow.yaml --format junit --output maestro-results.xml - - echo "🧹 Cleaning up..." - kill $METRO_PID 2>/dev/null || true - pkill -f "metro" 2>/dev/null || true - - echo "🔄 Shutting down emulator..." - adb emu kill 2>/dev/null || echo "⚠️ Emulator already stopped" - + mkdir -p "$ANDROID_SDK_ROOT/cmdline-tools" + cd "$ANDROID_SDK_ROOT/cmdline-tools" + curl -O https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip + unzip -q commandlinetools-linux-*.zip -d temp + mv temp "$ANDROID_SDK_ROOT/cmdline-tools/latest" + rm commandlinetools-linux-*.zip + echo "$ANDROID_SDK_ROOT/emulator" >> $GITHUB_PATH + echo "$ANDROID_SDK_ROOT/platform-tools" >> $GITHUB_PATH + echo "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin" >> $GITHUB_PATH + - name: Run Android E2E (Metro + AVD + Maestro) + shell: bash + run: | + echo "🧱 Creating AVD..." + mkdir -p "$HOME/.android/avd" + sdkmanager --licenses < /dev/null + sdkmanager "system-images;android-30;google_apis;x86_64" + echo "no" | avdmanager create avd \ + -n test \ + -k "system-images;android-30;google_apis;x86_64" \ + -d "Nexus 5" + if [ ! -f "$HOME/.android/avd/test.avd/config.ini" ]; then + echo "❌ Failed to create AVD" + ls -l "$HOME/.android/avd" + exit 1 + fi + echo "🚀 Starting emulator..." + emulator -avd test -no-snapshot -no-window -gpu swiftshader_indirect -no-audio & + EMULATOR_PID=$! + + echo "⏳ Waiting for emulator boot..." + booted=0 + for i in {1..60}; do + if adb shell getprop sys.boot_completed | grep 1 > /dev/null; then + echo "✅ Emulator booted" + booted=1 + break + fi + echo "Waiting for boot... ($i/60)" + sleep 5 + done + + if [ "$booted" -eq 0 ]; then + echo "❌ Emulator failed to boot within 300 seconds" + adb logcat -d > emulator_logcat.txt + exit 1 + fi + + echo "🌐 Starting Metro..." + pnpm start --reset-cache & + METRO_PID=$! + + echo "📦 Installing app..." + pnpm run android -- --variant devRelease + + echo "🧪 Running Maestro tests..." + $HOME/.maestro/bin/maestro test Flow.yaml + + echo "🧹 Cleaning up..." + kill $METRO_PID || true + kill $EMULATOR_PID || true - name: Upload Metro logs if: always() uses: actions/upload-artifact@v4 From 785805bec236cb8b5cdf23d50dd9ab107918194e Mon Sep 17 00:00:00 2001 From: Tsubasa SEKIGUCHI Date: Fri, 11 Jul 2025 19:55:11 +0900 Subject: [PATCH 10/10] downgrade jdk --- .github/workflows/android_e2e.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/android_e2e.yml b/.github/workflows/android_e2e.yml index be890d07ad..e0fb6dfb05 100644 --- a/.github/workflows/android_e2e.yml +++ b/.github/workflows/android_e2e.yml @@ -34,7 +34,7 @@ jobs: - uses: actions/setup-java@v4 with: distribution: "temurin" - java-version: "21" + java-version: "17" - name: Install dependencies run: pnpm install --frozen-lockfile