Skip to content

Commit 0d6ff30

Browse files
committed
ci(e2e): add Android E2E workflow
1 parent 5c2297a commit 0d6ff30

2 files changed

Lines changed: 135 additions & 0 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: 'Setup Demo'
2+
description: 'Installs the JDK and Android toolchains, caches Gradle, and writes the demo local.properties file'
3+
inputs:
4+
onesignal-app-id:
5+
description: 'OneSignal App ID written into examples/demo/local.properties'
6+
required: true
7+
onesignal-api-key:
8+
description: 'OneSignal REST API key written into examples/demo/local.properties'
9+
required: true
10+
runs:
11+
using: 'composite'
12+
steps:
13+
- name: Set up Java
14+
uses: actions/setup-java@v4
15+
with:
16+
distribution: temurin
17+
java-version: '17'
18+
19+
- name: Set up Android SDK
20+
uses: android-actions/setup-android@v3
21+
with:
22+
cmdline-tools-version: '10406996'
23+
log-accepted-android-sdk-licenses: false
24+
25+
- name: Cache Gradle
26+
uses: actions/cache@v4
27+
with:
28+
path: |
29+
~/.gradle/caches
30+
~/.gradle/wrapper
31+
key: ${{ runner.os }}-gradle-demo-${{ hashFiles('examples/demo/**/*.gradle*', 'examples/demo/**/gradle-wrapper.properties') }}
32+
restore-keys: |
33+
${{ runner.os }}-gradle-demo-
34+
${{ runner.os }}-gradle-
35+
36+
# Mirrors the Capacitor demo's `.env`: writes the override file before any
37+
# build runs so the OneSignal App ID + channel id end up baked into
38+
# BuildConfig. `examples/demo/app/build.gradle.kts` resolves each key in
39+
# this order: `-PKEY=value` from the CLI > local.properties > built-in
40+
# default, so writing to local.properties is the closest equivalent to
41+
# the Capacitor `.env` flow.
42+
- name: Write demo local.properties
43+
shell: bash
44+
working-directory: examples/demo
45+
env:
46+
ONESIGNAL_APP_ID: ${{ inputs.onesignal-app-id }}
47+
ONESIGNAL_API_KEY: ${{ inputs.onesignal-api-key }}
48+
run: |
49+
{
50+
echo "ONESIGNAL_APP_ID=${ONESIGNAL_APP_ID}"
51+
echo "ONESIGNAL_API_KEY=${ONESIGNAL_API_KEY}"
52+
echo "ONESIGNAL_ANDROID_CHANNEL_ID=7ec2ece9-c538-4656-9516-1316f48a005c"
53+
} > local.properties

.github/workflows/e2e.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: E2E Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- rel/**
7+
workflow_dispatch:
8+
inputs:
9+
sdk-version:
10+
description: 'OneSignal Android SDK version to wait for and build against (defaults to OneSignalSDK/gradle.properties).'
11+
required: false
12+
type: string
13+
14+
permissions:
15+
contents: read
16+
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
build-android:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
28+
- name: Set up demo
29+
uses: ./.github/actions/setup-demo
30+
with:
31+
onesignal-app-id: ${{ vars.APPIUM_ONESIGNAL_APP_ID }}
32+
onesignal-api-key: ${{ secrets.APPIUM_ONESIGNAL_API_KEY }}
33+
34+
- name: Resolve OneSignal Android SDK version
35+
id: android-sdk-version
36+
env:
37+
INPUT_VERSION: ${{ github.event.inputs.sdk-version }}
38+
run: |
39+
if [ -n "$INPUT_VERSION" ]; then
40+
VERSION="$INPUT_VERSION"
41+
else
42+
VERSION=$(grep -E '^SDK_VERSION=' OneSignalSDK/gradle.properties | cut -d '=' -f2)
43+
fi
44+
if [ -z "$VERSION" ]; then
45+
echo "::error::Could not resolve OneSignal Android SDK version"
46+
exit 1
47+
fi
48+
echo "Resolved OneSignal Android SDK version: $VERSION"
49+
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
50+
51+
- name: Wait for OneSignal Android SDK on Maven Central
52+
uses: OneSignal/sdk-shared/.github/actions/wait-for-maven-artifact@main
53+
with:
54+
version: ${{ steps.android-sdk-version.outputs.version }}
55+
56+
- name: Build debug APK
57+
working-directory: examples/demo
58+
# Build the gms-debug variant: BrowserStack devices all run Google
59+
# Play Services, and debug ensures isDebuggable=true so Appium's
60+
# UiAutomator2 driver can attach. The Maven-resolved OneSignal
61+
# dependency is pinned to the version we just waited for, so the
62+
# APK exercises the actual published artifact.
63+
run: ./gradlew :app:assembleGmsDebug -PSDK_VERSION=${{ steps.android-sdk-version.outputs.version }} --console=plain --warning-mode=summary
64+
65+
- name: Upload APK
66+
uses: actions/upload-artifact@v4
67+
with:
68+
name: demo-apk
69+
path: examples/demo/app/build/outputs/apk/gms/debug/app-gms-debug.apk
70+
retention-days: 1
71+
compression-level: 0
72+
73+
e2e-android:
74+
needs: build-android
75+
uses: OneSignal/sdk-shared/.github/workflows/appium-e2e.yml@main
76+
secrets: inherit
77+
with:
78+
platform: android
79+
app-artifact: demo-apk
80+
app-filename: app-gms-debug.apk
81+
sdk-type: android
82+
build-name: android-${{ github.ref_name }}-${{ github.run_number }}

0 commit comments

Comments
 (0)