Skip to content

Commit

Permalink
Fixes issues and updates to M3
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseAlcerreca committed Dec 10, 2024
1 parent e7d267c commit 17f7410
Show file tree
Hide file tree
Showing 32 changed files with 339 additions and 367 deletions.
10 changes: 7 additions & 3 deletions .github/ci-gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@
#

org.gradle.daemon=false
org.gradle.parallel=false
org.gradle.jvmargs=-Xmx5120m
org.gradle.parallel=true
org.gradle.workers.max=2

kotlin.incremental=false
kotlin.compiler.execution.strategy=in-process

# Controls KotlinOptions.allWarningsAsErrors.
# This value used in CI and is currently set to false.
# If you want to treat warnings as errors locally, set this property to true
# in your ~/.gradle/gradle.properties file.
warningsAsErrors=false
72 changes: 27 additions & 45 deletions .github/workflows/blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,78 +1,60 @@
name: blueprints
name: build_test

on:
push:
branches:
- main
- views
pull_request:
branches:
- main
- views

jobs:
build:
runs-on: macos-latest # Needed for emulators
timeout-minutes: 45
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
matrix:
api-level: [29]

steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4

- 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
ls /dev/kvm
- name: Copy CI gradle.properties
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties

- name: Set up JDK 11
- name: Set Up JDK
uses: actions/setup-java@v4
with:
java-version: 11

- uses: actions/cache@v4
with:
path: |
~/.gradle/caches/modules-*
~/.gradle/caches/jars-*
~/.gradle/caches/build-cache-*
key: gradle-${{ hashFiles('checksum.txt') }}

- name: Build project and UnitTest
run: ./gradlew assembleDebug compileDebugUnitTestKotlin

- name: Spotless
# Spotless is not gradle configuration cache compliant. To allow the rest of the build
# comply, run spotless with a gradle init script and disable the cache.
run: ./gradlew spotlessCheck --init-script gradle/init.gradle.kts --no-configuration-cache
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '17'
cache: 'gradle'

- name: Unit tests
run: ./gradlew testDebugUnitTest
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

# Needed to accept licenses
- name: Setup Android SDK
uses: android-actions/setup-android@v3

- name: Compile AndroidTests
run: ./gradlew compileDebugAndroidTestKotlin

- name: Run instrumentation tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 31
arch: x86_64
api-level: ${{ matrix.api-level }}
arch: x86
disable-animations: true
disk-size: 2000M
heap-size: 600M
script: ./gradlew connectedDebugAndroidTest
script: ./gradlew connectedCheck --stacktrace

- name: Upload build reports
- name: Upload test reports
if: always()
uses: actions/upload-artifact@v4
with:
name: build-reports
path: app/build/reports/
name: test-reports-${{ matrix.api-level }}
path: ./app/build/reports/androidTests


- name: Upload all outputs
if: failure()
uses: actions/upload-artifact@v4
with:
name: outputs
path: app/build/outputs/
25 changes: 12 additions & 13 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kapt)
alias(libs.plugins.ksp)
alias(libs.plugins.hilt)
alias(libs.plugins.compose.compiler)
}

