Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 45 additions & 95 deletions .github/workflows/detekt.yml
Original file line number Diff line number Diff line change
@@ -1,116 +1,66 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

# This workflow performs a static analysis of your Kotlin source code using
# Detekt.
#
# Scans are triggered:
# 1. On every push to default and protected branches
# 2. On every Pull Request targeting the default branch
# 3. On a weekly schedule
# 4. Manually, on demand, via the "workflow_dispatch" event
#
# The workflow should work with no modifications, but you might like to use a
# later version of the Detekt CLI by modifying the $DETEKT_RELEASE_TAG
# environment variable.
name: Scan with Detekt
name: Detekt Analysis

on:
# Triggers the workflow on push or pull request events but only for default and protected branches
# Triggers on push to key branches
push:
branches: [ "master" ]
branches: [ "master", "stable", "next", "feature/major-refactor-ui-changes" ]
pull_request:
branches: [ "master" ]
schedule:
branches:
- '**' # Triggers on pull requests to any branch
schedule: # Scheduled weekly scan
- cron: '35 5 * * 0'

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

env:
# Release tag associated with version of Detekt to be installed
# SARIF support (required for this workflow) was introduced in Detekt v1.15.0
DETEKT_RELEASE_TAG: v1.22.0
DETEKT_RELEASE: 1.22.0

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "scan"
scan:
name: Scan
# The type of runner that the job will run on
detekt:
name: Static Code Analysis with Detekt
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
# ✅ Step 1: Checkout Repository
- name: Check out code
uses: actions/checkout@v4

# Gets the download URL associated with the $DETEKT_RELEASE_TAG
- name: Get Detekt download URL
id: detekt_info
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api graphql --field tagName=$DETEKT_RELEASE_TAG --raw-field query='
query getReleaseAssetDownloadUrl($tagName: String!) {
repository(name: "detekt", owner: "detekt") {
release(tagName: $tagName) {
releaseAssets(name: "detekt", first: 1) {
nodes {
downloadUrl
}
}
tagCommit {
oid
}
}
}
}
' 1> gh_response.json
# ✅ Step 2: Set up Java 17
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'

DETEKT_RELEASE_SHA=$(jq --raw-output '.data.repository.release.releaseAssets' gh_response.json)
if [ $DETEKT_RELEASE_SHA != "4b1da0d5feb53d9ae9b80193ad49c5597d7c4b42" ]; then
echo "Release tag doesn't match expected commit SHA"
exit 1
fi
cat gh_response.json
DETEKT_DOWNLOAD_URL=https://github.com/detekt/detekt/releases/download/$DETEKT_RELEASE_TAG/detekt-cli-$DETEKT_RELEASE-all.jar
echo $DETEKT_DOWNLOAD_URL
echo "download_url=$DETEKT_DOWNLOAD_URL" >> $GITHUB_OUTPUT
# ✅ Step 3: Install Ruby and Bundler (Required for Fastlane)
- name: Install Ruby and Bundler
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
bundler-cache: true

# Sets up and runs the detekt cli
- name: Setup and Run Detekt
continue-on-error: true
id: detekt_setup_and_run
# ✅ Step 4: Install Fastlane Dependencies
- name: Install Fastlane dependencies
run: |
curl --request GET \
--url ${{ steps.detekt_info.outputs.download_url }} \
--silent \
--location \
--output detekt.jar
chmod a+x detekt.jar
# Performs static analysis using Detekt
java -jar "detekt.jar" --input ${{ github.workspace }} --all-rules --report sarif:${{ github.workspace }}/detekt.sarif.json
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3

# Modifies the SARIF output produced by Detekt so that absolute URIs are relative
# This is so we can easily map results onto their source files
# This can be removed once relative URI support lands in Detekt: https://git.io/JLBbA
- name: Make artifact location URIs relative
continue-on-error: true
# ✅ Step 5: Run Detekt via Fastlane
- name: Run Detekt
run: |
echo "$(
jq \
--arg github_workspace ${{ github.workspace }} \
'. | ( .runs[].results[].locations[].physicalLocation.artifactLocation.uri |= if test($github_workspace) then .[($github_workspace | length | . + 1):] else . end )' \
${{ github.workspace }}/detekt.sarif.json
)" > ${{ github.workspace }}/detekt.sarif.json
bundle exec fastlane detekt

