Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
46 changes: 46 additions & 0 deletions .github/workflows/release_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This is a basic workflow to help you get started with Actions

name: Release MVI Test

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
tags:
- 'test/[0-9]+.[0-9]+.[0-9]+'

# 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 "build"
build:
# The type of runner that the job will run on
runs-on: macos-latest

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

- name: Set up JDK 21
uses: actions/setup-java@v2
with:
java-version: '21'
distribution: 'temurin'

- name: Grant Permission to Execute Gradle
run: chmod +x gradlew

- name: Build with Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: build

- name: Publish Library
run: |
echo "Publishing library🚀"
./gradlew :mvi-test:publishAndReleaseToMavenCentral --no-configuration-cache
echo "Published✅"
env:
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_PASSWORD }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Here are the current available mvi modules versions:
| mvi | [![Maven Central](https://img.shields.io/maven-central/v/com.adidas.mvi/mvi)](https://mvnrepository.com/artifact/com.adidas.mvi/mvi) |
| mvi-compose | [![Maven Central](https://img.shields.io/maven-central/v/com.adidas.mvi/mvi-compose)](https://mvnrepository.com/artifact/com.adidas.mvi/mvi-compose) |
| mvi-kotest | [![Maven Central](https://img.shields.io/maven-central/v/com.adidas.mvi/mvi-kotest)](https://mvnrepository.com/artifact/com.adidas.mvi/mvi-kotest) |
| mvi-test | [![Maven Central](https://img.shields.io/maven-central/v/com.adidas.mvi/mvi-test)](https://mvnrepository.com/artifact/com.adidas.mvi/mvi-test) |

## Features

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import com.adidas.mvi.Logger
*
* You can access list of all logged entries from [loggedTranformations] and [loggedIntents].
*/
@Deprecated("Use the one from mvi-test package",
replaceWith = ReplaceWith(
"com.adidas.mvi.test.TestMviLogger",
"com.adidas.mvi.test.TestMviLogger"
))
public class TestMviLogger : Logger {
public val loggedTranformations: MutableList<LoggedTranformation> = ArrayList<LoggedTranformation>()
public val loggedIntents: MutableList<LoggedIntent> = ArrayList<LoggedIntent>()
Expand Down
1 change: 1 addition & 0 deletions mvi-sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ dependencies {

implementation(libs.mvi)
implementation(project(":mvi-compose"))
implementation(project(":mvi-test"))

implementation(libs.koinCore)
implementation(libs.koinAndroid)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.adidas.mvi.sample.login.viewmodel

import com.adidas.mvi.kotest.GivenViewModel
import com.adidas.mvi.kotest.TestMviLogger
import com.adidas.mvi.test.TestMviLogger
import io.kotest.core.spec.style.BehaviorSpec
import io.kotest.matchers.shouldBe
import kotlinx.coroutines.ExperimentalCoroutinesApi
Expand Down
1 change: 1 addition & 0 deletions mvi-test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
19 changes: 19 additions & 0 deletions mvi-test/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import org.jlleitschuh.gradle.ktlint.KtlintExtension

plugins {
kotlin("jvm") version libs.versions.kotlin.get()
alias(libs.plugins.ktlint)
alias(libs.plugins.mavenPublish)
}

kotlin {
explicitApi()
}

configure<KtlintExtension> {
version.set(libs.versions.ktlint.lib.get())
}

dependencies {
implementation(libs.mvi)
}
58 changes: 58 additions & 0 deletions mvi-test/src/main/kotlin/com/adidas/mvi/test/TestMviLogger.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package com.adidas.mvi.test

import com.adidas.mvi.Loggable
import com.adidas.mvi.Logger

/**
* A fake implementation of [Logger] that remembers all logged entries, for use in tests.
*
* You can access list of all logged entries from [loggedTranformations] and [loggedIntents].
*/
public class TestMviLogger : Logger {
public val loggedTranformations: MutableList<LoggedTranformation> = ArrayList<LoggedTranformation>()
public val loggedIntents: MutableList<LoggedIntent> = ArrayList<LoggedIntent>()

override fun logFailedIntent(
intent: Loggable,
throwable: Throwable,
) {
loggedIntents += LoggedIntent.Failure(intent, throwable)
}

override fun logIntent(intent: Loggable) {
loggedIntents += LoggedIntent.Success(intent)
}

override fun logFailedTransformNewState(
transform: Loggable,
state: Loggable,
throwable: Throwable,
) {
loggedTranformations += LoggedTranformation.Failure(transform, state, throwable)
}

override fun logTransformedNewState(
transform: Loggable,
previousState: Loggable,
newState: Loggable,
) {
loggedTranformations += LoggedTranformation.Success(transform, previousState, newState)
}

public sealed class LoggedIntent() {
public abstract val intent: Loggable

public data class Success(override val intent: Loggable) : LoggedIntent()

public data class Failure(override val intent: Loggable, val throwable: Throwable) : LoggedIntent()
}

public sealed class LoggedTranformation() {
public abstract val transform: Loggable
public abstract val previousState: Loggable

public data class Success(override val transform: Loggable, override val previousState: Loggable, val newState: Loggable) : LoggedTranformation()

public data class Failure(override val transform: Loggable, override val previousState: Loggable, val throwable: Throwable) : LoggedTranformation()
}
}
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ include(":mvi")
include(":mvi-compose")
include(":mvi-kotest")
include(":mvi-sample")
include(":mvi-test")
Loading