Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/gradle/androidx.preference-pref…
Browse files Browse the repository at this point in the history
…erence-1.2.0
  • Loading branch information
kodiakhq[bot] authored Jan 25, 2024
2 parents c46fcf5 + 7ded781 commit f8b6072
Show file tree
Hide file tree
Showing 108 changed files with 2,258 additions and 2,079 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ indent_style=space
indent_size=4
continuation_indent_size=4
insert_final_newline=true
disabled_rules=import-ordering
import_ordering=disabled
44 changes: 6 additions & 38 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,20 @@
name: CI and automatic releases
on:
pull_request:
push:
branches-ignore: [gh-pages]
branches: [master]
jobs:
static-checks:
name: Static checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1

ci:
needs: static-checks
name: "Run static checks and tests"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
with:
java-version: 17
- name: Cache Grade dependencies
uses: actions/cache@v1
with:
path: ~/.gradle
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- uses: eskatos/gradle-command-action@v1
with:
arguments: build --scan
- name: Assemble instrumentation tests APK
uses: eskatos/gradle-command-action@v1
with:
arguments: "app:assembleDebug app:assembleDebugAndroidTest"
- name: Run tests on physical and virtual devices
uses: asadmansr/Firebase-Test-Lab-Action@v1.0
with:
arg-spec: 'app/firebase-test-lab.yml:spec'
env:
SERVICE_ACCOUNT: ${{ secrets.CI_GCP_SERVICE_ACCOUNT }}
uses: relaycorp/shared-workflows/.github/workflows/android-app-ci.yml@main
secrets:
gcp_service_account: ${{ secrets.CI_GCP_SERVICE_ACCOUNT }}

release:
needs: ci
uses: relaycorp/shared-workflows/.github/workflows/android-app-release.yml@main
secrets:
android_keystore: ${{ secrets.ANDROID_KEYSTORE }}
android_keystore_password: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
android_key_alias: ${{ secrets.ANDROID_KEYSTORE_KEY_NAME }}
android_key_alias: ${{ secrets.ANDROID_KEYSTORE_KEY_ALIAS }}
android_key_password: ${{ secrets.ANDROID_KEYSTORE_KEY_PASSWORD }}
android_publisher_credentials: ${{ secrets.PUBLISHER_GCP_SERVICE_ACCOUNT }}
12 changes: 0 additions & 12 deletions .kodiak.toml

This file was deleted.

20 changes: 10 additions & 10 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ repositories {
}

