Skip to content

Commit

Permalink
Merge pull request #4 from azrael8576/chore/speed_up_the_build
Browse files Browse the repository at this point in the history
Chore/speed up the build
  • Loading branch information
azrael8576 authored Sep 30, 2023
2 parents 376b4fb + 53a65e3 commit d6ea1ff
Show file tree
Hide file tree
Showing 71 changed files with 945 additions and 931 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
# Run local tests after screenshot tests to avoid wrong UP-TO-DATE. TODO: Ignore screenshots.
- name: Run local tests
if: always()
run: ./gradlew test
run: ./gradlew testDemoDebug testProdDebug

- name: Upload test results (XML)
if: always()
Expand Down Expand Up @@ -110,18 +110,17 @@ jobs:
uses: gradle/gradle-build-action@v2

- name: Build AndroidTest apps
run: ./gradlew packageDebug packageDebugAndroidTest --daemon
run: ./gradlew packageDemoDebug packageDemoDebugAndroidTest --daemon

- name: Run instrumentation tests
uses: reactivecircus/android-emulator-runner@v2
continue-on-error: true
with:
api-level: ${{ matrix.api-level }}
arch: x86_64
disable-animations: true
disk-size: 6000M
heap-size: 600M
script: ./gradlew connectedDebugAndroidTest --daemon
script: ./gradlew connectedDemoDebugAndroidTest --daemon --profile

- name: Upload test reports
if: always()
Expand Down
53 changes: 45 additions & 8 deletions .github/workflows/CICDTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,52 @@ jobs:
- name: Run local tests
run: ./gradlew test

test:
runs-on: ubuntu-latest

permissions:
contents: write

timeout-minutes: 60

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

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1

- name: Copy CI gradle.properties
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 17

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

# Run local tests after screenshot tests to avoid wrong UP-TO-DATE. TODO: Ignore screenshots.
- name: Run local tests
if: always()
run: ./gradlew testDemoDebug testProdDebug

- name: Upload test results (XML)
if: always()
uses: actions/upload-artifact@v3
with:
name: test-results
path: '**/build/test-results/test*UnitTest/**.xml'

androidTest:
needs: build
runs-on: macOS-latest # enables hardware acceleration in the virtual machine
timeout-minutes: 55
strategy:
matrix:
api-level: [26]
api-level: [26, 30]

steps:
- name: Checkout
Expand All @@ -70,7 +109,7 @@ jobs:
uses: gradle/gradle-build-action@v2

- name: Build AndroidTest apps
run: ./gradlew packageDebug packageDebugAndroidTest --daemon
run: ./gradlew packageDemoDebug packageDemoDebugAndroidTest --daemon

- name: Run instrumentation tests
uses: reactivecircus/android-emulator-runner@v2
Expand All @@ -81,16 +120,14 @@ jobs:
disable-animations: true
disk-size: 6000M
heap-size: 600M
script: |
./gradlew connectedDebugAndroidTest --daemon || echo "UI Test failed"
adb logcat -d > logcat_output.txt
script: ./gradlew connectedDemoDebugAndroidTest --daemon --profile

- name: Upload logcat output
- name: Upload Profiling Report
if: always()
uses: actions/upload-artifact@v3
with:
name: logcat-output
path: logcat_output.txt
name: profiling-report-${{ matrix.api-level }}
path: '**/build/reports/profile'

- name: Upload test reports
if: always()
Expand Down
56 changes: 42 additions & 14 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,44 @@
# built application files
*.apk
*.ap_

# files for the dex VM
*.dex

# Java class files
*.class

# generated files
bin/
gen/
out/
build/

# Local configuration file (sdk path, etc)
local.properties

# Eclipse project files
.classpath
.project

# Windows thumbnail db
.DS_Store

# IDEA/Android Studio project files
*.iml
.idea/*
!.idea/copyright
# Keep the code styles
!/.idea/codeStyles
/.idea/codeStyles/*
!/.idea/codeStyles/Project.xml
!/.idea/codeStyles/codeStyleConfig.xml

# Gradle cache
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
.idea/

# Sandbox stuff
_sandbox

# Android Studio captures folder
captures/
54 changes: 18 additions & 36 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import com.wei.amazingtalker_recruit.AtBuildType

plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.hilt)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.ksp)
id("at.android.application")
id("at.android.application.compose")
id("at.android.application.flavors")
id("at.android.hilt")
}

android {
namespace = "com.wei.amazingtalker_recruit"
compileSdk = 34

defaultConfig {
applicationId = "com.wei.amazingtalker_recruit"
minSdk = 23
targetSdk = 33
/**
* Version Code: AABCXYZ
*
Expand All @@ -30,6 +29,7 @@ android {
*/
versionName = "0.5.0"

// Custom test runner to set up Hilt dependency graph
testInstrumentationRunner = "com.wei.amazingtalker_recruit.core.testing.AtTestRunner"

