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

Pipeline #23

Merged
merged 9 commits into from
Mar 20, 2024
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
10 changes: 9 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Gradle cache
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: 8.3
gradle-version: 7.5

- name: AVD cache
uses: actions/cache@v4
Expand Down Expand Up @@ -59,10 +59,18 @@ jobs:
~/.android/adb*
key: avd-29

- name: Add Dropbox API credentials
shell: bash
run: |
echo "dropbox.token = \"${{ secrets.DROPBOX_APP_TOKEN }}\"" >> app.properties
echo "dropbox.app_key = \"${{ secrets.DROPBOX_APP_KEY }}\"" >> app.properties
echo "dropbox.app_key_schema = \"db-${{ secrets.DROPBOX_APP_KEY }}\"" >> app.properties

- name: run tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
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
Expand Down
2 changes: 0 additions & 2 deletions app/src/androidTest/java/com/orgzly/android/OrgzlyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ public void tearDown() throws Exception {
database.close();

dataRepository.clearDatabase();

localStorage.cleanup();
}

private void setupPreferences() {
Expand Down
4 changes: 2 additions & 2 deletions app/src/androidTest/java/com/orgzly/android/RetryTestRule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.junit.runners.model.Statement
/**
* Retry test rule used to retry test that failed. Retry failed test 3 times
*/
class RetryTestRule(val retryCount: Int = 3) : TestRule {
class RetryTestRule(val retryCount: Int = 3, val sleepBetweenAttemptsMs: Long = 1000) : TestRule {

private val TAG = RetryTestRule::class.java.simpleName

Expand All @@ -30,7 +30,7 @@ class RetryTestRule(val retryCount: Int = 3) : TestRule {
} catch (t: Throwable) {
caughtThrowable = t
Log.e(TAG, description.displayName + ": run " + (i + 1) + " failed")
Thread.sleep(1000)
Thread.sleep(sleepBetweenAttemptsMs)
}
}

Expand Down
11 changes: 10 additions & 1 deletion app/src/androidTest/java/com/orgzly/android/query/QueryTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ package com.orgzly.android.query

import androidx.test.espresso.matcher.ViewMatchers.assertThat
import com.orgzly.android.OrgzlyTest
import com.orgzly.android.RetryTestRule
import com.orgzly.android.query.sql.SqliteQueryBuilder
import com.orgzly.android.query.user.DottedQueryBuilder
import com.orgzly.android.query.user.DottedQueryParser
import org.hamcrest.Matchers.`is`
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TestRule
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
import java.util.*
import java.util.Calendar

@RunWith(value = Parameterized::class)
class QueryTest(private val param: Parameter) : OrgzlyTest() {
Expand All @@ -23,6 +26,12 @@ class QueryTest(private val param: Parameter) : OrgzlyTest() {
private lateinit var actualQuerySortOrders: List<SortOrder>
private lateinit var actualQueryOptions: Options

@Rule
@JvmField
// Avoid sleeping between test attempts, as parameter creation vs test run
// timing is sensitive for many of these tests.
val mRetryTestRule: TestRule = RetryTestRule(3, 0)

data class Parameter(
val queryString: String,
val expectedParsedQuery: String? = null,
Expand Down
Loading