Skip to content

Commit

Permalink
ci: Add android checks and unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KaylaBrady committed Dec 18, 2023
1 parent f5a6fd8 commit c50a7e3
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 9 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,35 @@ jobs:
create_credentials_file: true
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
# TODO: Get java version from .tool-versions?
- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
cache: gradle
- uses: actions/cache@v3
with:
path: ~/.konan
key: konan-${{ runner.os }}-${{ hashFiles('build.gradle.kts') }}
restore-keys: konan-${{ runner.os }}
# TODO: pre-commit run spotless
- run: ./gradlew spotlessCheck
- name: shared checks & unit tests
run: ./gradlew shared:check
uses: actions/upload-artifact@v3
if: failure()
with:
name: android-shared-reports
path: shared/build/reports
- name: android checks & unit tests
run: ./gradlew androidApp:check
uses: actions/upload-artifact@v3
if: failure()
with:
name: android-android-reports
path: androidApp/build/reports

- name: Fetch AWS secrets
uses: aws-actions/aws-secretsmanager-get-secrets@v1
with:
Expand Down
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ruby 3.2.2
java temurin-17.0.9+9
6 changes: 3 additions & 3 deletions androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ android {
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "1.8"
Expand All @@ -45,4 +45,4 @@ dependencies {
implementation(libs.compose.material3)
implementation(libs.androidx.activity.compose)
debugImplementation(libs.compose.ui.tooling)
}
}
25 changes: 24 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
plugins {
//trick: for the same plugin versions in all sub-modules
// trick: for the same plugin versions in all sub-modules
alias(libs.plugins.androidApplication).apply(false)
alias(libs.plugins.androidLibrary).apply(false)
alias(libs.plugins.kotlinAndroid).apply(false)
alias(libs.plugins.kotlinMultiplatform).apply(false)
id("com.diffplug.spotless").version("6.21.0")
}

spotless {
kotlinGradle {
ktlint()
}
}

subprojects {
apply(plugin = "com.diffplug.spotless")

spotless {
kotlin {
target("src/**/*.kt")
ktfmt().kotlinlangStyle()
}
kotlinGradle { ktfmt().kotlinlangStyle() }
}
}

tasks.getByName("clean", Delete::class) {
delete(rootProject.buildDir)
}
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ dependencyResolutionManagement {

rootProject.name = "MBTA_App"
include(":androidApp")
include(":shared")
include(":shared")
6 changes: 5 additions & 1 deletion shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ kotlin {
}
}
}

listOf(
iosX64(),
iosArm64(),
Expand Down Expand Up @@ -45,4 +45,8 @@ android {
defaultConfig {
minSdk = 28
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.mbta.tid.mbta_app

import org.junit.Assert.assertTrue
import org.junit.Assert.assertFalse
import org.junit.Test

class AndroidGreetingTest {

@Test
fun testExample() {
assertTrue("Check Android is mentioned", Greeting().greet().contains("Android"))
// TODO: Switch back to assertTrue. See how test failure is represented in CI
assertFalse("Check Android is mentioned", Greeting().greet().contains("Android"))
}
}
}

0 comments on commit c50a7e3

Please sign in to comment.