Skip to content

Commit

Permalink
Detekt (#18)
Browse files Browse the repository at this point in the history
# Add Detekt

Fixes #6

- Adds Detekt in the project
- Configures github action on pull requests
- Add pre-commit detekt git hook
- Add internal guide to setup detekt plugin locally and pre-commit hook
installation

## ⚙️ Release Notes 
*Add a bullet point list summary of the feature and possible migration
guides if this is a breaking change so this section can be added to the
release notes.*
*Include code snippets that provide examples of the feature implemented
or links to the documentation if it appends or changes the public
interface.*


## 📚 Documentation
*Please ensure that you properly document any additions in conformance
to [Spezi Documentation
Guide](https://github.com/StanfordSpezi/.github/blob/main/DOCUMENTATIONGUIDE.md).*
*You can use this section to describe your solution, but we encourage
contributors to document your reasoning and changes using in-line
documentation.*


## ✅ Testing
*Please ensure that the PR meets the testing requirements set by CodeCov
and that new functionality is appropriately tested.*
*This section describes important information about the tests and why
some elements might not be testable.*


## 📝 Code of Conduct & Contributing Guidelines 

By submitting creating this pull request, you agree to follow our [Code
of
Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md):
- [ ] I agree to follow the [Code of
Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md).
  • Loading branch information
eldcn authored Jun 2, 2024
1 parent b8db3d1 commit 742b7f9
Show file tree
Hide file tree
Showing 104 changed files with 1,276 additions and 284 deletions.
102 changes: 0 additions & 102 deletions .github/workflows/android.yml

This file was deleted.

60 changes: 60 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Pull Request

on:
pull_request:
branches: [ "main" ]

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

jobs:
detekt:
name: Detekt review
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/[email protected]
with:
fetch-depth: 1
ref: ${{ github.head_ref }}
- name: Detekt PR Check
uses: alaegin/[email protected]
with:
reviewdog_reporter: github-pr-check
github_token: ${{ secrets.github_token }}
fail_on_error: true
detekt_config: internal/detekt-config.yml

buildtestanalyze:
name: Build, test and analyze
runs-on: ubuntu-latest
timeout-minutes: 120
permissions: # needed for CodeQL steps
security-events: write
packages: read
actions: read
contents: read

steps:
- name: Checkout code
uses: actions/[email protected]
- name: Initialize CodeQL # CodeQL init should happen before project build!
uses: github/codeql-action/init@v3
with:
languages: java-kotlin
build-mode: manual
- name: Set up JDK 17
uses: actions/[email protected]
with:
distribution: 'temurin'
java-version: '17'
cache: gradle
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Build and test
run: ./gradlew build
- name: Perform CodeQL Analysis # CodeQL analysis needs project build!
uses: github/codeql-action/analyze@v3
with:
category: "/language:java-kotlin"
49 changes: 49 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Merge

on:
push:
branches: [ "main" ]

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

jobs:
buildtestanalyze:
uses: ./.github/workflows/build-and-test.yml
secrets: inherit

uploadartifacts:
name: Archive production artifacts
runs-on: ubuntu-latest
needs: buildtestanalyze
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: app
path: app/build/outputs/apk/

dokka:
runs-on: ubuntu-latest
needs: buildtestanalyze
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Set up JDK 17
uses: actions/[email protected]
with:
distribution: 'temurin'
java-version: '17'
cache: gradle
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Run Dokka with Gradle
run: ./gradlew dokkaHtmlMultiModule
- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: build/dokka/htmlMultiModule
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ dependencies {
implementation(libs.hilt.navigation.compose)

implementation(project(":core:bluetooth"))
}
}

This file was deleted.

4 changes: 2 additions & 2 deletions app/src/main/kotlin/edu/stanford/spezi/app/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class MainActivity : ComponentActivity() {
super.onCreate(savedInstanceState)
setContent {
SpeziTheme {
BluetoothScreen()
BluetoothScreen()
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ class MainApplication : Application() {

SpeziLogger.setLoggingEnabled(enabled = BuildConfig.DEBUG)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ class BluetoothViewModel @Inject internal constructor(
object EnableBluetooth : Event
data class RequestPermissions(val permissions: List<String>) : Event
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ class BluetoothUiStateMapper @Inject constructor() {
}

private fun format(value: Number?): String = String.format(Locale.US, "%.2f", value)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ data class DeviceUiModel(
val address: String,
val measurementsCount: Int,
val summary: String,
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ private fun AdditionalInfo(uiState: BluetoothUiState) {
Text(text = text)
}


@Composable
fun DeviceComposable(device: DeviceUiModel) {
ElevatedCard(modifier = Modifier.fillMaxWidth()) {
Expand Down Expand Up @@ -102,4 +101,4 @@ private fun BluetoothEvents(events: Flow<BluetoothViewModel.Event>) {
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,4 @@ class BluetoothViewModelTest {
uiStateMapper = uiStateMapper
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ class BluetoothUiStateMapperTest {
const val WEIGHT = 4.56
const val ADDRESS = "some device address"
}
}
}
2 changes: 1 addition & 1 deletion build-logic/convention/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ gradlePlugin {
conventionPlugin(id = "hilt", className = "HiltConventionPlugin")
conventionPlugin(id = "library", className = "SpeziLibraryConventionPlugin")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ internal fun DependencyHandler.debugImplementation(dependency: Any) {

internal fun DependencyHandler.androidTestImplementation(dependency: Any) {
add("androidTestImplementation", dependency)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ internal fun Project.commonExtensions(configBlock: CommonExtension<*,*,*,*,*,*>.
isLibrary() -> extension<LibraryExtension>(configBlock)
else -> error("commonExtensions was called before setting the module type plugin")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ enum class PluginId(val id: String) {
HILT(id = "com.google.dagger.hilt.android"),
KSP(id = "com.google.devtools.ksp"),
COMPOSE_COMPILER("org.jetbrains.kotlin.plugin.compose")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ class HiltConventionPlugin : Plugin<Project> {
enableAggregatingTask = true
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ abstract class SpeziAbstractConfigPlugin(private val modulePlugin: PluginId) : P
testImplementation(project(":core:testing"))
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package edu.stanford.spezi.build.logic.convention.plugins

import edu.stanford.spezi.build.logic.convention.model.PluginId

class SpeziApplicationConventionPlugin : SpeziAbstractConfigPlugin(modulePlugin = PluginId.ANDROID_APPLICATION)
class SpeziApplicationConventionPlugin : SpeziAbstractConfigPlugin(modulePlugin = PluginId.ANDROID_APPLICATION)
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ class SpeziBaseConfigConventionPlugin : Plugin<Project> {
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ class SpeziComposeConventionPlugin : Plugin<Project> {
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package edu.stanford.spezi.build.logic.convention.plugins

import edu.stanford.spezi.build.logic.convention.model.PluginId

class SpeziLibraryConventionPlugin : SpeziAbstractConfigPlugin(modulePlugin = PluginId.ANDROID_LIBRARY)
class SpeziLibraryConventionPlugin : SpeziAbstractConfigPlugin(modulePlugin = PluginId.ANDROID_LIBRARY)
2 changes: 1 addition & 1 deletion build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ dependencyResolutionManagement {
}

rootProject.name = "build-logic"
include(":convention")
include(":convention")
Loading

0 comments on commit 742b7f9

Please sign in to comment.