android {
namespace = "com.example.android.architecture.blueprints.todoapp"
compileSdk = libs.versions.compileSdk.get().toInt()

defaultConfig {
Expand Down Expand Up @@ -78,26 +79,23 @@ android {

buildFeatures {
compose = true
buildConfig = true
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "17"
}

packagingOptions {
packaging {
excludes += "META-INF/AL2.0"
excludes += "META-INF/LGPL2.1"
}

composeOptions {
kotlinCompilerExtensionVersion = libs.versions.androidxComposeCompiler.get()
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn"
Expand Down Expand Up @@ -128,7 +126,7 @@ dependencies {
// Hilt
implementation(libs.hilt.android.core)
implementation(libs.androidx.hilt.navigation.compose)
kapt(libs.hilt.compiler)
ksp(libs.hilt.compiler)

// Jetpack Compose
val composeBom = platform(libs.androidx.compose.bom)
Expand All @@ -139,7 +137,8 @@ dependencies {
implementation(libs.androidx.compose.foundation.core)
implementation(libs.androidx.compose.foundation.layout)
implementation(libs.androidx.compose.animation)
implementation(libs.androidx.compose.material.core)
implementation(libs.androidx.compose.material3)
implementation(libs.androidx.compose.material.iconsExtended)
implementation(libs.androidx.compose.ui.tooling.preview)
implementation(libs.androidx.navigation.compose)
implementation(libs.androidx.lifecycle.runtimeCompose)
Expand All @@ -166,7 +165,7 @@ dependencies {

// JVM tests - Hilt
testImplementation(libs.hilt.android.testing)
kaptTest(libs.hilt.compiler)
kspTest(libs.hilt.compiler)

// Dependencies for Android unit tests
androidTestImplementation(composeBom)
Expand Down Expand Up @@ -196,5 +195,5 @@ dependencies {

// AndroidX Test - Hilt testing
androidTestImplementation(libs.hilt.android.testing)
kaptAndroidTest(libs.hilt.compiler)
kspAndroidTest(libs.hilt.compiler)
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.example.android.architecture.blueprints.todoapp.addedittask

import androidx.compose.material.Surface
import androidx.compose.material3.Surface
import androidx.compose.ui.test.SemanticsNodeInteraction
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.hasSetTextAction
Expand All @@ -32,18 +32,18 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
import com.example.android.architecture.blueprints.todoapp.HiltTestActivity
import com.example.android.architecture.blueprints.todoapp.R
import com.example.android.architecture.blueprints.todoapp.TodoTheme
import com.example.android.architecture.blueprints.todoapp.data.TaskRepository
import com.google.accompanist.appcompattheme.AppCompatTheme
import dagger.hilt.android.testing.HiltAndroidRule
import dagger.hilt.android.testing.HiltAndroidTest
import javax.inject.Inject
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import javax.inject.Inject

/**
* Integration test for the Add Task screen.
Expand All @@ -70,7 +70,7 @@ class AddEditTaskScreenTest {

// GIVEN - On the "Add Task" screen.
composeTestRule.setContent {
AppCompatTheme {
TodoTheme {
Surface {
AddEditTaskScreen(
viewModel = AddEditTaskViewModel(repository, SavedStateHandle()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@

package com.example.android.architecture.blueprints.todoapp.statistics

import androidx.compose.material.Surface
import androidx.compose.material3.Surface
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.onNodeWithText
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
import com.example.android.architecture.blueprints.todoapp.HiltTestActivity
import com.example.android.architecture.blueprints.todoapp.R
import com.example.android.architecture.blueprints.todoapp.TodoTheme
import com.example.android.architecture.blueprints.todoapp.data.TaskRepository
import com.google.accompanist.appcompattheme.AppCompatTheme
import dagger.hilt.android.testing.HiltAndroidRule
import dagger.hilt.android.testing.HiltAndroidTest
import javax.inject.Inject
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import javax.inject.Inject

/**
* Integration test for the statistics screen.
Expand Down Expand Up @@ -71,7 +71,7 @@ class StatisticsScreenTest {
}

composeTestRule.setContent {
AppCompatTheme {
TodoTheme {
Surface {
StatisticsScreen(
openDrawer = { },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.example.android.architecture.blueprints.todoapp.taskdetail

import androidx.compose.material.Surface
import androidx.compose.material3.Surface
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.assertIsOff
import androidx.compose.ui.test.assertIsOn
Expand All @@ -27,17 +27,17 @@ import androidx.lifecycle.SavedStateHandle
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
import com.example.android.architecture.blueprints.todoapp.HiltTestActivity
import com.example.android.architecture.blueprints.todoapp.TodoTheme
import com.example.android.architecture.blueprints.todoapp.data.TaskRepository
import com.google.accompanist.appcompattheme.AppCompatTheme
import dagger.hilt.android.testing.HiltAndroidRule
import dagger.hilt.android.testing.HiltAndroidTest
import javax.inject.Inject
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import javax.inject.Inject

/**
* Integration test for the Task Details screen.
Expand Down Expand Up @@ -100,7 +100,7 @@ class TaskDetailScreenTest {

private fun setContent(activeTaskId: String) {
composeTestRule.setContent {
AppCompatTheme {
TodoTheme {
Surface {
TaskDetailScreen(
viewModel = TaskDetailViewModel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ import androidx.test.filters.LargeTest
import com.example.android.architecture.blueprints.todoapp.HiltTestActivity
import com.example.android.architecture.blueprints.todoapp.R
import com.example.android.architecture.blueprints.todoapp.TodoNavGraph
import com.example.android.architecture.blueprints.todoapp.TodoTheme
import com.example.android.architecture.blueprints.todoapp.data.TaskRepository
import com.google.accompanist.appcompattheme.AppCompatTheme
import dagger.hilt.android.testing.HiltAndroidRule
import dagger.hilt.android.testing.HiltAndroidTest
import javax.inject.Inject
import kotlinx.coroutines.test.runTest
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import javax.inject.Inject

/**
* Tests for scenarios that requires navigating within the app.
Expand Down Expand Up @@ -181,7 +181,7 @@ class AppNavigationTest {

private fun setContent() {
composeTestRule.setContent {
AppCompatTheme {
TodoTheme {
TodoNavGraph()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package com.example.android.architecture.blueprints.todoapp.tasks

import androidx.annotation.StringRes
import androidx.compose.material.Surface
import androidx.compose.material3.Surface
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.isToggleable
import androidx.compose.ui.test.junit4.createAndroidComposeRule
Expand All @@ -29,17 +29,17 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
import com.example.android.architecture.blueprints.todoapp.HiltTestActivity
import com.example.android.architecture.blueprints.todoapp.R
import com.example.android.architecture.blueprints.todoapp.TodoTheme
import com.example.android.architecture.blueprints.todoapp.data.TaskRepository
import com.google.accompanist.appcompattheme.AppCompatTheme
import dagger.hilt.android.testing.HiltAndroidRule
import dagger.hilt.android.testing.HiltAndroidTest
import javax.inject.Inject
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import javax.inject.Inject

/**
* Integration test for the Task List screen.
Expand Down Expand Up @@ -255,7 +255,7 @@ class TasksScreenTest {

private fun setContent() {
composeTestRule.setContent {
AppCompatTheme {
TodoTheme {
Surface {
TasksScreen(
viewModel = TasksViewModel(repository, SavedStateHandle()),
Expand Down
Loading

0 comments on commit 17f7410

Please sign in to comment.