diff --git a/.github/workflows/master_dev_ci.yml b/.github/workflows/master_dev_ci.yml index 4beca38f9..42bbfa670 100644 --- a/.github/workflows/master_dev_ci.yml +++ b/.github/workflows/master_dev_ci.yml @@ -12,64 +12,29 @@ jobs: name: Build APK runs-on: ubuntu-latest steps: - - name: Checking out repository + - name: Checkout code uses: actions/checkout@v4 - # Set up JDK - - name: Set Up JDK 1.8 - uses: actions/setup-java@v1 + - name: Set up JDK 17 + uses: actions/setup-java@v4 with: - java-version: 11 + distribution: 'zulu' + java-version: 17 - # Install NDK -# - name: Install NDK -# run: echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;20.0.5594570" --sdk_root=${ANDROID_SDK_ROOT} + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 - # Update Gradle Permission - - name: Change gradlew Permission - run: chmod +x gradlew - - # Build App - - name: Build with Gradle - run: ./gradlew assemble - - # Upload Built APK - - name: Upload Build Artifacts - uses: actions/upload-artifact@v3.1.3 + - name: Cache Gradle and build outputs + uses: actions/cache@v4 with: - name: mifos-mobile - path: app/build/outputs/apk/debug/ + path: | + ~/.gradle/caches + ~/.gradle/wrapper + build + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: ${{ runner.os }}-gradle- - lintCheck: - name: Static Analysis - runs-on: ubuntu-latest - steps: - - name: Checking out repository - uses: actions/checkout@v4 + - name: Build With Gradle + run: ./gradlew build - - name: Static Analysis - run: ./gradlew lint - - name: Upload Static Analysis Report For Mifos-Mobile Module - uses: actions/upload-artifact@v3.1.3 - if: failure() - with: - name: Static Analysis Report - path: app/build/reports/ - - pmd: - name: PMD - runs-on: ubuntu-latest - steps: - - name: Checking out repository - uses: actions/checkout@v4 - - - name: PMD Check - run: ./gradlew pmd - - - name: Upload PMD Report - uses: actions/upload-artifact@v3.1.3 - if: failure() - with: - name: PMD Report - path: app/build/reports/ diff --git a/.gitignore b/.gitignore index 3f9ffd26f..3c7ee5b81 100644 --- a/.gitignore +++ b/.gitignore @@ -43,6 +43,9 @@ build/ # Gradle cache .gradle +# Kotlin +.kotlin + # Android Studio captures folder captures/ diff --git a/build.gradle.kts b/build.gradle.kts index ef438e025..7dc8d1e88 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,13 +1,11 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - repositories { - google() - mavenCentral() - } dependencies { classpath(libs.google.oss.licenses.plugin) { exclude(group = "com.google.protobuf") } + + classpath(libs.spotless.gradle) } } @@ -30,4 +28,53 @@ plugins { alias(libs.plugins.kotlin.android) apply false alias(libs.plugins.spotbugs) apply false alias(libs.plugins.kotlinMultiplatform) apply false + alias(libs.plugins.detekt) apply true + alias(libs.plugins.spotless) apply true +} + +val detektFormatting = libs.detekt.formatting +val twitterComposeRules = libs.twitter.detekt.compose +val ktlintVersion = "1.0.1" + +subprojects { + apply { + plugin("io.gitlab.arturbosch.detekt") + plugin("com.diffplug.spotless") + } + + tasks.withType().configureEach { + config.from(rootProject.files("config/detekt/detekt.yml")) + reports.xml.required.set(true) + reports.html.required.set(true) + } + + extensions.configure { + kotlin { + target("**/*.kt") + targetExclude("**/build/**/*.kt") + ktlint(ktlintVersion).editorConfigOverride( + mapOf( + "android" to "true", + ), + ) + licenseHeaderFile(rootProject.file("spotless/copyright.kt")) + } + format("kts") { + target("**/*.kts") + targetExclude("**/build/**/*.kts") + // Look for the first line that doesn't have a block comment (assumed to be the license) + licenseHeaderFile(rootProject.file("spotless/copyright.kts"), "(^(?![\\/ ]\\*).*$)") + } + format("xml") { + target("**/*.xml") + targetExclude("**/build/**/*.xml") + // Look for the first XML tag that isn't a comment ( \ No newline at end of file