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
52 changes: 13 additions & 39 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: push

jobs:
lint:
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4
Expand All @@ -14,23 +14,10 @@ jobs:
distribution: 'adopt'
java-version: '17'
- name: "lint"
run: ./gradlew lint

ktlint:
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Set up Java"
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '17'
- name: "ktlint"
run: ./gradlew ktlintCheck
run: ./gradlew lint ktlintCheck

test:
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4
Expand All @@ -43,7 +30,7 @@ jobs:
run: ./gradlew test

check_coverage:
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4
Expand All @@ -53,23 +40,10 @@ jobs:
distribution: 'adopt'
java-version: '17'
- name: "Check if coverage is satisfied"
run: ./gradlew jacocoTestCoverageVerification

mutation_test:
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Set up Java"
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '17'
- name: "Mutation Testing"
run: ./gradlew pitest
run: ./gradlew koverVerify

api_validation:
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4
Expand All @@ -82,8 +56,8 @@ jobs:
run: ./gradlew apiCheck

assemble:
needs: [lint, ktlint, test, check_coverage, mutation_test]
runs-on: ubuntu-latest
needs: [lint, test, check_coverage]
runs-on: macos-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4
Expand All @@ -97,7 +71,7 @@ jobs:

upload_coverage:
needs: [assemble]
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4
Expand All @@ -107,10 +81,10 @@ jobs:
distribution: 'adopt'
java-version: '17'
- name: "Create coverage reports"
run: ./gradlew check jacocoTestReport
run: ./gradlew koverXmlReport
- name: "Upload coverage to codecov"
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v5.3.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./control-core/build/reports/jacoco/test/jacocoTestReport.xml
fail_ci_if_error: true
files: ./control-core/build/reports/kover/report.xml
fail_ci_if_error: true
23 changes: 9 additions & 14 deletions .github/workflows/deploy-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,41 @@ name: "deploy release"
on:
push:
tags-ignore:
- '*-SNAPSHOT'
- "*-SNAPSHOT"

jobs:
all_checks:
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Set up Java"
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '17'
distribution: "adopt"
java-version: "17"
- name: "Checks all the things"
run: ./gradlew lint ktlintCheck test jacocoTestCoverageVerification pitest apiCheck assemble
run: ./gradlew lint ktlintCheck test koverVerify apiCheck assemble

