Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #42

Closed
wants to merge 10 commits into from
Closed

Dev #42

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 97 additions & 59 deletions .github/workflows/dev-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
paths-ignore:
- '.github/**'
- 'README.md'
- 'extras/**'
branches: [ "dev" ]

workflow_dispatch:
Expand All @@ -27,25 +28,6 @@ jobs:
with:
cache-read-only: false

- name: AVD cache
uses: actions/cache@v3
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-29

- name: create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."

- name: Get Google Services Json
env:
CERTIFICATE_BASE64: ${{ secrets.GOOGLE_SERVICES_JSON }}
Expand All @@ -55,11 +37,21 @@ jobs:
- name: Run Unit Test
run: ./gradlew test

- name: Assemble Debug
run: ./gradlew assembleDebug

- name: Upload Debug Apk
uses: actions/upload-artifact@v4
with:
name: debug-apk
path: app/build/outputs/apk/debug/*.apk

- name: Upload Unit Test Report
if: always()
uses: actions/upload-artifact@v3
with:
name: unit-test-report
path: build/reports/unitTests
path: build/reports/unitTests

integration-test:
needs: [unit-test]
Expand All @@ -78,15 +70,6 @@ jobs:
uses: ./.github/actions/setup-jdk-gradle
with:
cache-read-only: true

- name: AVD cache
uses: actions/cache/restore@v3
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-29

- name: Get Google Services Json
env:
Expand All @@ -97,13 +80,16 @@ jobs:
- name: Run Integration Test
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
api-level: 30
target: google_apis
arch: x86_64
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: ./gradlew connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.cucumberUseAndroidJUnitRunner=true mergeAndroidReports
script: ./gradlew connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.cucumberUseAndroidJUnitRunner=true mergeAndroidReports --continue

- name: Upload Integration Test Report
if: always()
uses: actions/upload-artifact@v3
with:
name: integration-test-report
Expand All @@ -126,15 +112,6 @@ jobs:
uses: ./.github/actions/setup-jdk-gradle
with:
cache-read-only: true

- name: AVD cache
uses: actions/cache/restore@v3
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-29

- name: Get Google Services Json
env:
Expand All @@ -145,47 +122,108 @@ jobs:
- name: Run Acceptance Test
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
api-level: 30
target: google_apis
arch: x86_64
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: ./gradlew connectedAndroidTest mergeAndroidReports
script: ./gradlew connectedAndroidTest mergeAndroidReports --continue

- name: Upload Acceptance Test Report
if: always()
uses: actions/upload-artifact@v3
with:
name: acceptance-test-report
path: build/androidTest-results

assemble-debug:
needs: [unit-test, integration-test, acceptance-test]
appium-tests:
needs: [unit-test]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: appium-tests

- name: Remove all apk in apps folder
run: rm -rf apps/*

- name: Display structure of downloaded files
run: ls -la apps

- name: Get APK
uses: actions/download-artifact@v4
with:
name: debug-apk
path: apps

- name: Copy And Rename APK
run: cp ./apps/[PusherNotif]* ./apps/PusherNotif.apk

- name: Display structure of downloaded files
run: ls -la apps

- name: Enable KVM
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: Setup JDK And Gradle
uses: ./.github/actions/setup-jdk-gradle

- name: Setup JDK 17
uses: actions/setup-java@v4
with:
cache-read-only: false
java-version: '17'
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
cache-read-only: true

- name: Grant Execute Permission For Gradlew
run: chmod +x gradlew
shell: bash

- name: Get Google Services Json
env:
CERTIFICATE_BASE64: ${{ secrets.GOOGLE_SERVICES_JSON }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 18

- name: Setup And Run Appium
run: |
echo $CERTIFICATE_BASE64 | base64 --decode > app/google-services.json

- name: Assemble Debug Apk
run: ./gradlew assembleDebug

- name: Upload Debug Apk
npm install -g [email protected]
appium -v
appium driver install uiautomator2
appium &

- name: Grant Execute Permission For Fcm
run: chmod +x fcm
shell: bash

- name: check
run: |
echo ~
pwd
ls -la
shell: bash

- name: Run Test
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 30
target: google_apis
arch: x86_64
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: |
adb root
./gradlew test

- name: Upload Report
if: always()
uses: actions/upload-artifact@v3
with:
name: debug-apk
path: app/build/outputs/apk/debug/*.apk
name: appium-test-report
path: build/reports
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,37 @@ Project contains:
# Note
This is an updated version of the old app. To see the old version, navigate to this [commit](https://github.com/syedahmedjamil/pushier/commit/ea7f30f8890fba63ff5571d64c3dffbe08dd9bfd) and click on "Browse Files".

# Before building the app
1. configure fcm https://pusher.com/docs/beams/getting-started/android/configure-fcm/?ref=docs-index#open-firebase-console
2. make sure when creating app in firebase the **"Android package name"** is same as you set in **build.grade** `applicationId`
3. paste your fcm server key in your pusher beams instance "Settings" page under "Google FCM Integration" field
4. download and store your `google-services.json` file in the app folder

# Payload Sample
> NOTE: your interest name has to be present in the `interests` array as well as in `fcm.data.interest` as shown below for it to work properly.
```json
{
"interests": [
"reddit"
],
"fcm": {
"data": {
"interest": "reddit",
"category": "Important",
"date": "1/1/2022",
"title": "How to optimise text size on lower dpi devices",
"body": "In XML, is there any other way than defining new layouts files for different dpi devices just to handle text sizes as it completely messes up the entire layout if not handled properly?",
"subtext": "r/androiddev",
"link": "https://www.reddit.com/r/androiddev/comments/13a3p1c/how_to_optimise_text_size_on_lower_dpi_devices",
"image": "https://media.glassdoor.com/sql/796358/reddit-squarelogo-1490630845152.png"
}
}
}
```
Sample using `curl` is located under `extras/payload_sample_using_curl.bat`

To use this sample you will need `PUSHER-BEAMS-INSTANCE-PRIMARY-KEY` and `PUSHER-BEAMS-INSTANCE-ID` both of which can be found by going to the "Keys" page of your pusher beams instance.

# Demo (new)
![](https://github.com/syedahmedjamil/pushier/blob/main/extras/demo_new.gif)

Expand Down
8 changes: 7 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ android {
minSdk = 24
targetSdk = 33
versionCode = project.property("versionCode").toString().toInt()
versionName = "1.4.0"
versionName = "1.4.1"
testApplicationId = "com.github.syedahmedjamil.pushernotif.test"
// testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
// testInstrumentationRunner = "io.cucumber.android.runner.CucumberAndroidJUnitRunner"
testInstrumentationRunner = "com.github.syedahmedjamil.pushernotif.test.CustomRunner"
testInstrumentationRunnerArguments["clearPackageData"] = "true"
//apk file name
setProperty("archivesBaseName", "${rootProject.name}-${versionName}-${versionCode}")
}
Expand Down Expand Up @@ -79,6 +80,7 @@ android {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = "1.8"
}
Expand All @@ -98,6 +100,7 @@ android {
useLegacyPackaging = true
}
}
execution = "ANDROIDX_TEST_ORCHESTRATOR"
}

kapt {
Expand Down Expand Up @@ -163,6 +166,9 @@ android {
androidTestImplementation("io.cucumber:cucumber-android-hilt:7.14.0")
androidTestImplementation("io.mockk:mockk-android:1.13.9")
androidTestImplementation("androidx.fragment:fragment-testing:1.6.2") // for DataBindingIdlingResource
androidTestImplementation("androidx.test.uiautomator:uiautomator:2.2.0")
androidTestImplementation("androidx.test:runner:1.5.2")
androidTestUtil("androidx.test:orchestrator:1.4.2")
}

}
13 changes: 13 additions & 0 deletions app/src/androidTest/assets/features/view_notifications.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Feature: View Notification
User can view notification for the subscribed interest

Background:
Given I am subscribed to instance

Scenario: User views notification from notification screen
When I receive push notification
Then I should see notification in the list

Scenario: User views notification from status bar
When I receive push notification
Then I should see notification in status bar
Loading
Loading