Skip to content

Commit 346e8fb

Browse files
authored
test: O11Y-908 - Add Android CI workflows (#337)
## Summary Introduces GitHub Actions workflows for Android E2E and Observability unit tests, enabling automated test runs on push and pull requests. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Introduces CI for Android testing and aligns tests with minor API changes. > > - Adds `Android E2E App Tests` workflow (`.github/workflows/android-e2e.yml`) to run `:app:testDebugUnitTest` for `e2e/android`, setting up JDK 17 and Android SDK, and uploading JUnit XML artifacts > - Adds `Android Observability` workflow (`.github/workflows/android-observability.yml`) to run `:lib:testDebugUnitTest` for `sdk/@launchdarkly/observability-android`, with artifact uploads > - Updates `SessionReplayExporterTest.kt`: sets `sessionId = null` in `IdentifyItemPayload` and uses `attributes` accessor instead of `getAttributes()` when mocking `LogRecordData` > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 4b02c29. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 069c518 commit 346e8fb

File tree

3 files changed

+104
-2
lines changed

3 files changed

+104
-2
lines changed

.github/workflows/android-e2e.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: 'Android E2E App Tests'
2+
3+
on:
4+
push:
5+
branches: ['main']
6+
paths:
7+
- 'e2e/android/**'
8+
- 'sdk/@launchdarkly/observability-android/**'
9+
- '.github/workflows/android-e2e.yml'
10+
pull_request:
11+
types: [opened, synchronize]
12+
paths:
13+
- 'e2e/android/**'
14+
- 'sdk/@launchdarkly/observability-android/**'
15+
- '.github/workflows/android-e2e.yml'
16+
17+
permissions:
18+
contents: read
19+
20+
concurrency: ${{ github.workflow }}-${{ github.ref }}
21+
jobs:
22+
test:
23+
name: E2E Tests
24+
runs-on: ubuntu-22.04-8core-32gb
25+
defaults:
26+
run:
27+
working-directory: ./e2e/android
28+
steps:
29+
- uses: actions/checkout@v4
30+
with:
31+
token: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Set up JDK 17
34+
uses: actions/setup-java@v4
35+
with:
36+
distribution: 'temurin'
37+
java-version: 17
38+
39+
- name: Set up Android SDK
40+
uses: android-actions/setup-android@9fc6c4e9069bf8d3d10b2204b1fb8f6ef7065407 # v3.2.2 commit SHA - https://github.com/android-actions/setup-android/releases/tag/v3.2.2
41+
42+
- name: Run unit tests
43+
run: ./gradlew :app:testDebugUnitTest
44+
45+
- name: Upload test reports
46+
if: always()
47+
uses: actions/upload-artifact@v4
48+
with:
49+
name: android-e2e-unit-test-results
50+
path: e2e/android/**/build/test-results/**/TEST-*.xml
51+
retention-days: 7
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: 'Android Observability'
2+
3+
on:
4+
push:
5+
branches: ['main']
6+
paths:
7+
- 'sdk/@launchdarkly/observability-android/**'
8+
- '.github/workflows/android-observability.yml'
9+
pull_request:
10+
types: [opened, synchronize]
11+
paths:
12+
- 'sdk/@launchdarkly/observability-android/**'
13+
- '.github/workflows/android-observability.yml'
14+
15+
permissions:
16+
contents: read
17+
18+
concurrency: ${{ github.workflow }}-${{ github.ref }}
19+
jobs:
20+
test:
21+
name: Unit Tests
22+
runs-on: ubuntu-22.04-8core-32gb
23+
defaults:
24+
run:
25+
working-directory: ./sdk/@launchdarkly/observability-android
26+
steps:
27+
- uses: actions/checkout@v4
28+
with:
29+
token: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Set up JDK 17
32+
uses: actions/setup-java@v4
33+
with:
34+
distribution: 'temurin'
35+
java-version: 17
36+
37+
- name: Set up Android SDK
38+
uses: android-actions/setup-android@9fc6c4e9069bf8d3d10b2204b1fb8f6ef7065407 # v3.2.2 commit SHA - https://github.com/android-actions/setup-android/releases/tag/v3.2.2
39+
40+
- name: Run unit tests
41+
run: ./gradlew :lib:testDebugUnitTest
42+
43+
- name: Upload test reports
44+
if: always()
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: android-unit-test-results
48+
path: sdk/@launchdarkly/observability-android/**/build/test-results/**/TEST-*.xml
49+
retention-days: 7

sdk/@launchdarkly/observability-android/lib/src/test/kotlin/com/launchdarkly/observability/replay/SessionReplayExporterTest.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ class SessionReplayExporterTest {
2222

2323
private val identifyEvent = IdentifyItemPayload(
2424
attributes = mapOf("key" to "user"),
25-
timestamp = 0L)
25+
timestamp = 0L,
26+
sessionId = null
27+
)
2628

2729
@BeforeEach
2830
fun setUp() {
@@ -465,7 +467,7 @@ class SessionReplayExporterTest {
465467
sessionId?.let { attributesBuilder.put(AttributeKey.stringKey("session.id"), it) }
466468

467469
return mockk<LogRecordData>().apply {
468-
every { getAttributes() } returns attributesBuilder.build()
470+
every { attributes } returns attributesBuilder.build()
469471
every { observedTimestampEpochNanos } returns timestamp
470472
}
471473
}

0 commit comments

Comments
 (0)