publish:
needs: [ all_checks ]
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Set up Java"
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '17'
distribution: "adopt"
java-version: "17"
- name: "Get tag and save into env"
uses: olegtarasov/get-tag@v2.1
id: tagName
- name: "Upload release"
run: ./gradlew publishAllPublicationsToMavenCentralRepository --no-daemon --no-parallel
run: ./gradlew publishAndReleaseToMavenCentral --no-daemon --no-parallel --no-configuration-cache
env:
libraryVersionTag: ${{ steps.tagName.outputs.tag }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
- name: "Publish release"
run: ./gradlew closeAndReleaseRepository --no-daemon --no-parallel
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
22 changes: 12 additions & 10 deletions .github/workflows/deploy-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,41 @@ name: "deploy snapshot"
on:
push:
tags:
- '*-SNAPSHOT'
- "*-SNAPSHOT"

jobs:
all_checks:
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Set up Java"
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '17'
distribution: "adopt"
java-version: "17"
- name: "Checks all the things"
run: ./gradlew lint ktlintCheck test jacocoTestCoverageVerification pitest apiCheck assemble
run: ./gradlew lint ktlintCheck test koverVerify apiCheck assemble

publish:
needs: [ all_checks ]
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Set up Java"
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '17'
distribution: "adopt"
java-version: "17"
- name: "Get tag and save into env"
uses: olegtarasov/get-tag@v2.1
id: tagName
- name: "Upload release"
run: ./gradlew publishAllPublicationsToMavenCentralRepository --no-daemon --no-parallel
- name: "Upload snapshot"
run: ./gradlew publishAllPublicationsToMavenCentralRepository --no-configuration-cache
env:
libraryVersionTag: ${{ steps.tagName.outputs.tag }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,4 @@ fabric.properties
# End of https://www.toptal.com/developers/gitignore/api/android,androidstudio,macos

*.salive
.java-version
.kotlin/
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .java-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
17.0
19 changes: 15 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# changelog

## `[2.0.0]` - 2025-03-16

- Update Kotlin to `2.1.10`
- Update kotlinx.coroutines to `1.10.1`
- Publish `control-core` as kotlin multiplatform library
- Create custom `@TestOnlyStub` annotation and use it instead of `@TestOnly` to support KMP
implementation

## `[1.3.0]` - 2024-11-16

- Update Kotlin to `2.0.21`
Expand Down Expand Up @@ -48,17 +56,20 @@

## `[0.11.0]` - 2020-05-30

- `CoroutineScope.createController` and `CoroutineScope.createSynchronousController` now accept a custom `ControllerStart` parameter instead of `CoroutineStart`.
- `CoroutineScope.createController` and `CoroutineScope.createSynchronousController` now accept a
custom `ControllerStart` parameter instead of `CoroutineStart`.
- Add `ManagedController`.
- `Controller.stub` is now marked as `@TestOnly`.
- binary compatibility is now checked on each `[build]` & `[publish]`.

## `[0.10.0]` - 2020-05-11

- `ControllerStub` is removed from `Controller` interface.
- `ControllerStub` is now accessible via the `Controller.stub()` extension function. once a `Controller` is stubbed via this extension function, it cannot be un-stubbed.
- `ControllerStub` is removed from `Controller` interface.
- `ControllerStub` is now accessible via the `Controller.stub()` extension function. once a
`Controller` is stubbed via this extension function, it cannot be un-stubbed.

## `[0.9.0]` - 2020-05-10

- `ControllerImplementation` now uses `MutableStateFlow` instead of `ConflatedBroadCastChannel` internally.
- `ControllerImplementation` now uses `MutableStateFlow` instead of `ConflatedBroadCastChannel`
internally.
- `Controller.state` emissions are now distinct by default (via `StateFlow`).
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ repositories {
mavenCentral()
}

dependencies {
implementation("at.florianschuster.control:control-core:$version")
kotlin {
sourceSets {
commonMain {
dependencies {
implementation("at.florianschuster.control:control-core:$version")
}
}
}
}
```

Expand All @@ -30,7 +36,10 @@ see [changelog](https://github.com/floschu/control/blob/develop/CHANGELOG.md) f

<p align="center"><img alt="flow" width="500" src=".media/udf.png"></p>

A [Controller](control-core/src/main/kotlin/at/florianschuster/control/Controller.kt) is an ui-independent class that controls the state of a view. The role of a `Controller` is to separate business-logic from view-logic. A `Controller` has no dependency to the view, so it can easily be unit tested.
A [Controller](control-core/src/main/kotlin/at/florianschuster/control/Controller.kt) is an
ui-independent class that controls the state of a view. The role of a `Controller` is to separate
business-logic from view-logic. A `Controller` has no dependency to the view, so it can easily be
unit tested.

## info & documentation

Expand All @@ -44,8 +53,9 @@ A [Controller](control-core/src/main/kotlin/at/florianschuster/control/Controlle

## examples

* [kotlin-counter](examples/kotlin-counter): most basic kotlin example. uses `Controller`.
* [android-counter](examples/android-counter): android counter example built with [jetpack compose](https://developer.android.com/jetpack/compose).
* [kotlin-counter](examples/kotlin-counter): most basic kotlin example. uses `Controller`.
* [android-counter](examples/android-counter): android counter example built
with [jetpack compose](https://developer.android.com/jetpack/compose).

## author

Expand Down
56 changes: 10 additions & 46 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,35 +1,22 @@
buildscript {
repositories {
google()
mavenCentral()
maven(url = "https://plugins.gradle.org/m2/")
}

dependencies {
classpath(libs.kotlin.gradle.plugin)
classpath(libs.pitest.gradle.plugin)
classpath(libs.binary.compat.validator)
classpath(libs.maven.publish.plugin)
classpath(libs.dokka.gradle.plugin)

// examples
classpath(libs.android.gradle.plugin)
classpath(libs.kotlin.serialization)
}
}
import kotlinx.validation.ExperimentalBCVApi

plugins {
jacoco
alias(libs.plugins.binary.compatibility.validator)
alias(libs.plugins.ktlint)
alias(libs.plugins.kover)
`maven-publish`
signing
alias(libs.plugins.kotlin.multiplatform) apply false
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.vanniktech.maven.publish) apply false
}

// ---- api-validation --- //

apply(plugin = "binary-compatibility-validator")

configure<kotlinx.validation.ApiValidationExtension> {
apiValidation {
@OptIn(ExperimentalBCVApi::class)
klib { enabled = true }
ignoredProjects.addAll(
listOf(
"kotlin-counter",
Expand All @@ -39,26 +26,3 @@ configure<kotlinx.validation.ApiValidationExtension> {
}

// ---- end api-validation --- //

// ---- jacoco --- //

subprojects {
configurations.all {
resolutionStrategy {
eachDependency {
if (requested.group == "org.jacoco") {
useVersion("0.8.7")
}
}
}
}
}

// ---- end jacoco --- //

allprojects {
repositories {
google()
mavenCentral()
}
}
Loading