# ✅ Step 6: Upload SARIF report for GitHub Security Code Scanning
- name: Upload SARIF report for GitHub Code Scanning
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: "app/build/reports/detekt/detekt.sarif"
category: detekt-analysis

# Uploads results to GitHub repository using the upload-sarif action
- uses: github/codeql-action/upload-sarif@v2
# ✅ Step 7: Upload Detekt Reports as Artifacts for Download
- name: Upload Detekt Reports as Artifacts
uses: actions/upload-artifact@v4
with:
# Path to SARIF file relative to the root of the repository
sarif_file: ${{ github.workspace }}/detekt.sarif.json
checkout_path: ${{ github.workspace }}
name: detekt-reports
path: |
*/build/reports/detekt/*.html
*/build/reports/detekt/*.md
*/build/reports/detekt/*.xml
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@ fastlane/.env
/app/release/baselineProfiles/0/save-unspecified-release.dm
/app/release/baselineProfiles/1/save-unspecified-release.dm
/app/release/output-metadata.json
/app/src/main/assets/.env
91 changes: 70 additions & 21 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ plugins {
id("org.jetbrains.kotlin.plugin.compose")
id("org.jetbrains.kotlin.plugin.serialization")
id("com.google.devtools.ksp")
id("androidx.navigation.safeargs.kotlin")
alias(libs.plugins.detekt.plugin)
}
android {

Expand All @@ -18,12 +20,12 @@ android {
compileSdk = 34

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

kotlinOptions {
jvmTarget = "11"
jvmTarget = "17"
}

defaultConfig {
Expand Down Expand Up @@ -95,6 +97,14 @@ android {
abortOnError = false
}


testOptions {
unitTests {
isIncludeAndroidResources = true
}
}


namespace = "net.opendasharchive.openarchive"

configurations.all {
Expand All @@ -107,9 +117,15 @@ android {

dependencies {

val composeVersion = "1.7.7"
val composeVersion = "1.7.8"
val material = "1.12.0"
val material3 = "1.3.1"
val lifecycle = "2.8.7"
val navigation = "2.8.8"
val fragment = "1.8.6"
val koin = "4.1.0-Beta5"

val coil = "3.0.4"

// Core Kotlin and Coroutines
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.1")
Expand All @@ -119,33 +135,38 @@ dependencies {
// AndroidX Libraries
implementation("androidx.appcompat:appcompat:1.7.0")
implementation("androidx.recyclerview:recyclerview:1.3.2")
implementation("androidx.viewpager2:viewpager2:1.1.0")
implementation("androidx.recyclerview:recyclerview-selection:1.1.0")
implementation("androidx.constraintlayout:constraintlayout:2.2.0")
implementation("androidx.constraintlayout:constraintlayout-compose:1.1.0")
implementation("androidx.constraintlayout:constraintlayout:2.2.1")
implementation("androidx.constraintlayout:constraintlayout-compose:1.1.1")
implementation("androidx.coordinatorlayout:coordinatorlayout:1.2.0")
implementation("androidx.core:core-splashscreen:1.0.1")

implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.8.7")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.7")
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.8.7")
implementation("androidx.navigation:navigation-fragment-ktx:2.8.6")
implementation("androidx.navigation:navigation-ui-ktx:2.8.6")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle")
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle")
implementation("androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle")
implementation("androidx.lifecycle:lifecycle-runtime-compose:$lifecycle")


implementation("androidx.preference:preference-ktx:1.2.1")
implementation("androidx.biometric:biometric:1.1.0")
implementation("androidx.work:work-runtime-ktx:2.9.1")
implementation("androidx.security:security-crypto-ktx:1.1.0-alpha06")

implementation("androidx.fragment:fragment-ktx:$fragment")
implementation("androidx.fragment:fragment-compose:$fragment")

// Compose Preferences
implementation("me.zhanghai.compose.preference:library:1.1.1")

// Material Design
implementation("com.google.android.material:material:$material")

// AndroidX SwipeRefreshLayout
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.2.0-alpha01")
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")

// Compose Libraries
implementation("androidx.activity:activity-ktx:1.9.3")
implementation("androidx.activity:activity-compose:1.9.3")
implementation("androidx.compose.material3:material3:$material3")
implementation("androidx.compose.ui:ui:$composeVersion")
Expand All @@ -154,24 +175,35 @@ dependencies {
implementation("androidx.compose.material:material-icons-extended:$composeVersion")
debugImplementation("androidx.compose.ui:ui-tooling:$composeVersion")

implementation("androidx.compose.runtime:runtime:$composeVersion")
implementation("androidx.compose.runtime:runtime-livedata:$composeVersion")

// Navigation
implementation("androidx.navigation:navigation-compose:2.8.6")
implementation("androidx.navigation:navigation-compose:$navigation")
implementation("androidx.navigation:navigation-ui-ktx:$navigation")
implementation("androidx.navigation:navigation-fragment-ktx:$navigation")
implementation("androidx.navigation:navigation-fragment-compose:$navigation")

// Preference
implementation("androidx.preference:preference-ktx:1.2.1")

// Dependency Injection
implementation("io.insert-koin:koin-core:4.1.0-Beta5")
implementation("io.insert-koin:koin-android:4.1.0-Beta5")
implementation("io.insert-koin:koin-androidx-compose:4.1.0-Beta5")
implementation("io.insert-koin:koin-core:$koin")
implementation("io.insert-koin:koin-android:$koin")
implementation("io.insert-koin:koin-androidx-compose:$koin")
implementation("io.insert-koin:koin-androidx-navigation:$koin")
implementation("io.insert-koin:koin-compose:$koin")
implementation("io.insert-koin:koin-compose-viewmodel:$koin")
implementation("io.insert-koin:koin-compose-viewmodel-navigation:$koin")

// Image Libraries
implementation("com.github.bumptech.glide:glide:4.16.0")
annotationProcessor("com.github.bumptech.glide:compiler:4.16.0")
implementation("com.github.esafirm:android-image-picker:3.0.0")
implementation("com.squareup.picasso:picasso:2.5.2")
implementation("io.coil-kt:coil-compose:2.7.0")
implementation("io.coil-kt:coil-video:2.7.0")
implementation("io.coil-kt.coil3:coil:$coil")
implementation("io.coil-kt.coil3:coil-compose:$coil")
implementation("io.coil-kt.coil3:coil-video:$coil")

// Networking and Data
// Networking
Expand Down Expand Up @@ -257,20 +289,37 @@ dependencies {

// Tests
testImplementation("junit:junit:4.13.2")
testImplementation("org.robolectric:robolectric:4.10.3")
testImplementation("org.robolectric:robolectric:4.14.1")
androidTestImplementation("androidx.test.ext:junit:1.2.1")
androidTestImplementation("androidx.test:runner:1.6.2")
testImplementation("androidx.work:work-testing:2.9.1")

// Detekt
detektPlugins(libs.detekt.formatting)
detektPlugins(libs.detekt.rules.authors)
detektPlugins(libs.detekt.rules.libraries)
detektPlugins(libs.detekt.compose)
}

configurations.all {
exclude(group = "com.google.guava", module = "listenablefuture")
}

detekt {
config.setFrom(file("$rootDir/config/detekt-config.yml"))
baseline = file("$rootDir/config/baseline.xml")
source.setFrom(
files("$rootDir/app/src")
)
buildUponDefaultConfig = true
allRules = false
autoCorrect = false
ignoreFailures = true
}

/**
testdroid {username '$bbusername'
password '$bbpassword'
deviceGroup 'gpdevices'
mode "FULL_RUN"
projectName "OASave"}**/

projectName "OASave"}**/
Loading
Loading