Skip to content

Commit

Permalink
Merge branch 'main' into chore/speed_up_the_build
Browse files Browse the repository at this point in the history
# Conflicts:
#	gradle.properties
  • Loading branch information
azrael8576 committed Sep 29, 2023
2 parents c417b28 + 53b54f2 commit cff0ef9
Show file tree
Hide file tree
Showing 22 changed files with 247 additions and 43 deletions.
21 changes: 21 additions & 0 deletions .github/ci-gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Disables the use of the Gradle daemon, which is a background process for speeding up Gradle commands.
# With this set to false, a new Gradle process will be started for each build.
org.gradle.daemon=false

# Enables the parallel execution of tasks that do not depend on each other. This can speed up the overall build process.
org.gradle.parallel=true

# Sets the maximum number of worker processes that Gradle can use for executing tasks (e.g., compilation).
# Here, it is limited to 2 worker processes.
org.gradle.workers.max=2

# Disables the incremental compilation feature of Kotlin. With incremental compilation, only the changed source files get recompiled.
kotlin.incremental=false

# Determines how the Kotlin compiler runs. 'in-process' means the compiler runs inside the Gradle process, not as a separate process.
kotlin.compiler.execution.strategy=in-process

# Controls whether warnings in Kotlin code should be treated as errors during the compilation process.
# This setting is useful for CI environments where you might not want a build to fail just because of warnings.
# Set to true if you want to treat warnings as errors in your local setup.
warningsAsErrors=false
130 changes: 130 additions & 0 deletions .github/workflows/Build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
name: Build

on:
push:
branches:
- main
pull_request:

concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 90

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

- name: Build all build type and flavor permutations
run: ./gradlew assemble

- name: Upload build outputs (APKs)
uses: actions/upload-artifact@v3
with:
name: APKs
path: '**/build/outputs/apk/**/*.apk'

- 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 test

- 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, 30]

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

- 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

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

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

- name: Upload test reports
if: always()
uses: actions/upload-artifact@v3
with:
name: test-reports-${{ matrix.api-level }}
path: '**/build/reports/androidTests'
27 changes: 21 additions & 6 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,24 @@ android {
versionName = "0.5.0"

testInstrumentationRunner = "com.wei.amazingtalker_recruit.core.testing.AtTestRunner"

vectorDrawables {
useSupportLibrary = true
}
}

buildTypes {
getByName("release") {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
debug {
applicationIdSuffix = ".debug"
}
release {
isMinifyEnabled = true
applicationIdSuffix = null
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
// who clones the code to sign and run the release variant, use the debug signing key.
// TODO: Abstract the signing configuration to a separate file to avoid hardcoding this.
signingConfig = signingConfigs.getByName("debug")
}
}
Expand All @@ -63,6 +72,12 @@ android {
viewBinding = true
compose = true
}

testOptions {
unitTests {
isIncludeAndroidResources = true
}
}
}

dependencies {
Expand Down
2 changes: 1 addition & 1 deletion core/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ android {
defaultConfig {
minSdk = 23

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunner = "com.wei.amazingtalker_recruit.core.testing.AtTestRunner"
}

buildTypes {
Expand Down
6 changes: 3 additions & 3 deletions core/common/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="generic_hello">Hello</string>
<string name="greeting_with_name">Hello, %s!</string>
<string name="greeting_with_name_and_weather">Hello, %s! It\'s a %s day today.</string>
<string name="generic_hello" translatable="false">Hello</string>
<string name="greeting_with_name" translatable="false">Hello, %s!</string>
<string name="greeting_with_name_and_weather" translatable="false">Hello, %1$s! It\'s a %2$s day today.</string>
</resources>
2 changes: 1 addition & 1 deletion core/data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ android {
defaultConfig {
minSdk = 23

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
// testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
Expand Down
2 changes: 1 addition & 1 deletion core/datastore-test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ android {
defaultConfig {
minSdk = 23

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
// testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
Expand Down
2 changes: 1 addition & 1 deletion core/datastore/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ android {
defaultConfig {
minSdk = 23

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
// testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
Expand Down
6 changes: 3 additions & 3 deletions core/domain/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ android {
defaultConfig {
minSdk = 23

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
// testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
getByName("release") {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/model/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ android {
defaultConfig {
minSdk = 23

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
// testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
Expand Down
28 changes: 14 additions & 14 deletions core/network/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.ksp)
alias(libs.plugins.secrets)
}

android {
Expand All @@ -13,22 +14,11 @@ android {
defaultConfig {
minSdk = 23

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
// testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
val AmazingTalkerServerUrl: String by project
getByName("debug") {
buildConfigField("String", "ServerUrl", AmazingTalkerServerUrl)
}
getByName("release") {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
buildConfigField("String", "ServerUrl", AmazingTalkerServerUrl)
}
buildFeatures {
buildConfig = true
}

compileOptions {
Expand All @@ -41,6 +31,16 @@ android {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}

testOptions {
unitTests {
isIncludeAndroidResources = true
}
}
}

secrets {
defaultPropertiesFileName = "secrets.defaults.properties"
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface RetrofitAtNetworkApi {
): NetworkTeacherSchedule
}

private const val AtBaseUrl = BuildConfig.ServerUrl
private const val AtBaseUrl = BuildConfig.BACKEND_URL

/**
* [Retrofit] backed [AtNetworkDataSource]
Expand Down
2 changes: 1 addition & 1 deletion core/testing/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ android {
defaultConfig {
minSdk = 23

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
// testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
Expand Down
2 changes: 1 addition & 1 deletion feature/contactme/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ android {
defaultConfig {
minSdk = 23

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunner = "com.wei.amazingtalker_recruit.core.testing.AtTestRunner"
}

buildTypes {
Expand Down
2 changes: 1 addition & 1 deletion feature/login/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ android {
defaultConfig {
minSdk = 23

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunner = "com.wei.amazingtalker_recruit.core.testing.AtTestRunner"
}

buildTypes {
Expand Down
2 changes: 1 addition & 1 deletion feature/teacherschedule/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ android {
defaultConfig {
minSdk = 23

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunner = "com.wei.amazingtalker_recruit.core.testing.AtTestRunner"
}

buildTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

<!-- 教師行事曆頁面 -->
<string name="your_local_time_zone">您當地的時區: %1$s GMT %2$s</string>
<string name="inquirying_teacher_calendar">您正在查詢 %s 老師
\n%s 的行事曆。</string>
<string name="inquirying_teacher_calendar">您正在查詢 %1$s 老師
\n%2$s 的行事曆。</string>
<string name="clickWeekDate">開啟日曆: %s</string>
<string name="morning">上午</string>
<string name="afternoon">下午</string>
Expand Down
6 changes: 2 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,5 @@ android.nonTransitiveRClass=true
android.defaults.buildfeatures.buildconfig=true
android.nonFinalResIds=false

android.suppressUnsupportedCompileSdk=34

# Debug Server Url
AmazingTalkerServerUrl="https://tw.amazingtalker.com/v1/guest/"
# This Android Gradle plugin (8.1.0-rc01) was tested up to compileSdk = 33 (and compileSdkPreview = "UpsideDownCakePrivacySandbox").
android.suppressUnsupportedCompileSdk=34
Loading

0 comments on commit cff0ef9

Please sign in to comment.