vectorDrawables {
Expand All @@ -39,11 +39,11 @@ android {

buildTypes {
debug {
applicationIdSuffix = ".debug"
applicationIdSuffix = AtBuildType.DEBUG.applicationIdSuffix
}
release {
isMinifyEnabled = true
applicationIdSuffix = null
applicationIdSuffix = AtBuildType.RELEASE.applicationIdSuffix
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")

// To publish on the Play store a private signing key is required, but to allow anyone
Expand All @@ -53,26 +53,11 @@ android {
}
}

compileOptions {
// Flag to enable support for the new language APIs
isCoreLibraryDesugaringEnabled = true
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}

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

buildFeatures {
viewBinding = true
compose = true
packaging {
resources {
excludes.add("/META-INF/{AL2.0,LGPL2.1}")
}
}

testOptions {
unitTests {
isIncludeAndroidResources = true
Expand All @@ -81,14 +66,16 @@ android {
}

dependencies {
implementation(project(":feature:login"))
implementation(project(":feature:teacherschedule"))
implementation(project(":feature:contactme"))

implementation(project(":core:designsystem"))
implementation(project(":core:common"))
implementation(project(":core:data"))
implementation(project(":core:model"))
implementation(project(":core:datastore"))
implementation(project(":feature:login"))
implementation(project(":feature:teacherschedule"))
implementation(project(":feature:contactme"))

androidTestImplementation(project(":core:designsystem"))
androidTestImplementation(project(":core:datastore-test"))
androidTestImplementation(project(":core:testing"))
Expand Down Expand Up @@ -116,11 +103,6 @@ dependencies {
implementation(libs.kotlinx.coroutines.android)
implementation(libs.kotlinx.coroutines.core)

// Hilt
implementation(libs.hilt.android)
ksp(libs.hilt.compiler)
kspAndroidTest(libs.hilt.android.compiler)

// Timber
implementation(libs.timber)

Expand Down
22 changes: 21 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,24 @@

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile

-dontwarn org.bouncycastle.jsse.BCSSLParameters
-dontwarn org.bouncycastle.jsse.BCSSLSocket
-dontwarn org.bouncycastle.jsse.provider.BouncyCastleJsseProvider
-dontwarn org.conscrypt.Conscrypt$Version
-dontwarn org.conscrypt.Conscrypt
-dontwarn org.conscrypt.ConscryptHostnameVerifier
-dontwarn org.openjsse.javax.net.ssl.SSLParameters
-dontwarn org.openjsse.javax.net.ssl.SSLSocket
-dontwarn org.openjsse.net.ssl.OpenJSSE

# Fix for Retrofit issue https://github.com/square/retrofit/issues/3751
# Keep generic signature of Call, Response (R8 full mode strips signatures from non-kept items).
-keep,allowobfuscation,allowshrinking interface retrofit2.Call
-keep,allowobfuscation,allowshrinking class retrofit2.Response

# With R8 full mode generic signatures are stripped for classes that are not
# kept. Suspend functions are wrapped in continuations where the type argument
# is used.
-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation
38 changes: 38 additions & 0 deletions build-logic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Convention Plugins

The `build-logic` folder defines project-specific convention plugins, used to keep a single
source of truth for common module configurations.

This approach is heavily based on
[https://developer.squareup.com/blog/herding-elephants/](https://developer.squareup.com/blog/herding-elephants/)
and
[https://github.com/jjohannes/idiomatic-gradle](https://github.com/jjohannes/idiomatic-gradle).

By setting up convention plugins in `build-logic`, we can avoid duplicated build script setup,
messy `subproject` configurations, without the pitfalls of the `buildSrc` directory.

`build-logic` is an included build, as configured in the root
[`settings.gradle.kts`](../settings.gradle.kts).

Inside `build-logic` is a `convention` module, which defines a set of plugins that all normal
modules can use to configure themselves.

`build-logic` also includes a set of `Kotlin` files used to share logic between plugins themselves,
which is most useful for configuring Android components (libraries vs applications) with shared
code.

These plugins are *additive* and *composable*, and try to only accomplish a single responsibility.
Modules can then pick and choose the configurations they need.
If there is one-off logic for a module without shared code, it's preferable to define that directly
in the module's `build.gradle`, as opposed to creating a convention plugin with module-specific
setup.

Current list of convention plugins:

- [`at.android.application`](convention/src/main/kotlin/AndroidApplicationConventionPlugin.kt),
[`at.android.library`](convention/src/main/kotlin/AndroidLibraryConventionPlugin.kt),
[`at.android.test`](convention/src/main/kotlin/AndroidTestConventionPlugin.kt):
Configures common Android and Kotlin options.
- [`at.android.application.compose`](convention/src/main/kotlin/AndroidApplicationComposeConventionPlugin.kt),
[`at.android.library.compose`](convention/src/main/kotlin/AndroidLibraryComposeConventionPlugin.kt):
Configures Jetpack Compose options
1 change: 1 addition & 0 deletions build-logic/convention/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
Loading

0 comments on commit d6ea1ff

Please sign in to comment.