Skip to content
Merged
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
92 changes: 92 additions & 0 deletions .github/workflows/integrated-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Integrated Tests

on:
pull_request:
branches: [ master ]
paths-ignore:
- 'fastlane/**'
- 'icons/**'
- 'images/**'
- 'scripts/**'
- 'whatsnew/**'
- '**.md'
- '**.MD'

# If two events are triggered within a short time in the same PR, cancel the run of the oldest event
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true

permissions:
contents: read
pull-requests: write

jobs:
integrated-tests:
name: 'Run Integrated UI Tests'
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'jetbrains'

- name: Grant execute permission for gradlew
run: chmod +x ./gradlew

- name: 🏗 Disable Firebase
run: |
bash ./scripts/enableDisableFirebase.sh false

- name: Enable KVM group perms
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: Run instrumented tests on Android Emulator
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
target: default
arch: x86_64
profile: Nexus 6
emulator-boot-timeout: 600
script: ./gradlew connectedFreeDebugAndroidTest --stacktrace

- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: app/build/reports/androidTests/connected/
retention-days: 7

- name: 💬 Comment on PR with test results
uses: actions/github-script@v7
if: always() && github.event_name == 'pull_request'
with:
script: |
const runId = context.runId;
const repo = context.repo;
const prNumber = context.issue.number;
const runUrl = `https://github.com/${repo.owner}/${repo.repo}/actions/runs/${runId}`;

const comment = `## 🧪 Integrated Test Results

The integrated UI tests have completed.

**View full test results:** [Test Run #${runId}](${runUrl})

Test reports are available in the artifacts section of the workflow run.`;

github.rest.issues.createComment({
owner: repo.owner,
repo: repo.repo,
issue_number: prNumber,
body: comment
});
8 changes: 8 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ android {
versionName = "1.0.18"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments += mapOf(
"clearPackageData" to "true",
)
}

testOptions {
execution = "ANDROIDX_TEST_ORCHESTRATOR"
}

productFlavors {
Expand Down Expand Up @@ -115,6 +122,7 @@ dependencies {
testImplementation(libs.ktor.client.mock)
testImplementation(libs.kotlinx.coroutines.test)
androidTestImplementation(libs.androidx.junit)
androidTestUtil(libs.orchestrator)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(platform(libs.androidx.compose.bom))
androidTestImplementation(libs.androidx.ui.test.junit4)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ class ExampleInstrumentedTest {
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.yogeshpaliyal.deepr", appContext.packageName)
assertEquals("com.yogeshpaliyal.deepr.debug", appContext.packageName)
}
}
Loading