From 4e1d54fab07faf3fd10a9024e9e639ab0ca9e9b6 Mon Sep 17 00:00:00 2001 From: alome007 Date: Thu, 27 Mar 2025 21:32:32 +0100 Subject: [PATCH 01/24] ADFA-519: Add instrumented test support --- .github/workflows/instrumented_test.yml | 101 ++++++++++++++++++++++++ LayoutEditor | 2 +- 2 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/instrumented_test.yml diff --git a/.github/workflows/instrumented_test.yml b/.github/workflows/instrumented_test.yml new file mode 100644 index 0000000000..70f245fd95 --- /dev/null +++ b/.github/workflows/instrumented_test.yml @@ -0,0 +1,101 @@ +name: Windows Instrumented Tests with Git LFS + +on: + push: + branches: [ "stage", "feature/**" ] + pull_request: + branches: [ "stage", "feature/**" ] + workflow_dispatch: { } + +env: + # Build configuration + BUILD_JAVA_VERSION: '17' + BUILD_JAVA_DIST: 'temurin' + +jobs: + run_instrumented_tests: + name: Run Instrumented Tests on Windows + runs-on: self-hosted + steps: + - name: Cancel previous runs + uses: styfle/cancel-workflow-action@0.12.1 + with: + access_token: ${{ github.token }} + + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Configure Git safe directory + run: | + git config --global --add safe.directory ${{ github.workspace }} + git config --global core.longpaths true + shell: bash + + - name: Initialize submodules + run: | + git submodule init + git submodule update --remote + shell: bash + + - name: Install Git LFS and pull large files + run: | + git lfs install + git lfs pull + shell: bash + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: ${{ env.BUILD_JAVA_VERSION }} + distribution: ${{ env.BUILD_JAVA_DIST }} + + - name: Setup Android SDK + uses: android-actions/setup-android@v3 + + - name: Install Android SDK components + run: | + sdkmanager.bat "platform-tools" "emulator" "system-images;android-30;google_apis;x86_64" "platforms;android-30" "build-tools;30.0.3" + shell: cmd + + - name: Set ANDROID_HOME environment variable + run: | + echo "ANDROID_HOME=$env:ANDROID_SDK_ROOT" >> $env:GITHUB_ENV + shell: pwsh + + - name: Restore Gradle Cache + uses: actions/cache@v4 + with: + path: | + %USERPROFILE%\.gradle\caches + %USERPROFILE%\.gradle\wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Create AVD + run: | + echo no | avdmanager.bat create avd -n test_avd -k "system-images;android-30;google_apis;x86_64" --force + shell: cmd + + - name: Start Android Emulator + run: | + start /b emulator.bat -avd test_avd -no-window -no-audio -no-boot-anim -gpu swiftshader_indirect + powershell -Command "& {$startTime = Get-Date; while (!(adb shell getprop sys.boot_completed 2>&1 | Select-String '1')) { if ((New-TimeSpan -Start $startTime -End (Get-Date)).TotalSeconds -gt 300) { Write-Host 'Emulator boot timed out'; exit 1 } Start-Sleep -Seconds 5; Write-Host 'Waiting for emulator to boot...' }}" + shell: cmd + + - name: Run Instrumented Tests + run: | + adb devices + gradlew.bat app:cAT "-Pandroid.testInstrumentationRunnerArguments.class=com.itsaky.androidide.OrderedTestSuite" --stacktrace + shell: cmd + env: + ANDROIDIDE_TEST: true + + - name: Upload Test Reports + if: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + name: test-results-instrumented + path: '**/build/reports/tests/' \ No newline at end of file diff --git a/LayoutEditor b/LayoutEditor index 9cb5395285..a15eca0245 160000 --- a/LayoutEditor +++ b/LayoutEditor @@ -1 +1 @@ -Subproject commit 9cb53952853fd2e1a8f05cca124ca52986095c64 +Subproject commit a15eca02452404c6a1bf9fe12a728932a5fe33da From 619c5d3a12164a2106c64840947d059e6cb1cfc3 Mon Sep 17 00:00:00 2001 From: alome007 Date: Thu, 27 Mar 2025 21:34:41 +0100 Subject: [PATCH 02/24] ADFA-315: Remove layout content directory from basic activity main template --- .github/workflows/instrumented_test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/instrumented_test.yml b/.github/workflows/instrumented_test.yml index 70f245fd95..be2840867f 100644 --- a/.github/workflows/instrumented_test.yml +++ b/.github/workflows/instrumented_test.yml @@ -1,4 +1,4 @@ -name: Windows Instrumented Tests with Git LFS +name: Instrumented Tests on: push: @@ -14,7 +14,7 @@ env: jobs: run_instrumented_tests: - name: Run Instrumented Tests on Windows + name: Run Instrumented Tests runs-on: self-hosted steps: - name: Cancel previous runs From f55d0edc43c74cec1f9c6b45069ca6bcc743e4af Mon Sep 17 00:00:00 2001 From: alome007 Date: Thu, 27 Mar 2025 21:40:34 +0100 Subject: [PATCH 03/24] ADFA-315: Remove layout content directory from basic activity main template --- .github/workflows/instrumented_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/instrumented_test.yml b/.github/workflows/instrumented_test.yml index be2840867f..7fc5b75306 100644 --- a/.github/workflows/instrumented_test.yml +++ b/.github/workflows/instrumented_test.yml @@ -39,7 +39,7 @@ jobs: git submodule update --remote shell: bash - - name: Install Git LFS and pull large files + - name: Install Git LFS run: | git lfs install git lfs pull From f9b3cc8ea8c1b74c3eca02dd59f0b13612963bef Mon Sep 17 00:00:00 2001 From: alome007 Date: Thu, 27 Mar 2025 22:28:28 +0100 Subject: [PATCH 04/24] ADFA-519: Add instrumented_test.yml --- .github/workflows/instrumented_test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/instrumented_test.yml b/.github/workflows/instrumented_test.yml index 7fc5b75306..ce65975150 100644 --- a/.github/workflows/instrumented_test.yml +++ b/.github/workflows/instrumented_test.yml @@ -1,4 +1,7 @@ name: Instrumented Tests +permissions: + contents: write + actions: write on: push: From 39471c4898273dfddd4749d837a6708f5ab65cda Mon Sep 17 00:00:00 2001 From: alome007 Date: Thu, 27 Mar 2025 22:39:42 +0100 Subject: [PATCH 05/24] ADFA-519: Add instrumented_test.yml --- .github/workflows/instrumented_test.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/instrumented_test.yml b/.github/workflows/instrumented_test.yml index ce65975150..f1dfdc202b 100644 --- a/.github/workflows/instrumented_test.yml +++ b/.github/workflows/instrumented_test.yml @@ -1,7 +1,4 @@ -name: Instrumented Tests -permissions: - contents: write - actions: write +name: Instrumented Tests on: push: From 585826b45a43cb67f74500e8281b2bdb29d958e7 Mon Sep 17 00:00:00 2001 From: alome007 Date: Thu, 27 Mar 2025 22:57:40 +0100 Subject: [PATCH 06/24] ADFA-519: Add instrumented_test.yml --- .github/workflows/instrumented_test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/instrumented_test.yml b/.github/workflows/instrumented_test.yml index f1dfdc202b..1e24d1d697 100644 --- a/.github/workflows/instrumented_test.yml +++ b/.github/workflows/instrumented_test.yml @@ -1,5 +1,7 @@ name: Instrumented Tests - +permissions: + contents: write + actions: write on: push: branches: [ "stage", "feature/**" ] From 52c62fd89652d3f7f22cfb4733ac1b960b0a983d Mon Sep 17 00:00:00 2001 From: alome007 Date: Thu, 27 Mar 2025 23:32:23 +0100 Subject: [PATCH 07/24] ADFA-519: Add instrumented_test.yml --- .github/workflows/instrumented_test.yml | 68 ++++++++++++------------- 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/.github/workflows/instrumented_test.yml b/.github/workflows/instrumented_test.yml index 1e24d1d697..b71a42827f 100644 --- a/.github/workflows/instrumented_test.yml +++ b/.github/workflows/instrumented_test.yml @@ -1,4 +1,4 @@ -name: Instrumented Tests +name: Instrumented Tests permissions: contents: write actions: write @@ -10,7 +10,6 @@ on: workflow_dispatch: { } env: - # Build configuration BUILD_JAVA_VERSION: '17' BUILD_JAVA_DIST: 'temurin' @@ -19,33 +18,36 @@ jobs: name: Run Instrumented Tests runs-on: self-hosted steps: - - name: Cancel previous runs + - name: Cancel Previous Runs uses: styfle/cancel-workflow-action@0.12.1 with: access_token: ${{ github.token }} - - name: Checkout code + - name: Setup Git LFS + run: | + echo Setting up Git LFS + where git-lfs || ( + echo Installing Git LFS + powershell -Command "Invoke-WebRequest -Uri https://github.com/git-lfs/git-lfs/releases/download/v3.4.1/git-lfs-windows-amd64-v3.4.1.zip -OutFile git-lfs.zip; Expand-Archive -Path git-lfs.zip -DestinationPath git-lfs; cd git-lfs; .\git-lfs-3.4.1\install.bat" + ) + git lfs install + shell: cmd + + - name: Checkout Code uses: actions/checkout@v4 with: fetch-depth: 0 + lfs: true - - name: Configure Git safe directory - run: | - git config --global --add safe.directory ${{ github.workspace }} - git config --global core.longpaths true - shell: bash + - name: Pull Git LFS Files + run: git lfs pull + shell: cmd - - name: Initialize submodules + - name: Initialize Submodules run: | git submodule init git submodule update --remote - shell: bash - - - name: Install Git LFS - run: | - git lfs install - git lfs pull - shell: bash + shell: cmd - name: Set up JDK 17 uses: actions/setup-java@v4 @@ -53,26 +55,13 @@ jobs: java-version: ${{ env.BUILD_JAVA_VERSION }} distribution: ${{ env.BUILD_JAVA_DIST }} - - name: Setup Android SDK - uses: android-actions/setup-android@v3 - - - name: Install Android SDK components - run: | - sdkmanager.bat "platform-tools" "emulator" "system-images;android-30;google_apis;x86_64" "platforms;android-30" "build-tools;30.0.3" - shell: cmd - - - name: Set ANDROID_HOME environment variable - run: | - echo "ANDROID_HOME=$env:ANDROID_SDK_ROOT" >> $env:GITHUB_ENV - shell: pwsh - - name: Restore Gradle Cache uses: actions/cache@v4 with: path: | - %USERPROFILE%\.gradle\caches - %USERPROFILE%\.gradle\wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle/wrapper/gradle-wrapper.properties') }} restore-keys: | ${{ runner.os }}-gradle- @@ -84,7 +73,16 @@ jobs: - name: Start Android Emulator run: | start /b emulator.bat -avd test_avd -no-window -no-audio -no-boot-anim -gpu swiftshader_indirect - powershell -Command "& {$startTime = Get-Date; while (!(adb shell getprop sys.boot_completed 2>&1 | Select-String '1')) { if ((New-TimeSpan -Start $startTime -End (Get-Date)).TotalSeconds -gt 300) { Write-Host 'Emulator boot timed out'; exit 1 } Start-Sleep -Seconds 5; Write-Host 'Waiting for emulator to boot...' }}" + powershell -Command "& { + $startTime = Get-Date; + while (!(adb shell getprop sys.boot_completed 2>&1 | Select-String '1')) { + if ((New-TimeSpan -Start $startTime -End (Get-Date)).TotalSeconds -gt 300) { + Write-Host 'Emulator boot timed out'; exit 1 + } + Start-Sleep -Seconds 5; + Write-Host 'Waiting for emulator to boot...' + } + }" shell: cmd - name: Run Instrumented Tests @@ -100,4 +98,4 @@ jobs: uses: actions/upload-artifact@v4 with: name: test-results-instrumented - path: '**/build/reports/tests/' \ No newline at end of file + path: '**/build/reports/tests/' From ce8cf61e3b291eb0587b289da7bfae15489f2fae Mon Sep 17 00:00:00 2001 From: alome007 Date: Thu, 27 Mar 2025 23:43:41 +0100 Subject: [PATCH 08/24] ADFA-519: Add instrumented_test.yml --- .github/workflows/instrumented_test.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/instrumented_test.yml b/.github/workflows/instrumented_test.yml index b71a42827f..9eb66fc428 100644 --- a/.github/workflows/instrumented_test.yml +++ b/.github/workflows/instrumented_test.yml @@ -12,6 +12,8 @@ on: env: BUILD_JAVA_VERSION: '17' BUILD_JAVA_DIST: 'temurin' + # Adjust the Android SDK path to your Windows setup + ANDROID_HOME: 'C:\Users\CoGoAdmin\AppData\Local\Android\Sdk' jobs: run_instrumented_tests: @@ -59,12 +61,19 @@ jobs: uses: actions/cache@v4 with: path: | - ~/.gradle/caches - ~/.gradle/wrapper + %USERPROFILE%\.gradle\caches + %USERPROFILE%\.gradle\wrapper key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle/wrapper/gradle-wrapper.properties') }} restore-keys: | ${{ runner.os }}-gradle- + - name: Add Android SDK Tools to PATH + run: | + echo Adding Android SDK tools to PATH... + setx PATH "%PATH%;%ANDROID_HOME%\cmdline-tools\latest\bin;%ANDROID_HOME%\emulator" + echo %PATH% + shell: cmd + - name: Create AVD run: | echo no | avdmanager.bat create avd -n test_avd -k "system-images;android-30;google_apis;x86_64" --force @@ -85,7 +94,7 @@ jobs: }" shell: cmd - - name: Run Instrumented Tests + - name: Run Instrumented Tests (Auto Install) run: | adb devices gradlew.bat app:cAT "-Pandroid.testInstrumentationRunnerArguments.class=com.itsaky.androidide.OrderedTestSuite" --stacktrace @@ -98,4 +107,4 @@ jobs: uses: actions/upload-artifact@v4 with: name: test-results-instrumented - path: '**/build/reports/tests/' + path: '**\build\reports\tests\' From 1ccb6c2cca88c1a65ad3a187c7a1b28bae2b5917 Mon Sep 17 00:00:00 2001 From: alome007 Date: Fri, 28 Mar 2025 08:20:08 +0100 Subject: [PATCH 09/24] ADFA-519: Add instrumented_test.yml --- .github/workflows/instrumented_test.yml | 27 ------------------------- 1 file changed, 27 deletions(-) diff --git a/.github/workflows/instrumented_test.yml b/.github/workflows/instrumented_test.yml index 9eb66fc428..b0e3626cba 100644 --- a/.github/workflows/instrumented_test.yml +++ b/.github/workflows/instrumented_test.yml @@ -67,33 +67,6 @@ jobs: restore-keys: | ${{ runner.os }}-gradle- - - name: Add Android SDK Tools to PATH - run: | - echo Adding Android SDK tools to PATH... - setx PATH "%PATH%;%ANDROID_HOME%\cmdline-tools\latest\bin;%ANDROID_HOME%\emulator" - echo %PATH% - shell: cmd - - - name: Create AVD - run: | - echo no | avdmanager.bat create avd -n test_avd -k "system-images;android-30;google_apis;x86_64" --force - shell: cmd - - - name: Start Android Emulator - run: | - start /b emulator.bat -avd test_avd -no-window -no-audio -no-boot-anim -gpu swiftshader_indirect - powershell -Command "& { - $startTime = Get-Date; - while (!(adb shell getprop sys.boot_completed 2>&1 | Select-String '1')) { - if ((New-TimeSpan -Start $startTime -End (Get-Date)).TotalSeconds -gt 300) { - Write-Host 'Emulator boot timed out'; exit 1 - } - Start-Sleep -Seconds 5; - Write-Host 'Waiting for emulator to boot...' - } - }" - shell: cmd - - name: Run Instrumented Tests (Auto Install) run: | adb devices From 3355e952f518bcbceff9e3d8916c94306a8b026b Mon Sep 17 00:00:00 2001 From: alome007 Date: Fri, 28 Mar 2025 08:49:01 +0100 Subject: [PATCH 10/24] ADFA-519: Add instrumented_test.yml --- .github/workflows/instrumented_test.yml | 48 ++++++++++++++++++++----- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/.github/workflows/instrumented_test.yml b/.github/workflows/instrumented_test.yml index b0e3626cba..fc3b60fa48 100644 --- a/.github/workflows/instrumented_test.yml +++ b/.github/workflows/instrumented_test.yml @@ -1,23 +1,20 @@ name: Instrumented Tests permissions: contents: write - actions: write on: push: branches: [ "stage", "feature/**" ] pull_request: branches: [ "stage", "feature/**" ] - workflow_dispatch: { } + workflow_dispatch: env: BUILD_JAVA_VERSION: '17' BUILD_JAVA_DIST: 'temurin' - # Adjust the Android SDK path to your Windows setup ANDROID_HOME: 'C:\Users\CoGoAdmin\AppData\Local\Android\Sdk' jobs: run_instrumented_tests: - name: Run Instrumented Tests runs-on: self-hosted steps: - name: Cancel Previous Runs @@ -28,7 +25,7 @@ jobs: - name: Setup Git LFS run: | echo Setting up Git LFS - where git-lfs || ( + where git-lfs || ( echo Installing Git LFS powershell -Command "Invoke-WebRequest -Uri https://github.com/git-lfs/git-lfs/releases/download/v3.4.1/git-lfs-windows-amd64-v3.4.1.zip -OutFile git-lfs.zip; Expand-Archive -Path git-lfs.zip -DestinationPath git-lfs; cd git-lfs; .\git-lfs-3.4.1\install.bat" ) @@ -67,10 +64,43 @@ jobs: restore-keys: | ${{ runner.os }}-gradle- - - name: Run Instrumented Tests (Auto Install) + - name: Prepare and Start Android Emulator run: | - adb devices - gradlew.bat app:cAT "-Pandroid.testInstrumentationRunnerArguments.class=com.itsaky.androidide.OrderedTestSuite" --stacktrace + # Check if AVD exists + "%ANDROID_HOME%\emulator\emulator.exe" -list-avds | findstr /i "Pixel_4_API_30" > nul + if %errorlevel% neq 0 ( + echo AVD Pixel_4_API_30 not found. Creating new AVD... + + # Ensure system image is installed + "%ANDROID_HOME%\cmdline-tools\latest\bin\sdkmanager" "system-images;android-30;google_apis;x86_64" + + # Create AVD + "%ANDROID_HOME%\cmdline-tools\latest\bin\avdmanager" create avd ^ + -n Pixel_4_API_30 ^ + -k "system-images;android-30;google_apis;x86_64" ^ + --device "pixel_4" ^ + -f + ) + + # Start emulator + start "" "%ANDROID_HOME%\emulator\emulator.exe" ^ + -avd Pixel_4_API_30 ^ + -no-window ^ + -no-audio ^ + -no-snapshot-load + + # Wait for emulator to boot + "%ANDROID_HOME%\platform-tools\adb" wait-for-device + "%ANDROID_HOME%\platform-tools\adb" shell "while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;" + shell: cmd + + - name: Run Instrumented Tests + run: | + # Verify devices are connected + "%ANDROID_HOME%\platform-tools\adb" devices + + # Run Android tests + gradlew.bat app:connectedAndroidTest "-Pandroid.testInstrumentationRunnerArguments.class=com.itsaky.androidide.OrderedTestSuite" --stacktrace shell: cmd env: ANDROIDIDE_TEST: true @@ -80,4 +110,4 @@ jobs: uses: actions/upload-artifact@v4 with: name: test-results-instrumented - path: '**\build\reports\tests\' + path: '**/build/reports/tests/' \ No newline at end of file From 72406124d5b13de6a18fbc82cc1f3c61f4f86bb9 Mon Sep 17 00:00:00 2001 From: alome007 Date: Fri, 28 Mar 2025 09:09:04 +0100 Subject: [PATCH 11/24] ADFA-519: Add instrumented_test.yml --- .github/workflows/instrumented_test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/instrumented_test.yml b/.github/workflows/instrumented_test.yml index fc3b60fa48..63c424449f 100644 --- a/.github/workflows/instrumented_test.yml +++ b/.github/workflows/instrumented_test.yml @@ -1,6 +1,7 @@ name: Instrumented Tests permissions: contents: write + actions: write on: push: branches: [ "stage", "feature/**" ] From 1ab8f382eec9702c0da52697b4a6d6f28bc00914 Mon Sep 17 00:00:00 2001 From: alome007 Date: Fri, 28 Mar 2025 09:43:59 +0100 Subject: [PATCH 12/24] ADFA-519: Add instrumented_test.yml --- .github/workflows/instrumented_test.yml | 55 +++++++------------------ 1 file changed, 15 insertions(+), 40 deletions(-) diff --git a/.github/workflows/instrumented_test.yml b/.github/workflows/instrumented_test.yml index 63c424449f..c878bd35b5 100644 --- a/.github/workflows/instrumented_test.yml +++ b/.github/workflows/instrumented_test.yml @@ -65,46 +65,21 @@ jobs: restore-keys: | ${{ runner.os }}-gradle- - - name: Prepare and Start Android Emulator - run: | - # Check if AVD exists - "%ANDROID_HOME%\emulator\emulator.exe" -list-avds | findstr /i "Pixel_4_API_30" > nul - if %errorlevel% neq 0 ( - echo AVD Pixel_4_API_30 not found. Creating new AVD... - - # Ensure system image is installed - "%ANDROID_HOME%\cmdline-tools\latest\bin\sdkmanager" "system-images;android-30;google_apis;x86_64" - - # Create AVD - "%ANDROID_HOME%\cmdline-tools\latest\bin\avdmanager" create avd ^ - -n Pixel_4_API_30 ^ - -k "system-images;android-30;google_apis;x86_64" ^ - --device "pixel_4" ^ - -f - ) - - # Start emulator - start "" "%ANDROID_HOME%\emulator\emulator.exe" ^ - -avd Pixel_4_API_30 ^ - -no-window ^ - -no-audio ^ - -no-snapshot-load - - # Wait for emulator to boot - "%ANDROID_HOME%\platform-tools\adb" wait-for-device - "%ANDROID_HOME%\platform-tools\adb" shell "while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;" - shell: cmd - - - name: Run Instrumented Tests - run: | - # Verify devices are connected - "%ANDROID_HOME%\platform-tools\adb" devices - - # Run Android tests - gradlew.bat app:connectedAndroidTest "-Pandroid.testInstrumentationRunnerArguments.class=com.itsaky.androidide.OrderedTestSuite" --stacktrace - shell: cmd - env: - ANDROIDIDE_TEST: true + - name: Run Android Emulator and Instrumented Tests + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: 30 + target: google_apis + arch: x86_64 + profile: Pixel_4_API_30 + emulator-options: "-no-window -no-audio -no-snapshot-load" + disable-animations: true + script: | + adb wait-for-device + gradlew.bat app:connectedAndroidTest "-Pandroid.testInstrumentationRunnerArguments.class=com.itsaky.androidide.OrderedTestSuite" --stacktrace + shell: cmd + env: + ANDROIDIDE_TEST: true - name: Upload Test Reports if: ${{ always() }} From 9f7dd6b5cf1df4341534c1aaaac7e0ba76094479 Mon Sep 17 00:00:00 2001 From: alome007 Date: Fri, 28 Mar 2025 10:09:14 +0100 Subject: [PATCH 13/24] ADFA-519: Add instrumented_test.yml --- .github/workflows/instrumented_test.yml | 54 ++++++++++++++++++------- 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/.github/workflows/instrumented_test.yml b/.github/workflows/instrumented_test.yml index c878bd35b5..e00a465dbc 100644 --- a/.github/workflows/instrumented_test.yml +++ b/.github/workflows/instrumented_test.yml @@ -65,21 +65,45 @@ jobs: restore-keys: | ${{ runner.os }}-gradle- - - name: Run Android Emulator and Instrumented Tests - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: 30 - target: google_apis - arch: x86_64 - profile: Pixel_4_API_30 - emulator-options: "-no-window -no-audio -no-snapshot-load" - disable-animations: true - script: | - adb wait-for-device - gradlew.bat app:connectedAndroidTest "-Pandroid.testInstrumentationRunnerArguments.class=com.itsaky.androidide.OrderedTestSuite" --stacktrace - shell: cmd - env: - ANDROIDIDE_TEST: true + - name: Prepare and Start Android Emulator + run: | + setlocal EnableDelayedExpansion + + echo Checking for existing AVDs... + set "AVD_NAME=" + for /f "delims=" %%a in ('"%ANDROID_HOME%\emulator\emulator.exe" -list-avds') do ( + set "AVD_NAME=%%a" + goto :have_avd + ) + + :have_avd + if defined AVD_NAME ( + echo Found existing AVD: !AVD_NAME!. Starting... + ) else ( + echo No existing AVD found. Creating Pixel_4_API_30... + "%ANDROID_HOME%\cmdline-tools\latest\bin\sdkmanager" "system-images;android-30;google_apis;x86_64" + "%ANDROID_HOME%\cmdline-tools\latest\bin\avdmanager" create avd -n Pixel_4_API_30 -k "system-images;android-30;google_apis;x86_64" --device "pixel_4" -f + set "AVD_NAME=Pixel_4_API_30" + ) + + echo Starting emulator !AVD_NAME!... + start "" "%ANDROID_HOME%\emulator\emulator.exe" -avd !AVD_NAME! -no-window -no-audio -no-snapshot-load + + echo Waiting for emulator to boot... + "%ANDROID_HOME%\platform-tools\adb" wait-for-device + "%ANDROID_HOME%\platform-tools\adb" shell "while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;" + + endlocal + exit /b 0 + shell: cmd + + - name: Run Instrumented Tests + run: | + "%ANDROID_HOME%\platform-tools\adb" devices + gradlew.bat app:connectedAndroidTest "-Pandroid.testInstrumentationRunnerArguments.class=com.itsaky.androidide.OrderedTestSuite" --stacktrace + shell: cmd + env: + ANDROIDIDE_TEST: true - name: Upload Test Reports if: ${{ always() }} From 121ad8e337ac5db47fe8507b641ccb4efb996af8 Mon Sep 17 00:00:00 2001 From: alome007 Date: Fri, 28 Mar 2025 10:33:21 +0100 Subject: [PATCH 14/24] ADFA-519: Add instrumented_test.yml --- .github/workflows/build.yml | 364 ++++++++++++------------ .github/workflows/instrumented_test.yml | 48 ++-- 2 files changed, 210 insertions(+), 202 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 072a3e70ff..42caa59fb5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,182 +1,182 @@ -name: Build APK -permissions: - contents: write - actions: write -on: - pull_request: - branches: [ "stage", "feature/**" ] - paths-ignore: - - '**.md' - - 'fastlane/**' - - '.github/workflows/crowdin_contributors.yml' - workflow_dispatch: { } - -env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # Signing info (if needed) - IDE_SIGNING_ALIAS: ${{ secrets.IDE_SIGNING_ALIAS }} - IDE_SIGNING_AUTH_PASS: ${{ secrets.IDE_SIGNING_AUTH_PASS }} - IDE_SIGNING_AUTH_USER: ${{ secrets.IDE_SIGNING_AUTH_USER }} - IDE_SIGNING_KEY_PASS: ${{ secrets.IDE_SIGNING_KEY_PASS }} - IDE_SIGNING_STORE_PASS: ${{ secrets.IDE_SIGNING_STORE_PASS }} - IDE_SIGNING_URL: ${{ secrets.IDE_SIGNING_URL }} - IDE_SIGNING_KEY_BIN: ${{ secrets.IDE_SIGNING_KEY_BIN }} - # Publishing credentials (if needed) - ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MVN_USERNAME }} - ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MVN_PASSWORD }} - ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.MVN_SIGNING_KEY }} - ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.MVN_SIGNING_KEY_ID }} - ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.MVN_SIGNING_KEY_PASSWORD }} - # Build configuration - BUILD_JAVA_VERSION: '17' - BUILD_JAVA_DIST: 'temurin' - -jobs: - build_apk: - name: Build Universal APK - runs-on: self-hosted - timeout-minutes: 60 - steps: - - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.12.1 - with: - access_token: ${{ github.token }} - - - name: Setup Git LFS - run: | - echo "Setting up Git LFS" - where git-lfs || ( - echo "Installing Git LFS" - powershell -Command "Invoke-WebRequest -Uri https://github.com/git-lfs/git-lfs/releases/download/v3.4.1/git-lfs-windows-amd64-v3.4.1.zip -OutFile git-lfs.zip; Expand-Archive -Path git-lfs.zip -DestinationPath git-lfs; cd git-lfs; .\git-lfs-3.4.1\install.bat" - ) - git lfs install - shell: cmd - - - name: Checkout Code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - lfs: true - - - name: Pull Git LFS Files - run: git lfs pull - shell: cmd - - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - java-version: ${{ env.BUILD_JAVA_VERSION }} - distribution: ${{ env.BUILD_JAVA_DIST }} - - - name: Initialize Submodules - run: | - git submodule init - git submodule update --remote - shell: cmd - - - name: Restore Gradle Cache - uses: actions/cache@v4 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle/wrapper/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradle- - - - name: Extract Commit Message - id: extract_commit_message - run: | - for /f "tokens=*" %%a in ('git log -1 --pretty=format:"%%B"') do ( - set "COMMIT_MESSAGE=%%a" - ) - echo Commit Message: %COMMIT_MESSAGE% - echo COMMIT_MESSAGE=%COMMIT_MESSAGE% >> %GITHUB_ENV% - shell: cmd - - - name: Assemble Universal APK - id: build_apk - run: | - .\gradlew.bat assembleDebug - if %errorlevel% neq 0 exit /b %errorlevel% - shell: cmd - - - name: Extract Branch Information - id: extract_branch - run: | - @echo off - rem Use the head ref for PR events; otherwise, fallback to the branch name - if defined GITHUB_HEAD_REF ( - set "BRANCH_NAME=%GITHUB_HEAD_REF%" - ) else ( - set "BRANCH_NAME=%GITHUB_REF:refs/heads/=%" - ) - echo Branch: %BRANCH_NAME% - - rem Extract Jira ticket pattern using PowerShell - powershell -Command "$branch = '%BRANCH_NAME%'; $match = [regex]::Match($branch, '[A-Z]+-[0-9]+'); if($match.Success) { $folder = $match.Value } else { $folder = '%BRANCH_NAME%' }; Write-Output \"Folder Name: $folder\"; \"FOLDER_NAME=$folder\" | Out-File -Append $env:GITHUB_ENV" - shell: cmd - - - name: Install rclone - run: | - echo Installing rclone... - powershell -Command "Invoke-WebRequest -Uri 'https://downloads.rclone.org/rclone-current-windows-amd64.zip' -OutFile 'rclone.zip'" - powershell -Command "Expand-Archive -Path 'rclone.zip' -DestinationPath '.\\rclone'" - for /d %%i in (.\rclone\rclone-*-windows-amd64) do ( - set "RCLONE_DIR=%%i" - ) - echo RCLONE_DIR is %RCLONE_DIR% - set "RCLONE_PATH=%CD%\%RCLONE_DIR%\rclone.exe" - echo RCLONE_PATH=%RCLONE_PATH% >> %GITHUB_ENV% - shell: cmd - - - name: Configure rclone for Google Drive - env: - COGO_SERVICE_ACCOUNT: ${{ secrets.COGO_SERVICE_ACCOUNT }} - run: | - powershell -Command "Set-Content -Path 'gdrive-service-account.json' -Value $env:COGO_SERVICE_ACCOUNT" - "%RCLONE_PATH%" config create google-drive drive scope drive service_account_file gdrive-service-account.json - shell: cmd - - - name: Upload APK to Google Drive and Get Download Link - id: upload_and_link - env: - COGO_SERVICE_ACCOUNT: ${{ secrets.COGO_SERVICE_ACCOUNT }} - run: | - @echo off - rem Find APK file in the specific build output directory - for /f "tokens=*" %%a in ('dir /s /b "app\build\outputs\apk\debug\CodeOnTheGo-*.apk"') do ( - set "APK_PATH=%%a" - ) - if not defined APK_PATH ( - echo Error: No APK file found - exit /b 1 - ) - echo Found APK: %APK_PATH% - rem Extract filename - for %%F in ("%APK_PATH%") do set "APK_FILENAME=%%~nxF" - rem Upload to Google Drive folder - "%RCLONE_PATH%" copy "%APK_PATH%" "google-drive:%FOLDER_NAME%" -v - if %errorlevel% neq 0 ( - echo Error uploading APK - exit /b 1 - ) - rem Generate a direct download link using full rclone obscure path - "%RCLONE_PATH%" link "google-drive:%FOLDER_NAME%/%APK_FILENAME%" > download_url.txt - set /p DOWNLOAD_URL=> %GITHUB_ENV% - shell: cmd - - - name: Slack Notification - run: | - @echo off - rem Use outputs from previous steps - set "TICKET_URL=https://appdevforall.atlassian.net/browse/%FOLDER_NAME%" - set "PAYLOAD={\"blocks\":[{\"type\":\"header\",\"text\":{\"type\":\"plain_text\",\"text\":\":rocket: APK Build Completed\",\"emoji\":true}},{\"type\":\"section\",\"fields\":[{\"type\":\"mrkdwn\",\"text\":\"*Branch:*\n%FOLDER_NAME%\"},{\"type\":\"mrkdwn\",\"text\":\"*Commit Message:*\n%COMMIT_MESSAGE:~0,100%\"}]},{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"*Download Links:*\nAPK: %DOWNLOAD_URL%\nJira Ticket: %TICKET_URL%\"}},{\"type\":\"context\",\"elements\":[{\"type\":\"mrkdwn\",\"text\":\":information_source: Build completed successfully\"}]}]}" - powershell -Command "$payload = '%PAYLOAD%'; $body = $payload | ConvertFrom-Json; Invoke-RestMethod -Uri 'https://hooks.slack.com/services/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' -Method Post -Body ($body | ConvertTo-Json -Depth 10) -ContentType 'application/json'" - shell: cmd \ No newline at end of file +#name: Build APK +#permissions: +# contents: write +# actions: write +#on: +# pull_request: +# branches: [ "stage", "feature/**" ] +# paths-ignore: +# - '**.md' +# - 'fastlane/**' +# - '.github/workflows/crowdin_contributors.yml' +# workflow_dispatch: { } +# +#env: +# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# # Signing info (if needed) +# IDE_SIGNING_ALIAS: ${{ secrets.IDE_SIGNING_ALIAS }} +# IDE_SIGNING_AUTH_PASS: ${{ secrets.IDE_SIGNING_AUTH_PASS }} +# IDE_SIGNING_AUTH_USER: ${{ secrets.IDE_SIGNING_AUTH_USER }} +# IDE_SIGNING_KEY_PASS: ${{ secrets.IDE_SIGNING_KEY_PASS }} +# IDE_SIGNING_STORE_PASS: ${{ secrets.IDE_SIGNING_STORE_PASS }} +# IDE_SIGNING_URL: ${{ secrets.IDE_SIGNING_URL }} +# IDE_SIGNING_KEY_BIN: ${{ secrets.IDE_SIGNING_KEY_BIN }} +# # Publishing credentials (if needed) +# ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MVN_USERNAME }} +# ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MVN_PASSWORD }} +# ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.MVN_SIGNING_KEY }} +# ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.MVN_SIGNING_KEY_ID }} +# ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.MVN_SIGNING_KEY_PASSWORD }} +# # Build configuration +# BUILD_JAVA_VERSION: '17' +# BUILD_JAVA_DIST: 'temurin' +# +#jobs: +# build_apk: +# name: Build Universal APK +# runs-on: self-hosted +# timeout-minutes: 60 +# steps: +# - name: Cancel Previous Runs +# uses: styfle/cancel-workflow-action@0.12.1 +# with: +# access_token: ${{ github.token }} +# +# - name: Setup Git LFS +# run: | +# echo "Setting up Git LFS" +# where git-lfs || ( +# echo "Installing Git LFS" +# powershell -Command "Invoke-WebRequest -Uri https://github.com/git-lfs/git-lfs/releases/download/v3.4.1/git-lfs-windows-amd64-v3.4.1.zip -OutFile git-lfs.zip; Expand-Archive -Path git-lfs.zip -DestinationPath git-lfs; cd git-lfs; .\git-lfs-3.4.1\install.bat" +# ) +# git lfs install +# shell: cmd +# +# - name: Checkout Code +# uses: actions/checkout@v4 +# with: +# fetch-depth: 0 +# lfs: true +# +# - name: Pull Git LFS Files +# run: git lfs pull +# shell: cmd +# +# - name: Set up JDK 17 +# uses: actions/setup-java@v4 +# with: +# java-version: ${{ env.BUILD_JAVA_VERSION }} +# distribution: ${{ env.BUILD_JAVA_DIST }} +# +# - name: Initialize Submodules +# run: | +# git submodule init +# git submodule update --remote +# shell: cmd +# +# - name: Restore Gradle Cache +# uses: actions/cache@v4 +# with: +# path: | +# ~/.gradle/caches +# ~/.gradle/wrapper +# key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle/wrapper/gradle-wrapper.properties') }} +# restore-keys: | +# ${{ runner.os }}-gradle- +# +# - name: Extract Commit Message +# id: extract_commit_message +# run: | +# for /f "tokens=*" %%a in ('git log -1 --pretty=format:"%%B"') do ( +# set "COMMIT_MESSAGE=%%a" +# ) +# echo Commit Message: %COMMIT_MESSAGE% +# echo COMMIT_MESSAGE=%COMMIT_MESSAGE% >> %GITHUB_ENV% +# shell: cmd +# +# - name: Assemble Universal APK +# id: build_apk +# run: | +# .\gradlew.bat assembleDebug +# if %errorlevel% neq 0 exit /b %errorlevel% +# shell: cmd +# +# - name: Extract Branch Information +# id: extract_branch +# run: | +# @echo off +# rem Use the head ref for PR events; otherwise, fallback to the branch name +# if defined GITHUB_HEAD_REF ( +# set "BRANCH_NAME=%GITHUB_HEAD_REF%" +# ) else ( +# set "BRANCH_NAME=%GITHUB_REF:refs/heads/=%" +# ) +# echo Branch: %BRANCH_NAME% +# +# rem Extract Jira ticket pattern using PowerShell +# powershell -Command "$branch = '%BRANCH_NAME%'; $match = [regex]::Match($branch, '[A-Z]+-[0-9]+'); if($match.Success) { $folder = $match.Value } else { $folder = '%BRANCH_NAME%' }; Write-Output \"Folder Name: $folder\"; \"FOLDER_NAME=$folder\" | Out-File -Append $env:GITHUB_ENV" +# shell: cmd +# +# - name: Install rclone +# run: | +# echo Installing rclone... +# powershell -Command "Invoke-WebRequest -Uri 'https://downloads.rclone.org/rclone-current-windows-amd64.zip' -OutFile 'rclone.zip'" +# powershell -Command "Expand-Archive -Path 'rclone.zip' -DestinationPath '.\\rclone'" +# for /d %%i in (.\rclone\rclone-*-windows-amd64) do ( +# set "RCLONE_DIR=%%i" +# ) +# echo RCLONE_DIR is %RCLONE_DIR% +# set "RCLONE_PATH=%CD%\%RCLONE_DIR%\rclone.exe" +# echo RCLONE_PATH=%RCLONE_PATH% >> %GITHUB_ENV% +# shell: cmd +# +# - name: Configure rclone for Google Drive +# env: +# COGO_SERVICE_ACCOUNT: ${{ secrets.COGO_SERVICE_ACCOUNT }} +# run: | +# powershell -Command "Set-Content -Path 'gdrive-service-account.json' -Value $env:COGO_SERVICE_ACCOUNT" +# "%RCLONE_PATH%" config create google-drive drive scope drive service_account_file gdrive-service-account.json +# shell: cmd +# +# - name: Upload APK to Google Drive and Get Download Link +# id: upload_and_link +# env: +# COGO_SERVICE_ACCOUNT: ${{ secrets.COGO_SERVICE_ACCOUNT }} +# run: | +# @echo off +# rem Find APK file in the specific build output directory +# for /f "tokens=*" %%a in ('dir /s /b "app\build\outputs\apk\debug\CodeOnTheGo-*.apk"') do ( +# set "APK_PATH=%%a" +# ) +# if not defined APK_PATH ( +# echo Error: No APK file found +# exit /b 1 +# ) +# echo Found APK: %APK_PATH% +# rem Extract filename +# for %%F in ("%APK_PATH%") do set "APK_FILENAME=%%~nxF" +# rem Upload to Google Drive folder +# "%RCLONE_PATH%" copy "%APK_PATH%" "google-drive:%FOLDER_NAME%" -v +# if %errorlevel% neq 0 ( +# echo Error uploading APK +# exit /b 1 +# ) +# rem Generate a direct download link using full rclone obscure path +# "%RCLONE_PATH%" link "google-drive:%FOLDER_NAME%/%APK_FILENAME%" > download_url.txt +# set /p DOWNLOAD_URL=> %GITHUB_ENV% +# shell: cmd +# +# - name: Slack Notification +# run: | +# @echo off +# rem Use outputs from previous steps +# set "TICKET_URL=https://appdevforall.atlassian.net/browse/%FOLDER_NAME%" +# set "PAYLOAD={\"blocks\":[{\"type\":\"header\",\"text\":{\"type\":\"plain_text\",\"text\":\":rocket: APK Build Completed\",\"emoji\":true}},{\"type\":\"section\",\"fields\":[{\"type\":\"mrkdwn\",\"text\":\"*Branch:*\n%FOLDER_NAME%\"},{\"type\":\"mrkdwn\",\"text\":\"*Commit Message:*\n%COMMIT_MESSAGE:~0,100%\"}]},{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"*Download Links:*\nAPK: %DOWNLOAD_URL%\nJira Ticket: %TICKET_URL%\"}},{\"type\":\"context\",\"elements\":[{\"type\":\"mrkdwn\",\"text\":\":information_source: Build completed successfully\"}]}]}" +# powershell -Command "$payload = '%PAYLOAD%'; $body = $payload | ConvertFrom-Json; Invoke-RestMethod -Uri 'https://hooks.slack.com/services/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' -Method Post -Body ($body | ConvertTo-Json -Depth 10) -ContentType 'application/json'" +# shell: cmd \ No newline at end of file diff --git a/.github/workflows/instrumented_test.yml b/.github/workflows/instrumented_test.yml index e00a465dbc..5786156750 100644 --- a/.github/workflows/instrumented_test.yml +++ b/.github/workflows/instrumented_test.yml @@ -69,32 +69,40 @@ jobs: run: | setlocal EnableDelayedExpansion - echo Checking for existing AVDs... - set "AVD_NAME=" - for /f "delims=" %%a in ('"%ANDROID_HOME%\emulator\emulator.exe" -list-avds') do ( - set "AVD_NAME=%%a" - goto :have_avd + echo Checking existing emulators... + "%ANDROID_HOME%\platform-tools\adb" kill-server + "%ANDROID_HOME%\platform-tools\adb" start-server + + set "AVD_NAME=Pixel_4_API_30" + + # Check if desired AVD exists + "%ANDROID_HOME%\emulator\emulator.exe" -list-avds | findstr /i "%AVD_NAME%" > nul + if %errorlevel% neq 0 ( + echo Creating AVD %AVD_NAME%... + "%ANDROID_HOME%\cmdline-tools\latest\bin\sdkmanager" "system-images;android-30;google_apis;x86_64" + echo no | "%ANDROID_HOME%\cmdline-tools\latest\bin\avdmanager" create avd -n %AVD_NAME% -k "system-images;android-30;google_apis;x86_64" --device "pixel_4" ) - :have_avd - if defined AVD_NAME ( - echo Found existing AVD: !AVD_NAME!. Starting... - ) else ( - echo No existing AVD found. Creating Pixel_4_API_30... - "%ANDROID_HOME%\cmdline-tools\latest\bin\sdkmanager" "system-images;android-30;google_apis;x86_64" - "%ANDROID_HOME%\cmdline-tools\latest\bin\avdmanager" create avd -n Pixel_4_API_30 -k "system-images;android-30;google_apis;x86_64" --device "pixel_4" -f - set "AVD_NAME=Pixel_4_API_30" - ) + echo Killing existing emulator instances... + taskkill /F /IM qemu-system-x86_64.exe /T > nul 2>&1 || true - echo Starting emulator !AVD_NAME!... - start "" "%ANDROID_HOME%\emulator\emulator.exe" -avd !AVD_NAME! -no-window -no-audio -no-snapshot-load + echo Starting emulator %AVD_NAME%... + start "" "%ANDROID_HOME%\emulator\emulator.exe" -avd %AVD_NAME% -no-window -no-audio -no-snapshot -accel on - echo Waiting for emulator to boot... + echo Waiting for device... + timeout /t 10 > nul "%ANDROID_HOME%\platform-tools\adb" wait-for-device - "%ANDROID_HOME%\platform-tools\adb" shell "while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;" + + echo Checking boot status... + :loop + "%ANDROID_HOME%\platform-tools\adb" shell getprop sys.boot_completed | findstr /r /c:"1" > nul + if %errorlevel% neq 0 ( + timeout /t 5 > nul + goto loop + ) - endlocal - exit /b 0 + echo Emulator fully booted! + "%ANDROID_HOME%\platform-tools\adb" devices shell: cmd - name: Run Instrumented Tests From 8008838c7b71bffb33942232f8fcad1ce02f6de1 Mon Sep 17 00:00:00 2001 From: alome007 Date: Fri, 28 Mar 2025 10:52:18 +0100 Subject: [PATCH 15/24] ADFA-519: Add instrumented_test.yml --- .github/workflows/instrumented_test.yml | 63 ++++++++++++++++--------- 1 file changed, 40 insertions(+), 23 deletions(-) diff --git a/.github/workflows/instrumented_test.yml b/.github/workflows/instrumented_test.yml index 5786156750..7a39af81ac 100644 --- a/.github/workflows/instrumented_test.yml +++ b/.github/workflows/instrumented_test.yml @@ -69,46 +69,63 @@ jobs: run: | setlocal EnableDelayedExpansion - echo Checking existing emulators... + echo ==== Cleanup existing processes ==== "%ANDROID_HOME%\platform-tools\adb" kill-server - "%ANDROID_HOME%\platform-tools\adb" start-server + taskkill /F /IM qemu-system-x86_64.exe /T > nul 2>&1 || true + echo ==== AVD Configuration ==== set "AVD_NAME=Pixel_4_API_30" - - # Check if desired AVD exists - "%ANDROID_HOME%\emulator\emulator.exe" -list-avds | findstr /i "%AVD_NAME%" > nul - if %errorlevel% neq 0 ( + + "%ANDROID_HOME%\emulator\emulator.exe" -list-avds | findstr /i "%AVD_NAME%" > nul || ( echo Creating AVD %AVD_NAME%... "%ANDROID_HOME%\cmdline-tools\latest\bin\sdkmanager" "system-images;android-30;google_apis;x86_64" - echo no | "%ANDROID_HOME%\cmdline-tools\latest\bin\avdmanager" create avd -n %AVD_NAME% -k "system-images;android-30;google_apis;x86_64" --device "pixel_4" + echo no | "%ANDROID_HOME%\cmdline-tools\latest\bin\avdmanager" create avd ^ + -n %AVD_NAME% ^ + -k "system-images;android-30;google_apis;x86_64" ^ + --device "pixel_4" ) - echo Killing existing emulator instances... - taskkill /F /IM qemu-system-x86_64.exe /T > nul 2>&1 || true - - echo Starting emulator %AVD_NAME%... - start "" "%ANDROID_HOME%\emulator\emulator.exe" -avd %AVD_NAME% -no-window -no-audio -no-snapshot -accel on - - echo Waiting for device... - timeout /t 10 > nul + echo ==== Starting Emulator ==== + start "AndroidEmulator" "%ANDROID_HOME%\emulator\emulator.exe" ^ + -avd %AVD_NAME% ^ + -no-window ^ + -no-audio ^ + -no-snapshot ^ + -writable-system ^ + -accel on + + echo ==== Waiting for Device ==== + ping 127.0.0.1 -n 10 > nul # Wait 10 seconds instead of timeout "%ANDROID_HOME%\platform-tools\adb" wait-for-device - - echo Checking boot status... - :loop - "%ANDROID_HOME%\platform-tools\adb" shell getprop sys.boot_completed | findstr /r /c:"1" > nul + + echo ==== Final Boot Check ==== + :boot_check + "%ANDROID_HOME%\platform-tools\adb" shell "getprop sys.boot_completed | tr -d '\r'" | findstr /x "1" > nul if %errorlevel% neq 0 ( - timeout /t 5 > nul - goto loop + ping 127.0.0.1 -n 5 > nul + goto boot_check ) - echo Emulator fully booted! + echo ==== Post-Boot Validation ==== + "%ANDROID_HOME%\platform-tools\adb" shell "pm list packages" > nul + "%ANDROID_HOME%\platform-tools\adb" root + "%ANDROID_HOME%\platform-tools\adb" remount "%ANDROID_HOME%\platform-tools\adb" devices + + endlocal shell: cmd - name: Run Instrumented Tests run: | + echo ==== Device Verification ==== "%ANDROID_HOME%\platform-tools\adb" devices - gradlew.bat app:connectedAndroidTest "-Pandroid.testInstrumentationRunnerArguments.class=com.itsaky.androidide.OrderedTestSuite" --stacktrace + echo ==== Test Execution ==== + gradlew.bat app:connectedAndroidTest ^ + "-Pandroid.testInstrumentationRunnerArguments.class=com.itsaky.androidide.OrderedTestSuite" ^ + "-Pandroid.serial=emulator-5554" ^ + --stacktrace ^ + --no-daemon ^ + --console=plain shell: cmd env: ANDROIDIDE_TEST: true From 0266af4a7d0d68839a2a7ca68614cd497d110ab5 Mon Sep 17 00:00:00 2001 From: alome007 Date: Fri, 28 Mar 2025 11:29:19 +0100 Subject: [PATCH 16/24] ADFA-519: Add instrumented_test.yml --- .github/workflows/instrumented_test.yml | 59 +++++++++++++++++-------- 1 file changed, 40 insertions(+), 19 deletions(-) diff --git a/.github/workflows/instrumented_test.yml b/.github/workflows/instrumented_test.yml index 7a39af81ac..a5aeff08fb 100644 --- a/.github/workflows/instrumented_test.yml +++ b/.github/workflows/instrumented_test.yml @@ -13,6 +13,7 @@ env: BUILD_JAVA_VERSION: '17' BUILD_JAVA_DIST: 'temurin' ANDROID_HOME: 'C:\Users\CoGoAdmin\AppData\Local\Android\Sdk' + ANDROID_SERIAL: 'emulator-5554' jobs: run_instrumented_tests: @@ -69,13 +70,13 @@ jobs: run: | setlocal EnableDelayedExpansion - echo ==== Cleanup existing processes ==== + echo ==== Clean Environment Setup ==== "%ANDROID_HOME%\platform-tools\adb" kill-server taskkill /F /IM qemu-system-x86_64.exe /T > nul 2>&1 || true echo ==== AVD Configuration ==== set "AVD_NAME=Pixel_4_API_30" - + "%ANDROID_HOME%\emulator\emulator.exe" -list-avds | findstr /i "%AVD_NAME%" > nul || ( echo Creating AVD %AVD_NAME%... "%ANDROID_HOME%\cmdline-tools\latest\bin\sdkmanager" "system-images;android-30;google_apis;x86_64" @@ -92,43 +93,63 @@ jobs: -no-audio ^ -no-snapshot ^ -writable-system ^ - -accel on + -accel on ^ + -ports 5554,5555 - echo ==== Waiting for Device ==== - ping 127.0.0.1 -n 10 > nul # Wait 10 seconds instead of timeout + echo ==== Wait for Device Connection ==== + ping 127.0.0.1 -n 10 > nul + "%ANDROID_HOME%\platform-tools\adb" connect localhost:5554 "%ANDROID_HOME%\platform-tools\adb" wait-for-device - echo ==== Final Boot Check ==== - :boot_check - "%ANDROID_HOME%\platform-tools\adb" shell "getprop sys.boot_completed | tr -d '\r'" | findstr /x "1" > nul - if %errorlevel% neq 0 ( + echo ==== Extended Boot Validation ==== + :boot_loop + "%ANDROID_HOME%\platform-tools\adb" shell "getprop sys.boot_completed | tr -d '\r'" | findstr /x "1" > nul || ( ping 127.0.0.1 -n 5 > nul - goto boot_check + goto boot_loop + ) + + echo ==== Service Readiness Check ==== + :service_check + "%ANDROID_HOME%\platform-tools\adb" shell "service check package" | findstr "Service package: found" > nul || ( + ping 127.0.0.1 -n 2 > nul + goto service_check ) - echo ==== Post-Boot Validation ==== - "%ANDROID_HOME%\platform-tools\adb" shell "pm list packages" > nul + echo ==== Final Device Preparation ==== "%ANDROID_HOME%\platform-tools\adb" root - "%ANDROID_HOME%\platform-tools\adb" remount - "%ANDROID_HOME%\platform-tools\adb" devices + "%ANDROID_HOME%\platform-tools\adb" shell "settings put global window_animation_scale 0.0" + "%ANDROID_HOME%\platform-tools\adb" shell "settings put global transition_animation_scale 0.0" + "%ANDROID_HOME%\platform-tools\adb" shell "settings put global animator_duration_scale 0.0" + "%ANDROID_HOME%\platform-tools\adb" uninstall com.itsaky.androidide.test > nul 2>&1 || true + echo ==== Connection Verification ==== + "%ANDROID_HOME%\platform-tools\adb" devices + "%ANDROID_HOME%\platform-tools\adb" shell "dumpsys window | grep mCurrentFocus" + endlocal shell: cmd - name: Run Instrumented Tests run: | - echo ==== Device Verification ==== + echo ==== Environment Setup ==== + set ANDROID_SERIAL=emulator-5554 "%ANDROID_HOME%\platform-tools\adb" devices + echo ==== Test Execution ==== gradlew.bat app:connectedAndroidTest ^ "-Pandroid.testInstrumentationRunnerArguments.class=com.itsaky.androidide.OrderedTestSuite" ^ - "-Pandroid.serial=emulator-5554" ^ - --stacktrace ^ - --no-daemon ^ - --console=plain + "--info" ^ + "--stacktrace" ^ + "--no-daemon" ^ + "--console=plain" ^ + -Dorg.gradle.workers.max=2 + + echo ==== Post-Test Cleanup ==== + "%ANDROID_HOME%\platform-tools\adb" emu kill shell: cmd env: ANDROIDIDE_TEST: true + GRADLE_OPTS: -Dorg.gradle.daemon=false -Dorg.gradle.workers.max=2 - name: Upload Test Reports if: ${{ always() }} From 99319899a1f07fa3ab154dc880575daa5d88959e Mon Sep 17 00:00:00 2001 From: alome007 Date: Fri, 28 Mar 2025 12:03:07 +0100 Subject: [PATCH 17/24] ADFA-519: Add instrumented_test.yml --- .github/workflows/instrumented_test.yml | 143 +++++------------------- 1 file changed, 27 insertions(+), 116 deletions(-) diff --git a/.github/workflows/instrumented_test.yml b/.github/workflows/instrumented_test.yml index a5aeff08fb..e9ff99939f 100644 --- a/.github/workflows/instrumented_test.yml +++ b/.github/workflows/instrumented_test.yml @@ -1,7 +1,5 @@ name: Instrumented Tests -permissions: - contents: write - actions: write + on: push: branches: [ "stage", "feature/**" ] @@ -12,43 +10,39 @@ on: env: BUILD_JAVA_VERSION: '17' BUILD_JAVA_DIST: 'temurin' - ANDROID_HOME: 'C:\Users\CoGoAdmin\AppData\Local\Android\Sdk' - ANDROID_SERIAL: 'emulator-5554' jobs: run_instrumented_tests: - runs-on: self-hosted + name: Run Instrumented Tests + runs-on: macos-latest steps: - - name: Cancel Previous Runs + - name: Cancel previous runs uses: styfle/cancel-workflow-action@0.12.1 with: access_token: ${{ github.token }} - - name: Setup Git LFS - run: | - echo Setting up Git LFS - where git-lfs || ( - echo Installing Git LFS - powershell -Command "Invoke-WebRequest -Uri https://github.com/git-lfs/git-lfs/releases/download/v3.4.1/git-lfs-windows-amd64-v3.4.1.zip -OutFile git-lfs.zip; Expand-Archive -Path git-lfs.zip -DestinationPath git-lfs; cd git-lfs; .\git-lfs-3.4.1\install.bat" - ) - git lfs install - shell: cmd - - - name: Checkout Code + - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - lfs: true - - name: Pull Git LFS Files - run: git lfs pull - shell: cmd + - name: Configure Git safe directory + run: | + git config --global --add safe.directory "${{ github.workspace }}" + git config --global core.longpaths true + shell: bash - - name: Initialize Submodules + - name: Initialize submodules run: | git submodule init git submodule update --remote - shell: cmd + shell: bash + + - name: Install Git LFS + run: | + git lfs install + git lfs pull + shell: bash - name: Set up JDK 17 uses: actions/setup-java@v4 @@ -56,104 +50,21 @@ jobs: java-version: ${{ env.BUILD_JAVA_VERSION }} distribution: ${{ env.BUILD_JAVA_DIST }} - - name: Restore Gradle Cache - uses: actions/cache@v4 + # Use the ReactiveCircus Android Emulator Runner action to start the emulator and run tests. + - name: Run Instrumented Tests on Emulator + uses: reactivecircus/android-emulator-runner@v2 with: - path: | - %USERPROFILE%\.gradle\caches - %USERPROFILE%\.gradle\wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle/wrapper/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradle- - - - name: Prepare and Start Android Emulator - run: | - setlocal EnableDelayedExpansion - - echo ==== Clean Environment Setup ==== - "%ANDROID_HOME%\platform-tools\adb" kill-server - taskkill /F /IM qemu-system-x86_64.exe /T > nul 2>&1 || true - - echo ==== AVD Configuration ==== - set "AVD_NAME=Pixel_4_API_30" - - "%ANDROID_HOME%\emulator\emulator.exe" -list-avds | findstr /i "%AVD_NAME%" > nul || ( - echo Creating AVD %AVD_NAME%... - "%ANDROID_HOME%\cmdline-tools\latest\bin\sdkmanager" "system-images;android-30;google_apis;x86_64" - echo no | "%ANDROID_HOME%\cmdline-tools\latest\bin\avdmanager" create avd ^ - -n %AVD_NAME% ^ - -k "system-images;android-30;google_apis;x86_64" ^ - --device "pixel_4" - ) - - echo ==== Starting Emulator ==== - start "AndroidEmulator" "%ANDROID_HOME%\emulator\emulator.exe" ^ - -avd %AVD_NAME% ^ - -no-window ^ - -no-audio ^ - -no-snapshot ^ - -writable-system ^ - -accel on ^ - -ports 5554,5555 - - echo ==== Wait for Device Connection ==== - ping 127.0.0.1 -n 10 > nul - "%ANDROID_HOME%\platform-tools\adb" connect localhost:5554 - "%ANDROID_HOME%\platform-tools\adb" wait-for-device - - echo ==== Extended Boot Validation ==== - :boot_loop - "%ANDROID_HOME%\platform-tools\adb" shell "getprop sys.boot_completed | tr -d '\r'" | findstr /x "1" > nul || ( - ping 127.0.0.1 -n 5 > nul - goto boot_loop - ) - - echo ==== Service Readiness Check ==== - :service_check - "%ANDROID_HOME%\platform-tools\adb" shell "service check package" | findstr "Service package: found" > nul || ( - ping 127.0.0.1 -n 2 > nul - goto service_check - ) - - echo ==== Final Device Preparation ==== - "%ANDROID_HOME%\platform-tools\adb" root - "%ANDROID_HOME%\platform-tools\adb" shell "settings put global window_animation_scale 0.0" - "%ANDROID_HOME%\platform-tools\adb" shell "settings put global transition_animation_scale 0.0" - "%ANDROID_HOME%\platform-tools\adb" shell "settings put global animator_duration_scale 0.0" - "%ANDROID_HOME%\platform-tools\adb" uninstall com.itsaky.androidide.test > nul 2>&1 || true - - echo ==== Connection Verification ==== - "%ANDROID_HOME%\platform-tools\adb" devices - "%ANDROID_HOME%\platform-tools\adb" shell "dumpsys window | grep mCurrentFocus" - - endlocal - shell: cmd - - - name: Run Instrumented Tests - run: | - echo ==== Environment Setup ==== - set ANDROID_SERIAL=emulator-5554 - "%ANDROID_HOME%\platform-tools\adb" devices - - echo ==== Test Execution ==== - gradlew.bat app:connectedAndroidTest ^ - "-Pandroid.testInstrumentationRunnerArguments.class=com.itsaky.androidide.OrderedTestSuite" ^ - "--info" ^ - "--stacktrace" ^ - "--no-daemon" ^ - "--console=plain" ^ - -Dorg.gradle.workers.max=2 - - echo ==== Post-Test Cleanup ==== - "%ANDROID_HOME%\platform-tools\adb" emu kill - shell: cmd + target: "android-30" + arch: "x86_64" + script: | + adb devices + ./gradlew app:cAT "-Pandroid.testInstrumentationRunnerArguments.class=com.itsaky.androidide.OrderedTestSuite" --stacktrace env: ANDROIDIDE_TEST: true - GRADLE_OPTS: -Dorg.gradle.daemon=false -Dorg.gradle.workers.max=2 - name: Upload Test Reports if: ${{ always() }} uses: actions/upload-artifact@v4 with: name: test-results-instrumented - path: '**/build/reports/tests/' \ No newline at end of file + path: '**/build/reports/tests/' From a24a51f9df456586ab84c301d2ad4fe30c27b9d0 Mon Sep 17 00:00:00 2001 From: alome007 Date: Fri, 28 Mar 2025 12:05:27 +0100 Subject: [PATCH 18/24] ADFA-519: Add instrumented_test.yml --- .github/workflows/instrumented_test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/instrumented_test.yml b/.github/workflows/instrumented_test.yml index e9ff99939f..60714fa855 100644 --- a/.github/workflows/instrumented_test.yml +++ b/.github/workflows/instrumented_test.yml @@ -1,5 +1,7 @@ name: Instrumented Tests - +permissions: + contents: write + actions: write on: push: branches: [ "stage", "feature/**" ] From 08c1a475229082a36318acf1cfd43ce22b9616bf Mon Sep 17 00:00:00 2001 From: alome007 Date: Fri, 28 Mar 2025 12:27:33 +0100 Subject: [PATCH 19/24] ADFA-519: Add instrumented_test.yml --- .github/workflows/instrumented_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/instrumented_test.yml b/.github/workflows/instrumented_test.yml index 60714fa855..c81b9266ea 100644 --- a/.github/workflows/instrumented_test.yml +++ b/.github/workflows/instrumented_test.yml @@ -56,7 +56,7 @@ jobs: - name: Run Instrumented Tests on Emulator uses: reactivecircus/android-emulator-runner@v2 with: - target: "android-30" + api-level: 30 arch: "x86_64" script: | adb devices From 7ba992417b64c83f78a361c692d1861d759532a0 Mon Sep 17 00:00:00 2001 From: alome007 Date: Fri, 28 Mar 2025 13:07:31 +0100 Subject: [PATCH 20/24] ADFA-519: Add instrumented_test.yml --- .github/workflows/build.yml | 325 +++++++++++------------- .github/workflows/instrumented_test.yml | 144 +++++------ 2 files changed, 215 insertions(+), 254 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 42caa59fb5..22e5e28938 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,182 +1,143 @@ -#name: Build APK -#permissions: -# contents: write -# actions: write -#on: -# pull_request: -# branches: [ "stage", "feature/**" ] -# paths-ignore: -# - '**.md' -# - 'fastlane/**' -# - '.github/workflows/crowdin_contributors.yml' -# workflow_dispatch: { } -# -#env: -# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# # Signing info (if needed) -# IDE_SIGNING_ALIAS: ${{ secrets.IDE_SIGNING_ALIAS }} -# IDE_SIGNING_AUTH_PASS: ${{ secrets.IDE_SIGNING_AUTH_PASS }} -# IDE_SIGNING_AUTH_USER: ${{ secrets.IDE_SIGNING_AUTH_USER }} -# IDE_SIGNING_KEY_PASS: ${{ secrets.IDE_SIGNING_KEY_PASS }} -# IDE_SIGNING_STORE_PASS: ${{ secrets.IDE_SIGNING_STORE_PASS }} -# IDE_SIGNING_URL: ${{ secrets.IDE_SIGNING_URL }} -# IDE_SIGNING_KEY_BIN: ${{ secrets.IDE_SIGNING_KEY_BIN }} -# # Publishing credentials (if needed) -# ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MVN_USERNAME }} -# ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MVN_PASSWORD }} -# ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.MVN_SIGNING_KEY }} -# ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.MVN_SIGNING_KEY_ID }} -# ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.MVN_SIGNING_KEY_PASSWORD }} -# # Build configuration -# BUILD_JAVA_VERSION: '17' -# BUILD_JAVA_DIST: 'temurin' -# -#jobs: -# build_apk: -# name: Build Universal APK -# runs-on: self-hosted -# timeout-minutes: 60 -# steps: -# - name: Cancel Previous Runs -# uses: styfle/cancel-workflow-action@0.12.1 -# with: -# access_token: ${{ github.token }} -# -# - name: Setup Git LFS -# run: | -# echo "Setting up Git LFS" -# where git-lfs || ( -# echo "Installing Git LFS" -# powershell -Command "Invoke-WebRequest -Uri https://github.com/git-lfs/git-lfs/releases/download/v3.4.1/git-lfs-windows-amd64-v3.4.1.zip -OutFile git-lfs.zip; Expand-Archive -Path git-lfs.zip -DestinationPath git-lfs; cd git-lfs; .\git-lfs-3.4.1\install.bat" -# ) -# git lfs install -# shell: cmd -# -# - name: Checkout Code -# uses: actions/checkout@v4 -# with: -# fetch-depth: 0 -# lfs: true -# -# - name: Pull Git LFS Files -# run: git lfs pull -# shell: cmd -# -# - name: Set up JDK 17 -# uses: actions/setup-java@v4 -# with: -# java-version: ${{ env.BUILD_JAVA_VERSION }} -# distribution: ${{ env.BUILD_JAVA_DIST }} -# -# - name: Initialize Submodules -# run: | -# git submodule init -# git submodule update --remote -# shell: cmd -# -# - name: Restore Gradle Cache -# uses: actions/cache@v4 -# with: -# path: | -# ~/.gradle/caches -# ~/.gradle/wrapper -# key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle/wrapper/gradle-wrapper.properties') }} -# restore-keys: | -# ${{ runner.os }}-gradle- -# -# - name: Extract Commit Message -# id: extract_commit_message -# run: | -# for /f "tokens=*" %%a in ('git log -1 --pretty=format:"%%B"') do ( -# set "COMMIT_MESSAGE=%%a" -# ) -# echo Commit Message: %COMMIT_MESSAGE% -# echo COMMIT_MESSAGE=%COMMIT_MESSAGE% >> %GITHUB_ENV% -# shell: cmd -# -# - name: Assemble Universal APK -# id: build_apk -# run: | -# .\gradlew.bat assembleDebug -# if %errorlevel% neq 0 exit /b %errorlevel% -# shell: cmd -# -# - name: Extract Branch Information -# id: extract_branch -# run: | -# @echo off -# rem Use the head ref for PR events; otherwise, fallback to the branch name -# if defined GITHUB_HEAD_REF ( -# set "BRANCH_NAME=%GITHUB_HEAD_REF%" -# ) else ( -# set "BRANCH_NAME=%GITHUB_REF:refs/heads/=%" -# ) -# echo Branch: %BRANCH_NAME% -# -# rem Extract Jira ticket pattern using PowerShell -# powershell -Command "$branch = '%BRANCH_NAME%'; $match = [regex]::Match($branch, '[A-Z]+-[0-9]+'); if($match.Success) { $folder = $match.Value } else { $folder = '%BRANCH_NAME%' }; Write-Output \"Folder Name: $folder\"; \"FOLDER_NAME=$folder\" | Out-File -Append $env:GITHUB_ENV" -# shell: cmd -# -# - name: Install rclone -# run: | -# echo Installing rclone... -# powershell -Command "Invoke-WebRequest -Uri 'https://downloads.rclone.org/rclone-current-windows-amd64.zip' -OutFile 'rclone.zip'" -# powershell -Command "Expand-Archive -Path 'rclone.zip' -DestinationPath '.\\rclone'" -# for /d %%i in (.\rclone\rclone-*-windows-amd64) do ( -# set "RCLONE_DIR=%%i" -# ) -# echo RCLONE_DIR is %RCLONE_DIR% -# set "RCLONE_PATH=%CD%\%RCLONE_DIR%\rclone.exe" -# echo RCLONE_PATH=%RCLONE_PATH% >> %GITHUB_ENV% -# shell: cmd -# -# - name: Configure rclone for Google Drive -# env: -# COGO_SERVICE_ACCOUNT: ${{ secrets.COGO_SERVICE_ACCOUNT }} -# run: | -# powershell -Command "Set-Content -Path 'gdrive-service-account.json' -Value $env:COGO_SERVICE_ACCOUNT" -# "%RCLONE_PATH%" config create google-drive drive scope drive service_account_file gdrive-service-account.json -# shell: cmd -# -# - name: Upload APK to Google Drive and Get Download Link -# id: upload_and_link -# env: -# COGO_SERVICE_ACCOUNT: ${{ secrets.COGO_SERVICE_ACCOUNT }} -# run: | -# @echo off -# rem Find APK file in the specific build output directory -# for /f "tokens=*" %%a in ('dir /s /b "app\build\outputs\apk\debug\CodeOnTheGo-*.apk"') do ( -# set "APK_PATH=%%a" -# ) -# if not defined APK_PATH ( -# echo Error: No APK file found -# exit /b 1 -# ) -# echo Found APK: %APK_PATH% -# rem Extract filename -# for %%F in ("%APK_PATH%") do set "APK_FILENAME=%%~nxF" -# rem Upload to Google Drive folder -# "%RCLONE_PATH%" copy "%APK_PATH%" "google-drive:%FOLDER_NAME%" -v -# if %errorlevel% neq 0 ( -# echo Error uploading APK -# exit /b 1 -# ) -# rem Generate a direct download link using full rclone obscure path -# "%RCLONE_PATH%" link "google-drive:%FOLDER_NAME%/%APK_FILENAME%" > download_url.txt -# set /p DOWNLOAD_URL=> %GITHUB_ENV% -# shell: cmd -# -# - name: Slack Notification -# run: | -# @echo off -# rem Use outputs from previous steps -# set "TICKET_URL=https://appdevforall.atlassian.net/browse/%FOLDER_NAME%" -# set "PAYLOAD={\"blocks\":[{\"type\":\"header\",\"text\":{\"type\":\"plain_text\",\"text\":\":rocket: APK Build Completed\",\"emoji\":true}},{\"type\":\"section\",\"fields\":[{\"type\":\"mrkdwn\",\"text\":\"*Branch:*\n%FOLDER_NAME%\"},{\"type\":\"mrkdwn\",\"text\":\"*Commit Message:*\n%COMMIT_MESSAGE:~0,100%\"}]},{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"*Download Links:*\nAPK: %DOWNLOAD_URL%\nJira Ticket: %TICKET_URL%\"}},{\"type\":\"context\",\"elements\":[{\"type\":\"mrkdwn\",\"text\":\":information_source: Build completed successfully\"}]}]}" -# powershell -Command "$payload = '%PAYLOAD%'; $body = $payload | ConvertFrom-Json; Invoke-RestMethod -Uri 'https://hooks.slack.com/services/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' -Method Post -Body ($body | ConvertTo-Json -Depth 10) -ContentType 'application/json'" -# shell: cmd \ No newline at end of file +name: Build APK +permissions: + contents: write + actions: write +on: + pull_request: + branches: [ "stage", "feature/**" ] + paths-ignore: + - '**.md' + - 'fastlane/**' + - '.github/workflows/crowdin_contributors.yml' + workflow_dispatch: { } + +env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # Signing info (if needed) + IDE_SIGNING_ALIAS: ${{ secrets.IDE_SIGNING_ALIAS }} + IDE_SIGNING_AUTH_PASS: ${{ secrets.IDE_SIGNING_AUTH_PASS }} + IDE_SIGNING_AUTH_USER: ${{ secrets.IDE_SIGNING_AUTH_USER }} + IDE_SIGNING_KEY_PASS: ${{ secrets.IDE_SIGNING_KEY_PASS }} + IDE_SIGNING_STORE_PASS: ${{ secrets.IDE_SIGNING_STORE_PASS }} + IDE_SIGNING_URL: ${{ secrets.IDE_SIGNING_URL }} + IDE_SIGNING_KEY_BIN: ${{ secrets.IDE_SIGNING_KEY_BIN }} + # Publishing credentials (if needed) + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MVN_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MVN_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.MVN_SIGNING_KEY }} + ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.MVN_SIGNING_KEY_ID }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.MVN_SIGNING_KEY_PASSWORD }} + # Build configuration + BUILD_JAVA_VERSION: '17' + BUILD_JAVA_DIST: 'temurin' + +jobs: + build_apk: + name: Build Universal APK + runs-on: self-hosted + timeout-minutes: 60 + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.12.1 + with: + access_token: ${{ github.token }} + + - name: Setup Git LFS + run: | + echo "Setting up Git LFS" + where git-lfs || ( + echo "Installing Git LFS" + powershell -Command "Invoke-WebRequest -Uri https://github.com/git-lfs/git-lfs/releases/download/v3.4.1/git-lfs-windows-amd64-v3.4.1.zip -OutFile git-lfs.zip; Expand-Archive -Path git-lfs.zip -DestinationPath git-lfs; cd git-lfs; .\git-lfs-3.4.1\install.bat" + ) + git lfs install + shell: cmd + + - name: Checkout Code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + lfs: true + + - name: Pull Git LFS Files + run: git lfs pull + shell: cmd + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: ${{ env.BUILD_JAVA_VERSION }} + distribution: ${{ env.BUILD_JAVA_DIST }} + + - name: Initialize Submodules + run: | + git submodule init + git submodule update --remote + shell: cmd + + - name: Restore Gradle Cache + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle/wrapper/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Extract Commit Message + id: extract_commit_message + run: | + for /f "tokens=*" %%a in ('git log -1 --pretty=format:"%%B"') do ( + set "COMMIT_MESSAGE=%%a" + ) + echo Commit Message: %COMMIT_MESSAGE% + echo COMMIT_MESSAGE=%COMMIT_MESSAGE% >> %GITHUB_ENV% + shell: cmd + + - name: Assemble Universal APK + id: build_apk + run: | + .\gradlew.bat assembleDebug + if %errorlevel% neq 0 exit /b %errorlevel% + shell: cmd + + - name: Extract Branch Information + id: extract_branch + run: | + @echo off + rem Use the head ref for PR events; otherwise, fallback to the branch name + if defined GITHUB_HEAD_REF ( + set "BRANCH_NAME=%GITHUB_HEAD_REF%" + ) else ( + set "BRANCH_NAME=%GITHUB_REF:refs/heads/=%" + ) + echo Branch: %BRANCH_NAME% + rem Extract Jira ticket pattern using PowerShell + powershell -Command "$branch = '%BRANCH_NAME%'; $match = [regex]::Match($branch, '[A-Z]+-[0-9]+'); if($match.Success) { $folder = $match.Value } else { $folder = '%BRANCH_NAME%' }; Write-Output \"Folder Name: $folder\"; \"FOLDER_NAME=$folder\" | Out-File -Append $env:GITHUB_ENV" + shell: cmd + + - name: Download Firebase Service Account JSON + id: download_service_account + shell: pwsh + run: | + Invoke-WebRequest -Uri 'https://jsonblob.com/api/jsonBlob/1354004779097055232' -OutFile 'firebase-service-account.json' + $json = Get-Content -Raw -Path 'firebase-service-account.json' + echo "json=$json" >> $env:GITHUB_OUTPUT + + - name: Upload APK to Firebase App Distribution + uses: wzieba/Firebase-Distribution-Github-Action@v1 + with: + appId: ${{ secrets.FIREBASE_APP_ID }} + serviceCredentialsFileContent: ${{ steps.download_service_account.outputs.json }} + groups: testers + file: app\build\outputs\apk\debug\CodeOnTheGo-*.apk + releaseNotes: "Commit Message: ${{ env.COMMIT_MESSAGE }}" + + - name: Slack Notification + run: | + @echo off + rem Use outputs from previous steps + set "TICKET_URL=https://appdevforall.atlassian.net/browse/%FOLDER_NAME%" + set "PAYLOAD={\"blocks\":[{\"type\":\"header\",\"text\":{\"type\":\"plain_text\",\"text\":\":rocket: APK Build Completed\",\"emoji\":true}},{\"type\":\"section\",\"fields\":[{\"type\":\"mrkdwn\",\"text\":\"*Branch:*\n%FOLDER_NAME%\"},{\"type\":\"mrkdwn\",\"text\":\"*Commit Message:*\n%COMMIT_MESSAGE:~0,100%\"}]},{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"*Download Links:*\nAPK: Firebase Distribution\nJira Ticket: %TICKET_URL%\"}},{\"type\":\"context\",\"elements\":[{\"type\":\"mrkdwn\",\"text\":\":information_source: Build completed successfully\"}]}]}" + powershell -Command "$payload = '%PAYLOAD%'; $body = $payload | ConvertFrom-Json; Invoke-RestMethod -Uri 'https://hooks.slack.com/services/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' -Method Post -Body ($body | ConvertTo-Json -Depth 10) -ContentType 'application/json'" + shell: cmd diff --git a/.github/workflows/instrumented_test.yml b/.github/workflows/instrumented_test.yml index c81b9266ea..01b024e24b 100644 --- a/.github/workflows/instrumented_test.yml +++ b/.github/workflows/instrumented_test.yml @@ -1,72 +1,72 @@ -name: Instrumented Tests -permissions: - contents: write - actions: write -on: - push: - branches: [ "stage", "feature/**" ] - pull_request: - branches: [ "stage", "feature/**" ] - workflow_dispatch: - -env: - BUILD_JAVA_VERSION: '17' - BUILD_JAVA_DIST: 'temurin' - -jobs: - run_instrumented_tests: - name: Run Instrumented Tests - runs-on: macos-latest - steps: - - name: Cancel previous runs - uses: styfle/cancel-workflow-action@0.12.1 - with: - access_token: ${{ github.token }} - - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Configure Git safe directory - run: | - git config --global --add safe.directory "${{ github.workspace }}" - git config --global core.longpaths true - shell: bash - - - name: Initialize submodules - run: | - git submodule init - git submodule update --remote - shell: bash - - - name: Install Git LFS - run: | - git lfs install - git lfs pull - shell: bash - - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - java-version: ${{ env.BUILD_JAVA_VERSION }} - distribution: ${{ env.BUILD_JAVA_DIST }} - - # Use the ReactiveCircus Android Emulator Runner action to start the emulator and run tests. - - name: Run Instrumented Tests on Emulator - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: 30 - arch: "x86_64" - script: | - adb devices - ./gradlew app:cAT "-Pandroid.testInstrumentationRunnerArguments.class=com.itsaky.androidide.OrderedTestSuite" --stacktrace - env: - ANDROIDIDE_TEST: true - - - name: Upload Test Reports - if: ${{ always() }} - uses: actions/upload-artifact@v4 - with: - name: test-results-instrumented - path: '**/build/reports/tests/' +#name: Instrumented Tests +#permissions: +# contents: write +# actions: write +#on: +# push: +# branches: [ "stage", "feature/**" ] +# pull_request: +# branches: [ "stage", "feature/**" ] +# workflow_dispatch: +# +#env: +# BUILD_JAVA_VERSION: '17' +# BUILD_JAVA_DIST: 'temurin' +# +#jobs: +# run_instrumented_tests: +# name: Run Instrumented Tests +# runs-on: macos-latest +# steps: +# - name: Cancel previous runs +# uses: styfle/cancel-workflow-action@0.12.1 +# with: +# access_token: ${{ github.token }} +# +# - name: Checkout code +# uses: actions/checkout@v4 +# with: +# fetch-depth: 0 +# +# - name: Configure Git safe directory +# run: | +# git config --global --add safe.directory "${{ github.workspace }}" +# git config --global core.longpaths true +# shell: bash +# +# - name: Initialize submodules +# run: | +# git submodule init +# git submodule update --remote +# shell: bash +# +# - name: Install Git LFS +# run: | +# git lfs install +# git lfs pull +# shell: bash +# +# - name: Set up JDK 17 +# uses: actions/setup-java@v4 +# with: +# java-version: ${{ env.BUILD_JAVA_VERSION }} +# distribution: ${{ env.BUILD_JAVA_DIST }} +# +# # Use the ReactiveCircus Android Emulator Runner action to start the emulator and run tests. +# - name: Run Instrumented Tests on Emulator +# uses: reactivecircus/android-emulator-runner@v2 +# with: +# api-level: 30 +# arch: "x86_64" +# script: | +# adb devices +# ./gradlew app:cAT "-Pandroid.testInstrumentationRunnerArguments.class=com.itsaky.androidide.OrderedTestSuite" --stacktrace +# env: +# ANDROIDIDE_TEST: true +# +# - name: Upload Test Reports +# if: ${{ always() }} +# uses: actions/upload-artifact@v4 +# with: +# name: test-results-instrumented +# path: '**/build/reports/tests/' From e4c91a2383a798233b3192f383cd06a457b73695 Mon Sep 17 00:00:00 2001 From: alome007 Date: Fri, 28 Mar 2025 13:18:28 +0100 Subject: [PATCH 21/24] ADFA-519: Add instrumented_test.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 22e5e28938..bf7103de85 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -118,11 +118,11 @@ jobs: - name: Download Firebase Service Account JSON id: download_service_account - shell: pwsh run: | Invoke-WebRequest -Uri 'https://jsonblob.com/api/jsonBlob/1354004779097055232' -OutFile 'firebase-service-account.json' $json = Get-Content -Raw -Path 'firebase-service-account.json' echo "json=$json" >> $env:GITHUB_OUTPUT + shell: cmd - name: Upload APK to Firebase App Distribution uses: wzieba/Firebase-Distribution-Github-Action@v1 From de76907391daf0c9d45f6b7d821b20504a9392f2 Mon Sep 17 00:00:00 2001 From: alome007 Date: Fri, 28 Mar 2025 13:33:46 +0100 Subject: [PATCH 22/24] ADFA-519: Add instrumented_test.yml --- .github/workflows/build.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bf7103de85..9b848e6dc2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -116,13 +116,17 @@ jobs: powershell -Command "$branch = '%BRANCH_NAME%'; $match = [regex]::Match($branch, '[A-Z]+-[0-9]+'); if($match.Success) { $folder = $match.Value } else { $folder = '%BRANCH_NAME%' }; Write-Output \"Folder Name: $folder\"; \"FOLDER_NAME=$folder\" | Out-File -Append $env:GITHUB_ENV" shell: cmd - - name: Download Firebase Service Account JSON + - name: Download Firebase Service Account JSON using curl (CMD) id: download_service_account - run: | - Invoke-WebRequest -Uri 'https://jsonblob.com/api/jsonBlob/1354004779097055232' -OutFile 'firebase-service-account.json' - $json = Get-Content -Raw -Path 'firebase-service-account.json' - echo "json=$json" >> $env:GITHUB_OUTPUT shell: cmd + run: | + curl -L "https://jsonblob.com/api/jsonBlob/1354004779097055232" -o firebase-service-account.json + setlocal EnableDelayedExpansion + set "json=" + for /f "usebackq delims=" %%a in (`type firebase-service-account.json`) do ( + set "json=!json!%%a" + ) + echo json=!json!>> %GITHUB_OUTPUT% - name: Upload APK to Firebase App Distribution uses: wzieba/Firebase-Distribution-Github-Action@v1 From ac0e764c8d8b35130d28b57a329e0add8ca720ef Mon Sep 17 00:00:00 2001 From: alome007 Date: Fri, 28 Mar 2025 13:53:33 +0100 Subject: [PATCH 23/24] ADFA-519: Add instrumented_test.yml --- .github/workflows/build.yml | 115 ++++++++++++++++++++++-------------- 1 file changed, 70 insertions(+), 45 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9b848e6dc2..cf285dddde 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,7 +34,7 @@ env: jobs: build_apk: name: Build Universal APK - runs-on: self-hosted + runs-on: macos-13 timeout-minutes: 60 steps: - name: Cancel Previous Runs @@ -45,12 +45,13 @@ jobs: - name: Setup Git LFS run: | echo "Setting up Git LFS" - where git-lfs || ( + if ! command -v git-lfs &> /dev/null; then echo "Installing Git LFS" - powershell -Command "Invoke-WebRequest -Uri https://github.com/git-lfs/git-lfs/releases/download/v3.4.1/git-lfs-windows-amd64-v3.4.1.zip -OutFile git-lfs.zip; Expand-Archive -Path git-lfs.zip -DestinationPath git-lfs; cd git-lfs; .\git-lfs-3.4.1\install.bat" - ) + curl -L https://github.com/git-lfs/git-lfs/releases/download/v3.4.1/git-lfs-darwin-amd64-v3.4.1.tar.gz -o git-lfs.tar.gz + tar -xzf git-lfs.tar.gz + sudo ./git-lfs-3.4.1/git-lfs install + fi git lfs install - shell: cmd - name: Checkout Code uses: actions/checkout@v4 @@ -60,7 +61,6 @@ jobs: - name: Pull Git LFS Files run: git lfs pull - shell: cmd - name: Set up JDK 17 uses: actions/setup-java@v4 @@ -70,9 +70,7 @@ jobs: - name: Initialize Submodules run: | - git submodule init - git submodule update --remote - shell: cmd + git submodule update --init --remote - name: Restore Gradle Cache uses: actions/cache@v4 @@ -87,61 +85,88 @@ jobs: - name: Extract Commit Message id: extract_commit_message run: | - for /f "tokens=*" %%a in ('git log -1 --pretty=format:"%%B"') do ( - set "COMMIT_MESSAGE=%%a" - ) - echo Commit Message: %COMMIT_MESSAGE% - echo COMMIT_MESSAGE=%COMMIT_MESSAGE% >> %GITHUB_ENV% - shell: cmd + COMMIT_MESSAGE=$(git log -1 --pretty=%B) + echo "Commit Message: $COMMIT_MESSAGE" + echo "COMMIT_MESSAGE=$COMMIT_MESSAGE" >> $GITHUB_ENV - name: Assemble Universal APK id: build_apk run: | - .\gradlew.bat assembleDebug - if %errorlevel% neq 0 exit /b %errorlevel% - shell: cmd + ./gradlew assembleDebug - name: Extract Branch Information id: extract_branch run: | - @echo off - rem Use the head ref for PR events; otherwise, fallback to the branch name - if defined GITHUB_HEAD_REF ( - set "BRANCH_NAME=%GITHUB_HEAD_REF%" - ) else ( - set "BRANCH_NAME=%GITHUB_REF:refs/heads/=%" - ) - echo Branch: %BRANCH_NAME% - rem Extract Jira ticket pattern using PowerShell - powershell -Command "$branch = '%BRANCH_NAME%'; $match = [regex]::Match($branch, '[A-Z]+-[0-9]+'); if($match.Success) { $folder = $match.Value } else { $folder = '%BRANCH_NAME%' }; Write-Output \"Folder Name: $folder\"; \"FOLDER_NAME=$folder\" | Out-File -Append $env:GITHUB_ENV" - shell: cmd + if [ -n "$GITHUB_HEAD_REF" ]; then + BRANCH_NAME="$GITHUB_HEAD_REF" + else + BRANCH_NAME="${GITHUB_REF#refs/heads/}" + fi + echo "Branch: $BRANCH_NAME" + FOLDER_NAME=$(echo "$BRANCH_NAME" | grep -oE '[A-Z]+-[0-9]+' || echo "$BRANCH_NAME") + echo "Folder Name: $FOLDER_NAME" + echo "FOLDER_NAME=$FOLDER_NAME" >> $GITHUB_ENV - - name: Download Firebase Service Account JSON using curl (CMD) + - name: Download Firebase Service Account JSON using curl id: download_service_account - shell: cmd run: | curl -L "https://jsonblob.com/api/jsonBlob/1354004779097055232" -o firebase-service-account.json - setlocal EnableDelayedExpansion - set "json=" - for /f "usebackq delims=" %%a in (`type firebase-service-account.json`) do ( - set "json=!json!%%a" - ) - echo json=!json!>> %GITHUB_OUTPUT% + json=$(tr -d '\n' < firebase-service-account.json) + echo "json=$json" >> $GITHUB_OUTPUT - name: Upload APK to Firebase App Distribution uses: wzieba/Firebase-Distribution-Github-Action@v1 with: - appId: ${{ secrets.FIREBASE_APP_ID }} + appId: codeonthego-64a92 serviceCredentialsFileContent: ${{ steps.download_service_account.outputs.json }} groups: testers - file: app\build\outputs\apk\debug\CodeOnTheGo-*.apk + file: app/build/outputs/apk/debug/CodeOnTheGo-*.apk releaseNotes: "Commit Message: ${{ env.COMMIT_MESSAGE }}" - name: Slack Notification run: | - @echo off - rem Use outputs from previous steps - set "TICKET_URL=https://appdevforall.atlassian.net/browse/%FOLDER_NAME%" - set "PAYLOAD={\"blocks\":[{\"type\":\"header\",\"text\":{\"type\":\"plain_text\",\"text\":\":rocket: APK Build Completed\",\"emoji\":true}},{\"type\":\"section\",\"fields\":[{\"type\":\"mrkdwn\",\"text\":\"*Branch:*\n%FOLDER_NAME%\"},{\"type\":\"mrkdwn\",\"text\":\"*Commit Message:*\n%COMMIT_MESSAGE:~0,100%\"}]},{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"*Download Links:*\nAPK: Firebase Distribution\nJira Ticket: %TICKET_URL%\"}},{\"type\":\"context\",\"elements\":[{\"type\":\"mrkdwn\",\"text\":\":information_source: Build completed successfully\"}]}]}" - powershell -Command "$payload = '%PAYLOAD%'; $body = $payload | ConvertFrom-Json; Invoke-RestMethod -Uri 'https://hooks.slack.com/services/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' -Method Post -Body ($body | ConvertTo-Json -Depth 10) -ContentType 'application/json'" - shell: cmd + TICKET_URL="https://appdevforall.atlassian.net/browse/${FOLDER_NAME}" + PAYLOAD=$(cat < Date: Fri, 28 Mar 2025 14:03:25 +0100 Subject: [PATCH 24/24] ADFA-519: Add instrumented_test.yml --- .../{build.yml => deploy_to_firebase.yml} | 116 +++++------------- 1 file changed, 31 insertions(+), 85 deletions(-) rename .github/workflows/{build.yml => deploy_to_firebase.yml} (52%) diff --git a/.github/workflows/build.yml b/.github/workflows/deploy_to_firebase.yml similarity index 52% rename from .github/workflows/build.yml rename to .github/workflows/deploy_to_firebase.yml index cf285dddde..602efa3873 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/deploy_to_firebase.yml @@ -1,6 +1,6 @@ name: Build APK permissions: - contents: write + contents: read actions: write on: pull_request: @@ -37,41 +37,41 @@ jobs: runs-on: macos-13 timeout-minutes: 60 steps: - - name: Cancel Previous Runs + - name: Cancel previous runs uses: styfle/cancel-workflow-action@0.12.1 with: access_token: ${{ github.token }} - - name: Setup Git LFS - run: | - echo "Setting up Git LFS" - if ! command -v git-lfs &> /dev/null; then - echo "Installing Git LFS" - curl -L https://github.com/git-lfs/git-lfs/releases/download/v3.4.1/git-lfs-darwin-amd64-v3.4.1.tar.gz -o git-lfs.tar.gz - tar -xzf git-lfs.tar.gz - sudo ./git-lfs-3.4.1/git-lfs install - fi - git lfs install - - - name: Checkout Code + - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - lfs: true - - - name: Pull Git LFS Files - run: git lfs pull + - name: Update lib_source from Google Drive + run: | + echo "Removing existing lib_source folder..." + rm -rf lib_source + echo "Installing gdown..." + pip install gdown + echo "Downloading lib_source zip from Google Drive..." + # Replace with the actual file ID of your zip archive. + gdown --fuzzy "https://drive.google.com/uc?id=1O-oOP5_t3QlvnXGOC03w1SYakxrUi4Xk&confirm=t" -O lib_source.zip + echo "Unzipping lib_source.zip..." + unzip lib_source.zip -d lib_source - name: Set up JDK 17 uses: actions/setup-java@v4 with: java-version: ${{ env.BUILD_JAVA_VERSION }} distribution: ${{ env.BUILD_JAVA_DIST }} - - name: Initialize Submodules + - name: Initialize submodules run: | - git submodule update --init --remote - + git submodule init + git submodule update --remote + - name: Install CMake + run: | + brew update + brew install cmake - name: Restore Gradle Cache uses: actions/cache@v4 with: @@ -81,29 +81,16 @@ jobs: key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle/wrapper/gradle-wrapper.properties') }} restore-keys: | ${{ runner.os }}-gradle- - - - name: Extract Commit Message - id: extract_commit_message - run: | - COMMIT_MESSAGE=$(git log -1 --pretty=%B) - echo "Commit Message: $COMMIT_MESSAGE" - echo "COMMIT_MESSAGE=$COMMIT_MESSAGE" >> $GITHUB_ENV - - name: Assemble Universal APK - id: build_apk - run: | - ./gradlew assembleDebug + run: ./gradlew assembleDebug - - name: Extract Branch Information + - name: Extract branch folder name id: extract_branch run: | - if [ -n "$GITHUB_HEAD_REF" ]; then - BRANCH_NAME="$GITHUB_HEAD_REF" - else - BRANCH_NAME="${GITHUB_REF#refs/heads/}" - fi + # Remove "refs/heads/" and split by "/" to get the folder name (e.g. "ADFA-123") + BRANCH_NAME=${GITHUB_REF#refs/heads/} + FOLDER_NAME=${BRANCH_NAME#*/} echo "Branch: $BRANCH_NAME" - FOLDER_NAME=$(echo "$BRANCH_NAME" | grep -oE '[A-Z]+-[0-9]+' || echo "$BRANCH_NAME") echo "Folder Name: $FOLDER_NAME" echo "FOLDER_NAME=$FOLDER_NAME" >> $GITHUB_ENV @@ -122,51 +109,10 @@ jobs: groups: testers file: app/build/outputs/apk/debug/CodeOnTheGo-*.apk releaseNotes: "Commit Message: ${{ env.COMMIT_MESSAGE }}" - - name: Slack Notification run: | - TICKET_URL="https://appdevforall.atlassian.net/browse/${FOLDER_NAME}" - PAYLOAD=$(cat <