Skip to content

Commit

Permalink
chore: add support for automatic screenshots (#961)
Browse files Browse the repository at this point in the history
  • Loading branch information
adityastic authored Jul 1, 2024
1 parent 167c4b8 commit 6fb77f4
Show file tree
Hide file tree
Showing 13 changed files with 356 additions and 101 deletions.
67 changes: 67 additions & 0 deletions .github/actions/screenshot-android/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
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: Set up Flutter
uses: subosito/flutter-action@v2
with:
cache: true

- 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: |
flutter drive --driver=test_integration/test_driver.dart --target=test_integration/screenshots.dart -d emulator
- name: Upload Screenshots
uses: actions/upload-artifact@v4
with:
name: Android Screenshots
path: screenshots/*
22 changes: 20 additions & 2 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
name: Badge Magic PR CI

on:
pull_request:
branches: ["flutter_app"]

env:
ANDROID_EMULATOR_API: 34
ANDROID_EMULATOR_ARCH: x86_64

jobs:
common:
name: Common Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -21,7 +28,6 @@ jobs:
- name: Android Workflow
uses: ./.github/actions/android


ios:
name: iOS Flutter Build
needs: common
Expand All @@ -31,4 +37,16 @@ jobs:

- name: iOS Workflow
uses: ./.github/actions/ios


screenshots:
name: Screenshots (Android)
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 }}

23 changes: 20 additions & 3 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
name: Badge Magic Push CI

on:
push:
branches: ["flutter_app"]

env:
ANDROID_EMULATOR_API: 34
ANDROID_EMULATOR_ARCH: x86_64

jobs:
common:
name: Common Build
runs-on: ubuntu-latest

outputs:
VERSION_NAME: ${{ steps.flutter-version.outputs.VERSION_NAME }}
VERSION_CODE: ${{ steps.flutter-version.outputs.VERSION_CODE }}

steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -166,6 +171,7 @@ jobs:
VERSION_CODE: ${{needs.common.outputs.VERSION_CODE}}

update-release:
name: Update Draft Release
needs: [common, android, ios]
runs-on: ubuntu-latest
steps:
Expand All @@ -175,4 +181,15 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
version: ${{ needs.common.outputs.VERSION_NAME }}


screenshots:
name: Screenshots (Android)
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 }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ app.*.map.json
/android/app/debug
/android/app/profile
/android/app/release

screenshots/
19 changes: 19 additions & 0 deletions iOS/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,39 @@ PODS:
- Flutter (1.0.0)
- flutter_blue_plus (0.0.1):
- Flutter
- fluttertoast (0.0.2):
- Flutter
- Toast
- integration_test (0.0.1):
- Flutter
- Toast (4.1.1)

DEPENDENCIES:
- Flutter (from `Flutter`)
- flutter_blue_plus (from `.symlinks/plugins/flutter_blue_plus/ios`)
- fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
- integration_test (from `.symlinks/plugins/integration_test/ios`)

SPEC REPOS:
trunk:
- Toast

EXTERNAL SOURCES:
Flutter:
:path: Flutter
flutter_blue_plus:
:path: ".symlinks/plugins/flutter_blue_plus/ios"
fluttertoast:
:path: ".symlinks/plugins/fluttertoast/ios"
integration_test:
:path: ".symlinks/plugins/integration_test/ios"

SPEC CHECKSUMS:
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_blue_plus: 4837da7d00cf5d441fdd6635b3a57f936778ea96
fluttertoast: e9a18c7be5413da53898f660530c56f35edfba9c
integration_test: ce0a3ffa1de96d1a89ca0ac26fca7ea18a749ef4
Toast: 1f5ea13423a1e6674c4abdac5be53587ae481c4e

PODFILE CHECKSUM: 819463e6a0290f5a72f145ba7cde16e8b6ef0796

Expand Down
6 changes: 5 additions & 1 deletion iOS/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import UIKit
import Flutter
import integration_test

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
Expand All @@ -8,6 +9,9 @@ import Flutter
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)

let controller : FlutterViewController = window?.rootViewController as! FlutterViewController

return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
}
2 changes: 2 additions & 0 deletions lib/constants.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const homeScreenTitleKey = "bm_hm_title";

//path to all the animation assets used
const String animation = 'assets/animations/ic_anim_animation.gif';
const String aniLeft = 'assets/animations/ic_anim_left.gif';
Expand Down
Loading

0 comments on commit 6fb77f4

Please sign in to comment.