android {
compileSdk 33
compileSdk 34
ndkVersion '21.3.6528147'

defaultConfig {
applicationId "tech.relaycorp.courier"
minSdk 23
targetSdk 33
targetSdk 34
versionCode 1
versionName project.findProperty("versionName") ?: "0.1"

Expand Down Expand Up @@ -113,7 +113,7 @@ android {

dependencies {
// Java 8
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'

// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
Expand All @@ -128,15 +128,15 @@ dependencies {
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'

// Dependency Injection
api 'com.google.dagger:dagger:2.43.2'
kapt 'com.google.dagger:dagger-compiler:2.43.2'
api 'com.google.dagger:dagger:2.48.1'
kapt 'com.google.dagger:dagger-compiler:2.48.1'

// Awala
implementation 'tech.relaycorp:awala:1.66.4'
implementation 'tech.relaycorp:cogrpc:1.1.30'
implementation 'tech.relaycorp:cogrpc-okhttp:1.1.18'
implementation 'tech.relaycorp:cogrpc:1.1.31'
implementation 'tech.relaycorp:cogrpc-okhttp:1.1.26'
implementation 'tech.relaycorp:doh:1.0.21'
testImplementation "tech.relaycorp:awala-testing:1.5.10"
testImplementation "tech.relaycorp:awala-testing:1.5.26"

// ORM
implementation "androidx.room:room-runtime:$roomVersion"
Expand Down Expand Up @@ -170,7 +170,7 @@ dependencies {

// Instrumentation Testing
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlinCoroutinesVersion"
androidTestImplementation "io.grpc:grpc-testing:$grpcVersion"
androidTestImplementation('androidx.test.espresso:espresso-core:3.5.1') {
Expand Down Expand Up @@ -198,7 +198,7 @@ configurations.all {

spotless {
kotlin {
ktlint('0.43.2').userData(['disabled_rules': 'import-ordering'])
ktlint '1.0.1'
target '**/*.kt'
}
}
Expand Down
6 changes: 3 additions & 3 deletions app/jacoco.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'jacoco'

jacoco {
toolVersion '0.8.5'
toolVersion '0.8.11'
}

task jacocoAndroidTestReport(type: JacocoReport) {
Expand Down Expand Up @@ -47,9 +47,9 @@ task jacocoAndroidTestReport(type: JacocoReport) {

reports {
html.required = true
html.destination file("${buildDir}/reports/coverage")
html.outputLocation = file("${buildDir}/reports/coverage")
xml.required = true
xml.destination file("${buildDir}/reports/coverage.xml")
xml.outputLocation = file("${buildDir}/reports/coverage.xml")
csv.required = false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import javax.inject.Singleton
@Component(
modules = [
AppModule::class,
DataModule::class
]
DataModule::class,
],
)
interface TestAppComponent : AppComponent {
fun inject(app: TestApp)
Expand All @@ -27,6 +27,8 @@ interface TestAppComponent : AppComponent {
// Tests

fun inject(test: MainActivityTest)

fun inject(test: PrivateSyncTest)

fun inject(test: SettingsActivityTest)
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import java.util.Date

@RunWith(AndroidJUnit4::class)
class StoredMessageDaoTest {

private lateinit var storedMessageDao: StoredMessageDao

@Before
Expand All @@ -24,47 +23,52 @@ class StoredMessageDaoTest {
}

@Test
fun insertAndGet() = runTest(testDispatcher) {
val messages = StoredMessageFactory.build()
storedMessageDao.insert(messages)
assertEquals(
listOf(messages),
storedMessageDao.observeAll().first()
)
}
fun insertAndGet() =
runTest(testDispatcher) {
val messages = StoredMessageFactory.build()
storedMessageDao.insert(messages)
assertEquals(
listOf(messages),
storedMessageDao.observeAll().first(),
)
}

@Test
fun observeTotalSize() = runTest(testDispatcher) {
assertEquals(
StorageSize.ZERO,
storedMessageDao.observeTotalSize().first()
)
fun observeTotalSize() =
runTest(testDispatcher) {
assertEquals(
StorageSize.ZERO,
storedMessageDao.observeTotalSize().first(),
)

val messages =
(1..3)
.map { StoredMessageFactory.build() }
.also { it.map { c -> storedMessageDao.insert(c) } }
val messages =
(1..3)
.map { StoredMessageFactory.build() }
.also { it.map { c -> storedMessageDao.insert(c) } }

assertEquals(
messages.map { it.size.bytes }.sum(),
storedMessageDao.observeTotalSize().first().bytes
)
}
assertEquals(
messages.map { it.size.bytes }.sum(),
storedMessageDao.observeTotalSize().first().bytes,
)
}

@Test
fun getExpiredBy() = runTest(testDispatcher) {
val date = Date()
val expiredMessage = StoredMessageFactory.build()
.copy(expirationTimeUtc = Date(date.time - 1))
val unexpiredMessage = StoredMessageFactory.build()
.copy(expirationTimeUtc = Date(date.time + 1))
fun getExpiredBy() =
runTest(testDispatcher) {
val date = Date()
val expiredMessage =
StoredMessageFactory.build()
.copy(expirationTimeUtc = Date(date.time - 1))
val unexpiredMessage =
StoredMessageFactory.build()
.copy(expirationTimeUtc = Date(date.time + 1))

storedMessageDao.insert(expiredMessage)
storedMessageDao.insert(unexpiredMessage)
storedMessageDao.insert(expiredMessage)
storedMessageDao.insert(unexpiredMessage)

assertEquals(
listOf(expiredMessage),
storedMessageDao.getExpiredBy(date)
)
}
assertEquals(
listOf(expiredMessage),
storedMessageDao.getExpiredBy(date),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import org.junit.Test
import tech.relaycorp.courier.data.model.StorageSize

internal class DiskStatsTest {

private val diskStats = DiskStats()

@Test
internal fun basicCheck() = runBlocking {
assertTrue(diskStats.getTotalStorage() > StorageSize.ZERO)
assertTrue(diskStats.getAvailableStorage() > StorageSize.ZERO)
assertTrue(diskStats.getAvailableStorage() < diskStats.getTotalStorage())
}
internal fun basicCheck() =
runBlocking {
assertTrue(diskStats.getTotalStorage() > StorageSize.ZERO)
assertTrue(diskStats.getAvailableStorage() > StorageSize.ZERO)
assertTrue(diskStats.getAvailableStorage() < diskStats.getTotalStorage())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import tech.relaycorp.courier.test.AppTestProvider.flowSharedPreferences
import tech.relaycorp.courier.test.AppTestProvider.testDispatcher

class StoragePreferencesTest {

private val preferences = StoragePreferences { flowSharedPreferences }

@Before
Expand All @@ -25,18 +24,19 @@ class StoragePreferencesTest {
}

@Test
fun maxStorage() = runTest(testDispatcher) {
assertEquals(
StoragePreferences.DEFAULT_MAX_STORAGE_SIZE,
preferences.getMaxStorageSize().first()
)

val newSize = StorageSize(100)
preferences.setMaxStorageSize(newSize)

assertEquals(
newSize,
preferences.getMaxStorageSize().first()
)
}
fun maxStorage() =
runTest(testDispatcher) {
assertEquals(
StoragePreferences.DEFAULT_MAX_STORAGE_SIZE,
preferences.getMaxStorageSize().first(),
)

val newSize = StorageSize(100)
preferences.setMaxStorageSize(newSize)

assertEquals(
newSize,
preferences.getMaxStorageSize().first(),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import java.util.concurrent.TimeUnit
import javax.inject.Inject

class PrivateSyncTest {

@Inject
lateinit var privateSync: PrivateSync

Expand All @@ -35,7 +34,7 @@ class PrivateSyncTest {
// Related issue: https://github.com/relaycorp/relaynet-courier-android/issues/584
assumeTrue(
"Test is currently failing on API 23 and lower due to a grpc internal issue",
Build.VERSION.SDK_INT >= 24
Build.VERSION.SDK_INT >= 24,
)

Networking.androidGatewaySubnetPrefix = null
Expand All @@ -57,7 +56,7 @@ class PrivateSyncTest {
OkHTTPChannelBuilderProvider
.makeBuilder(
InetSocketAddress(gatewayIpAddress, 21473),
PrivateSubnetTrustManager.INSTANCE
PrivateSubnetTrustManager.INSTANCE,
)
.hostnameVerifier { _, _ -> true }
.build()
Expand All @@ -66,8 +65,8 @@ class PrivateSyncTest {
private val client by lazy {
CargoRelayGrpc.newStub(clientChannel).withInterceptors(
MetadataUtils.newAttachHeadersInterceptor(
AuthorizationMetadata.makeMetadata("CCA".toByteArray())
)
AuthorizationMetadata.makeMetadata("CCA".toByteArray()),
),
)
}
}
Loading

0 comments on commit f8b6072

Please sign in to comment.