From 1f943ca46fb834e2172c97a5239e2439329303ce Mon Sep 17 00:00:00 2001 From: Anashuman Singh Date: Fri, 26 Jul 2024 16:27:01 +0530 Subject: [PATCH 1/5] chore: configure automatic screenshots --- .github/actions/screenshot-android/action.yml | 58 ++++++ .github/workflows/release.yml | 13 +- app/build.gradle.kts | 7 + .../io/pslab/activity/ScreenshotsTest.java | 173 ++++++++++++++++++ app/src/main/AndroidManifest.xml | 4 + 5 files changed, 252 insertions(+), 3 deletions(-) create mode 100644 .github/actions/screenshot-android/action.yml create mode 100644 app/src/androidTest/java/io/pslab/activity/ScreenshotsTest.java diff --git a/.github/actions/screenshot-android/action.yml b/.github/actions/screenshot-android/action.yml new file mode 100644 index 000000000..e5f368496 --- /dev/null +++ b/.github/actions/screenshot-android/action.yml @@ -0,0 +1,58 @@ +name: "Android Screenshots Workflow" + +inputs: + ANDROID_EMULATOR_API: + description: 'Emulator API to be used when running tests' + required: false + default: 34 + ANDROID_EMULATOR_ARCH: + description: 'Emulator architecture to be used when running tests' + required: false + default: x86_64 + +runs: + using: "composite" + steps: + - name: Enable KVM group perms + shell: bash + run: | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules + sudo udevadm control --reload-rules + sudo udevadm trigger --name-match=kvm + - name: Cache AVD + uses: actions/cache@v4 + id: avd-cache + with: + path: | + ~/.android/avd/* + ~/.android/adb* + key: avd-${{ inputs.ANDROID_EMULATOR_API }}-${{ inputs.ANDROID_EMULATOR_ARCH }} + + - name: Create AVD and Cache Snapshot + if: steps.avd-cache.outputs.cache-hit != 'true' + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: ${{ inputs.ANDROID_EMULATOR_API }} + arch: ${{ inputs.ANDROID_EMULATOR_ARCH }} + profile: pixel_6 + avd-name: pixel_6 + force-avd-creation: false + emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none + disable-animations: false + script: echo "Generated AVD snapshot for caching." + + - name: Create Android Screenshots + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: ${{ inputs.ANDROID_EMULATOR_API }} + arch: ${{ inputs.ANDROID_EMULATOR_ARCH }} + profile: pixel_6 + avd-name: pixel_6 + force-avd-creation: false + emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none + disable-animations: true + script: | + bundle exec fastlane screengrab + if [[ $? -ne 0 ]]; then + exit 1 + fi \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 776227049..ba7b9c5a6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -41,12 +41,19 @@ jobs: read -r version_code < versionCode.txt echo "VERSION_CODE=$version_code" >> $GITHUB_OUTPUT - - name: Add Changelogs to fastlane branch - run: | git config --global user.name "github-actions[bot]" git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" git clone --branch=fastlane --depth=1 https://${{ github.repository_owner }}:${{ github.token }}@github.com/${{ github.repository }} fastlane + + - name: Android Screenshot Workflow + uses: ./.github/actions/screenshot-android + with: + ANDROID_EMULATOR_API: ${{ env.ANDROID_EMULATOR_API }} + ANDROID_EMULATOR_ARCH: ${{ env.ANDROID_EMULATOR_ARCH }} + + - name: Add Changelogs to fastlane branch + run: | cd fastlane echo "${{ github.event.release.body }}" > metadata/android/en-US/changelogs/${{ steps.download-assets.outputs.VERSION_CODE }}.txt @@ -54,7 +61,7 @@ jobs: # Force push to fastlane branch git checkout --orphan temporary git add --all . - git commit -am "[Auto] Add changelogs for versionCode: ${{ steps.download-assets.outputs.VERSION_CODE }} ($(date +%Y-%m-%d.%H:%M:%S))" + git commit -am "[Auto] Update metadata for versionCode: ${{ steps.download-assets.outputs.VERSION_CODE }} ($(date +%Y-%m-%d.%H:%M:%S))" git branch -D fastlane git branch -m fastlane git push --force origin fastlane diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 2af61952f..a4c018316 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -18,6 +18,7 @@ android { versionCode = System.getenv("VERSION_CODE")?.toInt() ?: 1 versionName = System.getenv("VERSION_NAME") ?: "1.0.0" resConfigs("en","ru","ar","si","pl") + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } signingConfigs { @@ -97,6 +98,12 @@ dependencies { // OKHTTP implementation("com.squareup.okhttp3:okhttp:4.12.0") + androidTestImplementation("tools.fastlane:screengrab:2.1.1") + androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1") + androidTestImplementation("androidx.test.uiautomator:uiautomator:2.3.0") + androidTestImplementation("androidx.test.ext:junit:1.2.1") + androidTestImplementation("androidx.test.espresso:espresso-contrib:3.6.1") + androidTestImplementation("androidx.test:rules:1.6.1") // ButterKnife val butterKnifeVersion = "10.2.3" diff --git a/app/src/androidTest/java/io/pslab/activity/ScreenshotsTest.java b/app/src/androidTest/java/io/pslab/activity/ScreenshotsTest.java new file mode 100644 index 000000000..ae16d8631 --- /dev/null +++ b/app/src/androidTest/java/io/pslab/activity/ScreenshotsTest.java @@ -0,0 +1,173 @@ +package io.pslab.activity; + + +import static androidx.test.core.app.ApplicationProvider.getApplicationContext; +import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.action.ViewActions.*; +import static androidx.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition; +import static androidx.test.espresso.matcher.ViewMatchers.*; +import static org.hamcrest.Matchers.allOf; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; + +import android.app.Activity; +import android.app.Instrumentation; +import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; +import android.view.View; +import android.view.ViewGroup; +import android.view.ViewParent; + +import androidx.test.espresso.Espresso; +import androidx.test.espresso.IdlingResource; +import androidx.test.espresso.PerformException; +import androidx.test.espresso.UiController; +import androidx.test.espresso.ViewAction; +import androidx.test.espresso.util.HumanReadables; +import androidx.test.espresso.util.TreeIterables; +import androidx.test.ext.junit.rules.ActivityScenarioRule; + +import tools.fastlane.screengrab.FalconScreenshotStrategy; +import tools.fastlane.screengrab.Screengrab; +import tools.fastlane.screengrab.UiAutomatorScreenshotStrategy; +import tools.fastlane.screengrab.locale.LocaleTestRule; + +import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.filters.LargeTest; +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.rule.GrantPermissionRule; +import androidx.test.uiautomator.By; +import androidx.test.uiautomator.UiDevice; +import androidx.test.uiautomator.UiObject; +import androidx.test.uiautomator.UiObjectNotFoundException; +import androidx.test.uiautomator.UiScrollable; +import androidx.test.uiautomator.UiSelector; +import androidx.test.uiautomator.Until; + +import org.hamcrest.Description; +import org.hamcrest.Matcher; +import org.hamcrest.TypeSafeMatcher; +import org.junit.Before; +import org.junit.ClassRule; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.concurrent.TimeoutException; + +import io.pslab.R; + +@LargeTest +@RunWith(AndroidJUnit4.class) +public class ScreenshotsTest { + private static final int LAUNCH_TIMEOUT = 10000; + private static final String APP_PACKAGE_NAME = "io.pslab"; + UiDevice mDevice; + + @ClassRule + public static final LocaleTestRule localeTestRule = new LocaleTestRule(); + + @Rule + public ActivityScenarioRule mActivityScenarioRule = + new ActivityScenarioRule<>(MainActivity.class); + + @Rule + public GrantPermissionRule mGrantPermissionRule = + GrantPermissionRule.grant( + "android.permission.ACCESS_FINE_LOCATION", + "android.permission.RECORD_AUDIO", + "android.permission.WRITE_EXTERNAL_STORAGE"); + + @Before + public void setUp() { + Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); + mDevice = UiDevice.getInstance(instrumentation); + mDevice.pressHome(); + + final String launcherPackage = getLauncherPackageName(); + assertThat(launcherPackage, notNullValue()); + + Context context = getApplicationContext(); + final Intent intent = context.getPackageManager().getLaunchIntentForPackage(APP_PACKAGE_NAME); + assert intent != null; + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); + context.startActivity(intent); + Screengrab.setDefaultScreenshotStrategy(new UiAutomatorScreenshotStrategy()); + + mDevice.wait(Until.hasObject(By.pkg(APP_PACKAGE_NAME).depth(0)), LAUNCH_TIMEOUT); + } + + private String getLauncherPackageName() { + final Intent intent = new Intent(Intent.ACTION_MAIN); + intent.addCategory(Intent.CATEGORY_HOME); + + PackageManager pm = getApplicationContext().getPackageManager(); + ResolveInfo resolveInfo = pm.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY); + assert resolveInfo != null; + return resolveInfo.activityInfo.packageName; + } + + @Test + public void testTakeScreenshot() throws UiObjectNotFoundException { + Screengrab.screenshot("dashboard"); + + UiObject openDrawer = mDevice.findObject(new UiSelector().description("open_drawer")); + openDrawer.click(); + Screengrab.screenshot("drawer"); + + UiScrollable navRecyclerView = new UiScrollable(new UiSelector().resourceId(APP_PACKAGE_NAME + ":id/nav_instruments")); + UiObject item = navRecyclerView.getChild(new UiSelector().text("Instruments")); + item.click(); + + UiScrollable applicationsRecyclerView = new UiScrollable(new UiSelector().resourceId(APP_PACKAGE_NAME + ":id/applications_recycler_view")); + applicationsRecyclerView.scrollTextIntoView("ACCELEROMETER"); + item = applicationsRecyclerView.getChild(new UiSelector().text("ACCELEROMETER")); + item.clickAndWaitForNewWindow(); + Screengrab.screenshot("instrument_accelerometer_view"); + + mDevice.pressBack(); + + applicationsRecyclerView.scrollTextIntoView("BAROMETER"); + item = applicationsRecyclerView.getChild(new UiSelector().text("BAROMETER")); + item.clickAndWaitForNewWindow(); + Screengrab.screenshot("instrument_barometer_view"); + + mDevice.pressBack(); + + applicationsRecyclerView.scrollTextIntoView("MULTIMETER"); + item = applicationsRecyclerView.getChild(new UiSelector().text("MULTIMETER")); + item.clickAndWaitForNewWindow(); + Screengrab.screenshot("instrument_multimeter_view"); + + mDevice.pressBack(); + + applicationsRecyclerView.scrollTextIntoView("LOGIC ANALYZER"); + item = applicationsRecyclerView.getChild(new UiSelector().text("LOGIC ANALYZER")); + item.clickAndWaitForNewWindow(); + Screengrab.screenshot("logic_analyzer_view"); + + mDevice.pressBack(); + + UiObject moreOptions = mDevice.findObject(new UiSelector().description("More options")); + moreOptions.click(); + + UiObject pinLayoutFront = mDevice.findObject(new UiSelector().text("Pin Layout Front")); + pinLayoutFront.clickAndWaitForNewWindow(); + Screengrab.screenshot("layout_pin_front"); + + openDrawer.click(); + + item = navRecyclerView.getChild(new UiSelector().text("Instruments")); + item.clickAndWaitForNewWindow(); + + applicationsRecyclerView.scrollTextIntoView("OSCILLOSCOPE"); + item = applicationsRecyclerView.getChild(new UiSelector().text("OSCILLOSCOPE")); + item.clickAndWaitForNewWindow(); + Screengrab.screenshot("oscilloscope_channel_view"); + + mDevice.pressBack(); + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b7bd03371..3bfb4ae13 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -13,6 +13,10 @@ + + + + Date: Tue, 31 Dec 2024 00:43:31 +0530 Subject: [PATCH 2/5] fix: tests --- .github/actions/screenshot-android/action.yml | 4 +- .../io/pslab/activity/ScreenshotsTest.java | 93 ++++++------------- 2 files changed, 32 insertions(+), 65 deletions(-) diff --git a/.github/actions/screenshot-android/action.yml b/.github/actions/screenshot-android/action.yml index e5f368496..6498abd25 100644 --- a/.github/actions/screenshot-android/action.yml +++ b/.github/actions/screenshot-android/action.yml @@ -30,7 +30,7 @@ runs: - name: Create AVD and Cache Snapshot if: steps.avd-cache.outputs.cache-hit != 'true' - uses: reactivecircus/android-emulator-runner@v2 + uses: reactivecircus/android-emulator-runner@v2.33.0 with: api-level: ${{ inputs.ANDROID_EMULATOR_API }} arch: ${{ inputs.ANDROID_EMULATOR_ARCH }} @@ -42,7 +42,7 @@ runs: script: echo "Generated AVD snapshot for caching." - name: Create Android Screenshots - uses: reactivecircus/android-emulator-runner@v2 + uses: reactivecircus/android-emulator-runner@v2.33.0 with: api-level: ${{ inputs.ANDROID_EMULATOR_API }} arch: ${{ inputs.ANDROID_EMULATOR_ARCH }} diff --git a/app/src/androidTest/java/io/pslab/activity/ScreenshotsTest.java b/app/src/androidTest/java/io/pslab/activity/ScreenshotsTest.java index ae16d8631..e008a5468 100644 --- a/app/src/androidTest/java/io/pslab/activity/ScreenshotsTest.java +++ b/app/src/androidTest/java/io/pslab/activity/ScreenshotsTest.java @@ -1,35 +1,19 @@ package io.pslab.activity; - import static androidx.test.core.app.ApplicationProvider.getApplicationContext; import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.action.ViewActions.*; -import static androidx.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition; import static androidx.test.espresso.matcher.ViewMatchers.*; -import static org.hamcrest.Matchers.allOf; -import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; -import android.app.Activity; import android.app.Instrumentation; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; -import android.view.View; -import android.view.ViewGroup; -import android.view.ViewParent; - -import androidx.test.espresso.Espresso; -import androidx.test.espresso.IdlingResource; -import androidx.test.espresso.PerformException; -import androidx.test.espresso.UiController; -import androidx.test.espresso.ViewAction; -import androidx.test.espresso.util.HumanReadables; -import androidx.test.espresso.util.TreeIterables; + import androidx.test.ext.junit.rules.ActivityScenarioRule; -import tools.fastlane.screengrab.FalconScreenshotStrategy; import tools.fastlane.screengrab.Screengrab; import tools.fastlane.screengrab.UiAutomatorScreenshotStrategy; import tools.fastlane.screengrab.locale.LocaleTestRule; @@ -46,24 +30,16 @@ import androidx.test.uiautomator.UiSelector; import androidx.test.uiautomator.Until; -import org.hamcrest.Description; -import org.hamcrest.Matcher; -import org.hamcrest.TypeSafeMatcher; import org.junit.Before; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import java.io.File; -import java.util.concurrent.TimeoutException; - -import io.pslab.R; - @LargeTest @RunWith(AndroidJUnit4.class) public class ScreenshotsTest { - private static final int LAUNCH_TIMEOUT = 10000; + private static final int TIMEOUT = 5000; private static final String APP_PACKAGE_NAME = "io.pslab"; UiDevice mDevice; @@ -97,25 +73,17 @@ public void setUp() { context.startActivity(intent); Screengrab.setDefaultScreenshotStrategy(new UiAutomatorScreenshotStrategy()); - mDevice.wait(Until.hasObject(By.pkg(APP_PACKAGE_NAME).depth(0)), LAUNCH_TIMEOUT); - } - - private String getLauncherPackageName() { - final Intent intent = new Intent(Intent.ACTION_MAIN); - intent.addCategory(Intent.CATEGORY_HOME); - - PackageManager pm = getApplicationContext().getPackageManager(); - ResolveInfo resolveInfo = pm.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY); - assert resolveInfo != null; - return resolveInfo.activityInfo.packageName; + mDevice.wait(Until.hasObject(By.pkg(APP_PACKAGE_NAME).depth(0)), TIMEOUT); } @Test public void testTakeScreenshot() throws UiObjectNotFoundException { + mDevice.wait(Until.hasObject(By.text("Instruments")), TIMEOUT); Screengrab.screenshot("dashboard"); - UiObject openDrawer = mDevice.findObject(new UiSelector().description("open_drawer")); openDrawer.click(); + + mDevice.wait(Until.hasObject(By.text("Not Connected")), TIMEOUT); Screengrab.screenshot("drawer"); UiScrollable navRecyclerView = new UiScrollable(new UiSelector().resourceId(APP_PACKAGE_NAME + ":id/nav_instruments")); @@ -123,51 +91,50 @@ public void testTakeScreenshot() throws UiObjectNotFoundException { item.click(); UiScrollable applicationsRecyclerView = new UiScrollable(new UiSelector().resourceId(APP_PACKAGE_NAME + ":id/applications_recycler_view")); + applicationsRecyclerView.scrollTextIntoView("ACCELEROMETER"); - item = applicationsRecyclerView.getChild(new UiSelector().text("ACCELEROMETER")); - item.clickAndWaitForNewWindow(); + onView(withText("ACCELEROMETER")).perform(click()); + mDevice.wait(Until.hasObject(By.text("Accelerometer")), TIMEOUT); Screengrab.screenshot("instrument_accelerometer_view"); mDevice.pressBack(); applicationsRecyclerView.scrollTextIntoView("BAROMETER"); - item = applicationsRecyclerView.getChild(new UiSelector().text("BAROMETER")); - item.clickAndWaitForNewWindow(); + onView(withText("BAROMETER")).perform(click()); + mDevice.wait(Until.hasObject(By.text("Barometer")), TIMEOUT); Screengrab.screenshot("instrument_barometer_view"); mDevice.pressBack(); applicationsRecyclerView.scrollTextIntoView("MULTIMETER"); - item = applicationsRecyclerView.getChild(new UiSelector().text("MULTIMETER")); - item.clickAndWaitForNewWindow(); + onView(withText("MULTIMETER")).perform(click()); + mDevice.wait(Until.hasObject(By.text("Multimeter")), TIMEOUT); Screengrab.screenshot("instrument_multimeter_view"); mDevice.pressBack(); - applicationsRecyclerView.scrollTextIntoView("LOGIC ANALYZER"); - item = applicationsRecyclerView.getChild(new UiSelector().text("LOGIC ANALYZER")); - item.clickAndWaitForNewWindow(); - Screengrab.screenshot("logic_analyzer_view"); + applicationsRecyclerView.scrollTextIntoView("WAVE GENERATOR"); + onView(withText("WAVE GENERATOR")).perform(click()); + mDevice.wait(Until.hasObject(By.text("Wave Generator")), TIMEOUT); + Screengrab.screenshot("instrument_wave_generator"); mDevice.pressBack(); - UiObject moreOptions = mDevice.findObject(new UiSelector().description("More options")); - moreOptions.click(); - - UiObject pinLayoutFront = mDevice.findObject(new UiSelector().text("Pin Layout Front")); - pinLayoutFront.clickAndWaitForNewWindow(); - Screengrab.screenshot("layout_pin_front"); - - openDrawer.click(); - - item = navRecyclerView.getChild(new UiSelector().text("Instruments")); - item.clickAndWaitForNewWindow(); - applicationsRecyclerView.scrollTextIntoView("OSCILLOSCOPE"); - item = applicationsRecyclerView.getChild(new UiSelector().text("OSCILLOSCOPE")); - item.clickAndWaitForNewWindow(); + onView(withText("OSCILLOSCOPE")).perform(click()); + mDevice.wait(Until.hasObject(By.text("Oscilloscope")), TIMEOUT); + mDevice.swipe(500, 0, 500, 1500, 10); + mDevice.wait(Until.hasObject(By.text("400")), TIMEOUT); Screengrab.screenshot("oscilloscope_channel_view"); + } - mDevice.pressBack(); + private String getLauncherPackageName() { + final Intent intent = new Intent(Intent.ACTION_MAIN); + intent.addCategory(Intent.CATEGORY_HOME); + + PackageManager pm = getApplicationContext().getPackageManager(); + ResolveInfo resolveInfo = pm.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY); + assert resolveInfo != null; + return resolveInfo.activityInfo.packageName; } } From 833f5628eef3f96f23d7bdd3d3aa2876edd4f1ea Mon Sep 17 00:00:00 2001 From: Anashuman Singh Date: Tue, 31 Dec 2024 00:49:45 +0530 Subject: [PATCH 3/5] fix: increased timeout --- app/src/androidTest/java/io/pslab/activity/ScreenshotsTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/androidTest/java/io/pslab/activity/ScreenshotsTest.java b/app/src/androidTest/java/io/pslab/activity/ScreenshotsTest.java index e008a5468..185098325 100644 --- a/app/src/androidTest/java/io/pslab/activity/ScreenshotsTest.java +++ b/app/src/androidTest/java/io/pslab/activity/ScreenshotsTest.java @@ -39,7 +39,7 @@ @LargeTest @RunWith(AndroidJUnit4.class) public class ScreenshotsTest { - private static final int TIMEOUT = 5000; + private static final int TIMEOUT = 10000; private static final String APP_PACKAGE_NAME = "io.pslab"; UiDevice mDevice; From 1d6b53bf154967d15f612b842737029ec30a1255 Mon Sep 17 00:00:00 2001 From: Anashuman Singh Date: Tue, 31 Dec 2024 19:37:08 +0530 Subject: [PATCH 4/5] fix: permissions --- app/src/debug/AndroidManifest.xml | 149 ++++++++++++++++++++++++++++++ app/src/main/AndroidManifest.xml | 4 - 2 files changed, 149 insertions(+), 4 deletions(-) create mode 100644 app/src/debug/AndroidManifest.xml diff --git a/app/src/debug/AndroidManifest.xml b/app/src/debug/AndroidManifest.xml new file mode 100644 index 000000000..9157c69ec --- /dev/null +++ b/app/src/debug/AndroidManifest.xml @@ -0,0 +1,149 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 9157c69ec..494df111f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -15,10 +15,6 @@ - - - - Date: Sun, 12 Jan 2025 23:43:59 +0530 Subject: [PATCH 5/5] feat: improvements --- .github/actions/screenshot-android/action.yml | 42 ++++++++++++++++--- .github/workflows/pull-request.yml | 18 +++++++- .github/workflows/push-event.yml | 16 ++++++- .github/workflows/release.yml | 15 +------ 4 files changed, 71 insertions(+), 20 deletions(-) diff --git a/.github/actions/screenshot-android/action.yml b/.github/actions/screenshot-android/action.yml index 6498abd25..ec31aa5d1 100644 --- a/.github/actions/screenshot-android/action.yml +++ b/.github/actions/screenshot-android/action.yml @@ -1,4 +1,4 @@ -name: "Android Screenshots Workflow" +name: "Screenshots Workflow" inputs: ANDROID_EMULATOR_API: @@ -13,12 +13,24 @@ inputs: runs: using: "composite" steps: + - name: Setup Java + uses: actions/setup-java@v3 + with: + distribution: 'adopt' + java-version: '17' + + - name: Build APKs + shell: bash + run: | + ./gradlew assembleDebug assembleAndroidTest --stacktrace + - name: Enable KVM group perms shell: bash run: | echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules sudo udevadm control --reload-rules sudo udevadm trigger --name-match=kvm + - name: Cache AVD uses: actions/cache@v4 id: avd-cache @@ -41,6 +53,23 @@ runs: disable-animations: false script: echo "Generated AVD snapshot for caching." + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.3' + bundler-cache: true + + - name: Prepare Bundler + shell: bash + run: | + bundle config path vendor/bundle + bundle install --jobs 4 --retry 3 + + - name: Setup Fastlane + shell: bash + run: | + git clone --branch=fastlane --depth=1 https://${{ github.repository_owner }}:${{ github.token }}@github.com/${{ github.repository }} fastlane + - name: Create Android Screenshots uses: reactivecircus/android-emulator-runner@v2.33.0 with: @@ -52,7 +81,10 @@ runs: emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none disable-animations: true script: | - bundle exec fastlane screengrab - if [[ $? -ne 0 ]]; then - exit 1 - fi \ No newline at end of file + bundle exec fastlane screengrab || exit 1 + + - name: Upload Screenshots + uses: actions/upload-artifact@v4 + with: + name: Android Screenshots + path: fastlane/metadata/android/en-US/images/phoneScreenshots \ No newline at end of file diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index f22605252..b9de11b19 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -6,6 +6,10 @@ on: - master - development +env: + ANDROID_EMULATOR_API: 34 + ANDROID_EMULATOR_ARCH: x86_64 + jobs: build: runs-on: ubuntu-latest @@ -39,4 +43,16 @@ jobs: with: name: apk-files path: | - app/build/outputs/apk/debug/app-debug.apk \ No newline at end of file + app/build/outputs/apk/debug/app-debug.apk + + screenshots: + name: Screenshots + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Android Screenshot Workflow + uses: ./.github/actions/screenshot-android + with: + ANDROID_EMULATOR_API: ${{ env.ANDROID_EMULATOR_API }} + ANDROID_EMULATOR_ARCH: ${{ env.ANDROID_EMULATOR_ARCH }} \ No newline at end of file diff --git a/.github/workflows/push-event.yml b/.github/workflows/push-event.yml index 001336c00..58baccb01 100644 --- a/.github/workflows/push-event.yml +++ b/.github/workflows/push-event.yml @@ -8,6 +8,8 @@ on: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ANDROID_EMULATOR_API: 34 + ANDROID_EMULATOR_ARCH: x86_64 jobs: build: @@ -164,4 +166,16 @@ jobs: - name: Create and Upload Assets run: | echo "${{ steps.android-version.outputs.VERSION_CODE }}" > ./versionCode.txt - gh release upload ${{ steps.run-release-drafter.outputs.tag_name }} apk/pslab-development-release.apk ./versionCode.txt --clobber \ No newline at end of file + gh release upload ${{ steps.run-release-drafter.outputs.tag_name }} apk/pslab-development-release.apk ./versionCode.txt --clobber + + screenshots: + name: Screenshots + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Android Screenshot Workflow + uses: ./.github/actions/screenshot-android + with: + ANDROID_EMULATOR_API: ${{ env.ANDROID_EMULATOR_API }} + ANDROID_EMULATOR_ARCH: ${{ env.ANDROID_EMULATOR_ARCH }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ba7b9c5a6..45abc30a7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,6 +6,8 @@ on: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ANDROID_EMULATOR_API: 34 + ANDROID_EMULATOR_ARCH: x86_64 jobs: release: @@ -16,17 +18,6 @@ jobs: - name: Download repository uses: actions/checkout@v4 - - name: Setup Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: '3.3' - bundler-cache: true - - - name: Prepare Bundler - run: | - bundle config path vendor/bundle - bundle install --jobs 4 --retry 3 - - name: Prepare Build Keys env: ENCRYPTED_F10B5E0E5262_IV: ${{ secrets.ENCRYPTED_F10B5E0E5262_IV }} @@ -43,8 +34,6 @@ jobs: git config --global user.name "github-actions[bot]" git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" - - git clone --branch=fastlane --depth=1 https://${{ github.repository_owner }}:${{ github.token }}@github.com/${{ github.repository }} fastlane - name: Android Screenshot Workflow uses: ./.github/actions/screenshot-android