Skip to content

Commit a1cf34c

Browse files
chore: Add CI workflows for building and running the example app (#13)
# Add CI workflows for building and running the example app ## Summary Adds two GitHub Actions workflows to the `hello-android` project: - **`build.yml`** — Builds the debug APK using Gradle on ubuntu-22.04 with Java 17 (Temurin). - **`run.yml`** — Fetches the LaunchDarkly mobile key and flag key from AWS SSM, injects them into the source, builds the debug APK, launches it on an Android emulator (API 29, x86_64), and validates that the UI displays "feature flag evaluates to true". Both workflows trigger on pushes and PRs to `main`, ignoring markdown-only changes. All actions are pinned to full SHAs with inline version comments and a reference link to the release page above each `uses:` line. ### Action versions used | Action | Version | SHA | Reference | |---|---|---|---| | `actions/checkout` | v4.2.2 | `11bd71901bbe5b1630ceea73d27597364c9af683` | [release](https://github.com/actions/checkout/releases/tag/v4.2.2) | | `actions/setup-java` | v4.7.1 | `c5195efecf7bdfc987ee8bae7a71cb8b11521c00` | [release](https://github.com/actions/setup-java/releases/tag/v4.7.1) | | `launchdarkly/gh-actions/actions/release-secrets` | release-secrets-v1.2.0 | `bbbbbda684f500766264e7fe327668094ba83d1c` | [release](https://github.com/launchdarkly/gh-actions/releases/tag/release-secrets-v1.2.0) | | `jlumbroso/free-disk-space` | v1.3.1 | `54081f138730dfa15788a46383842cd2f914a1be` | [release](https://github.com/jlumbroso/free-disk-space/releases/tag/v1.3.1) | | `reactivecircus/android-emulator-runner` | v2.34.0 | `324029e2f414c084d8b15ba075288885e74aef9c` | [release](https://github.com/reactivecircus/android-emulator-runner/releases/tag/v2.34.0) | ## Review & Testing Checklist for Human - [ ] **Verify SHA pins**: Confirm each SHA in the table above matches the stated version tag on the corresponding GitHub action repository. - [ ] **Verify `AWS_ROLE_ARN` repository variable**: The run workflow requires `vars.AWS_ROLE_ARN` to be configured for the OIDC-based AWS credentials flow. Confirm this variable is set in the repo settings. - [ ] **`sed` injection robustness**: The mobile key is injected via `sed -i "s/mobile-key-from-launch-darkly-website/$LAUNCHDARKLY_MOBILE_KEY/"`. If the mobile key contains `/` or other sed-special characters, this will break. Verify the key format is safe, or consider switching to a different delimiter. - [ ] **`uiautomator dump` reliability**: The evaluation validation uses `adb exec-out uiautomator dump /dev/tty` to capture UI text. Verify this reliably captures the flag evaluation text on the emulator. The 15-second sleep before the dump may need tuning if SDK initialization takes longer in CI. - [ ] **Test workflow execution**: Trigger or wait for both workflows to run and verify they complete successfully end-to-end. ### Notes - Inspired by the `js-core` repo's [`react-native-detox.yml`](https://github.com/launchdarkly/js-core/blob/main/.github/workflows/react-native-detox.yml) workflow. - SDK key retrieval follows the same `release-secrets` pattern used in other hello-app repos (e.g. `hello-ruby`). - The build workflow (`build.yml`) is straightforward and low-risk. - The run workflow (`run.yml`) uses KVM acceleration for emulator performance and frees disk space before launching the emulator to avoid space issues. --- Link to Devin Session: https://app.devin.ai/sessions/0b2bb3fc4f5845238a581c78eefd5369 Requested by: rlamb@launchdarkly.com <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/launchdarkly/hello-android/pull/13" target="_blank"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open with Devin"> </picture> </a> <!-- devin-review-badge-end --> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: rlamb@launchdarkly.com <rlamb@launchdarkly.com>
1 parent a933fb4 commit a1cf34c

2 files changed

Lines changed: 108 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths-ignore:
7+
- '**.md'
8+
pull_request:
9+
branches: [main]
10+
paths-ignore:
11+
- '**.md'
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-22.04
16+
steps:
17+
# https://github.com/actions/checkout/releases/tag/v4.2.2
18+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
19+
20+
# https://github.com/actions/setup-java/releases/tag/v4.7.1
21+
- name: Setup Java
22+
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
23+
with:
24+
distribution: temurin
25+
java-version: 17
26+
cache: 'gradle'
27+
28+
- name: Grant execute permission for gradlew
29+
run: chmod +x gradlew
30+
31+
- name: Build with Gradle
32+
run: ./gradlew assembleDebug

.github/workflows/run.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Run
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths-ignore:
7+
- '**.md'
8+
pull_request:
9+
branches: [main]
10+
paths-ignore:
11+
- '**.md'
12+
13+
jobs:
14+
run:
15+
runs-on: ubuntu-22.04
16+
permissions:
17+
id-token: write
18+
contents: read
19+
steps:
20+
# https://github.com/actions/checkout/releases/tag/v4.2.2
21+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
22+
23+
# https://github.com/launchdarkly/gh-actions/releases/tag/release-secrets-v1.2.0
24+
- uses: launchdarkly/gh-actions/actions/release-secrets@bbbbbda684f500766264e7fe327668094ba83d1c # release-secrets-v1.2.0
25+
name: 'Get mobile key and flag key'
26+
with:
27+
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
28+
ssm_parameter_pairs: '/sdk/common/hello-apps/mobile-key = LAUNCHDARKLY_MOBILE_KEY,
29+
/sdk/common/hello-apps/boolean-flag-key = LAUNCHDARKLY_FLAG_KEY'
30+
31+
- name: Configure SDK mobile key
32+
run: |
33+
sed -i "s/mobile-key-from-launch-darkly-website/$LAUNCHDARKLY_MOBILE_KEY/" app/src/main/java/com/launchdarkly/hello_android/MainApplication.kt
34+
35+
- name: Configure feature flag key
36+
run: |
37+
sed -i "s/sample-feature/$LAUNCHDARKLY_FLAG_KEY/" app/src/main/java/com/launchdarkly/hello_android/MainActivity.kt
38+
39+
# https://github.com/actions/setup-java/releases/tag/v4.7.1
40+
- name: Setup Java
41+
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
42+
with:
43+
distribution: temurin
44+
java-version: 17
45+
cache: 'gradle'
46+
47+
- name: Grant execute permission for gradlew
48+
run: chmod +x gradlew
49+
50+
- name: Build debug APK
51+
run: ./gradlew assembleDebug
52+
53+
- name: Enable KVM group perms (for performance)
54+
run: |
55+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
56+
sudo udevadm control --reload-rules
57+
sudo udevadm trigger --name-match=kvm
58+
59+
# https://github.com/jlumbroso/free-disk-space/releases/tag/v1.3.1
60+
- name: Free disk space
61+
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
62+
with:
63+
android: false
64+
large-packages: false
65+
66+
# https://github.com/reactivecircus/android-emulator-runner/releases/tag/v2.34.0
67+
- name: Run on emulator
68+
uses: reactivecircus/android-emulator-runner@324029e2f414c084d8b15ba075288885e74aef9c # v2.34.0
69+
with:
70+
api-level: 29
71+
arch: x86_64
72+
script: |
73+
adb install app/build/outputs/apk/debug/app-debug.apk
74+
adb shell am start -n com.launchdarkly.hello_android/.MainActivity
75+
sleep 15
76+
adb exec-out uiautomator dump /dev/tty | grep -o 'feature flag evaluates to true'

0 commit comments

Comments
 (0)