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
38 changes: 22 additions & 16 deletions .github/workflows/kotlin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ jobs:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Check with Gradle
- name: Lint via gradle
uses: ./.github/actions/gradle-task
with:
task: lint
Expand All @@ -187,7 +187,7 @@ jobs:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Check with Gradle
- name: allTests via gradle
uses: ./.github/actions/gradle-task
with:
task: |
Expand Down Expand Up @@ -228,18 +228,24 @@ jobs:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Check with Gradle
- name: jvmTest via Gradle
uses: ./.github/actions/gradle-task
with:
task: jvmTest --continue -Pworkflow.runtime=drainExclusive
restore-cache-key: main-build-artifacts

- name: test via Gradle
uses: ./.github/actions/gradle-task
with:
task: test --continue -Pworkflow.runtime=drainExclusive
restore-cache-key: main-build-artifacts

# Report as GitHub Pull Request Check.
- name: Publish Test Report
uses: mikepenz/action-junit-report@db71d41eb79864e25ab0337e395c352e84523afe # v4
if: always() # always run even if the previous step fails
with:
report_paths: '**/build/test-results/jvmTest/TEST-*.xml'
report_paths: '**/build/test-results/*[tT]est/TEST-*.xml'

jvm-conflate-runtime-test:
name: CSR JVM Tests
Expand All @@ -260,7 +266,7 @@ jobs:
uses: mikepenz/action-junit-report@db71d41eb79864e25ab0337e395c352e84523afe # v4
if: always() # always run even if the previous step fails
with:
report_paths: '**/build/test-results/jvmTest/TEST-*.xml'
report_paths: '**/build/test-results/*[tT]est/TEST-*.xml'

jvm-stateChange-runtime-test:
name: SCO JVM Tests
Expand All @@ -281,7 +287,7 @@ jobs:
uses: mikepenz/action-junit-report@db71d41eb79864e25ab0337e395c352e84523afe # v4
if: always() # always run even if the previous step fails
with:
report_paths: '**/build/test-results/jvmTest/TEST-*.xml'
report_paths: '**/build/test-results/*[tT]est/TEST-*.xml'

jvm-stable-handlers-test:
name: SEH JVM Tests
Expand All @@ -302,7 +308,7 @@ jobs:
uses: mikepenz/action-junit-report@db71d41eb79864e25ab0337e395c352e84523afe # v4
if: always() # always run even if the previous step fails
with:
report_paths: '**/build/test-results/jvmTest/TEST-*.xml'
report_paths: '**/build/test-results/*[tT]est/TEST-*.xml'

jvm-partial-runtime-test:
name: PTR JVM Tests
Expand All @@ -323,7 +329,7 @@ jobs:
uses: mikepenz/action-junit-report@db71d41eb79864e25ab0337e395c352e84523afe # v4
if: always() # always run even if the previous step fails
with:
report_paths: '**/build/test-results/jvmTest/TEST-*.xml'
report_paths: '**/build/test-results/*[tT]est/TEST-*.xml'

jvm-conflate-stateChange-runtime-test:
name: SCO, CSR JVM Tests
Expand All @@ -344,7 +350,7 @@ jobs:
uses: mikepenz/action-junit-report@db71d41eb79864e25ab0337e395c352e84523afe # v4
if: always() # always run even if the previous step fails
with:
report_paths: '**/build/test-results/jvmTest/TEST-*.xml'
report_paths: '**/build/test-results/*[tT]est/TEST-*.xml'

jvm-conflate-partial-runtime-test:
name: CSR, PTR JVM Tests
Expand All @@ -365,7 +371,7 @@ jobs:
uses: mikepenz/action-junit-report@db71d41eb79864e25ab0337e395c352e84523afe # v4
if: always() # always run even if the previous step fails
with:
report_paths: '**/build/test-results/jvmTest/TEST-*.xml'
report_paths: '**/build/test-results/*[tT]est/TEST-*.xml'

jvm-conflate-drainExclusive-runtime-test:
name: CSR, DEA JVM Tests
Expand All @@ -386,7 +392,7 @@ jobs:
uses: mikepenz/action-junit-report@db71d41eb79864e25ab0337e395c352e84523afe # v4
if: always() # always run even if the previous step fails
with:
report_paths: '**/build/test-results/jvmTest/TEST-*.xml'
report_paths: '**/build/test-results/*[tT]est/TEST-*.xml'

jvm-stateChange-drainExclusive-runtime-test:
name: SCO, DEA JVM Tests
Expand All @@ -407,7 +413,7 @@ jobs:
uses: mikepenz/action-junit-report@db71d41eb79864e25ab0337e395c352e84523afe # v4
if: always() # always run even if the previous step fails
with:
report_paths: '**/build/test-results/jvmTest/TEST-*.xml'
report_paths: '**/build/test-results/*[tT]est/TEST-*.xml'

jvm-partial-drainExclusive-runtime-test:
name: PTR, DEA JVM Tests
Expand All @@ -428,7 +434,7 @@ jobs:
uses: mikepenz/action-junit-report@db71d41eb79864e25ab0337e395c352e84523afe # v4
if: always() # always run even if the previous step fails
with:
report_paths: '**/build/test-results/jvmTest/TEST-*.xml'
report_paths: '**/build/test-results/*[tT]est/TEST-*.xml'

jvm-conflate-stateChange-drainExclusive-runtime-test:
name: SCO, CSR, DEA JVM Tests
Expand All @@ -449,7 +455,7 @@ jobs:
uses: mikepenz/action-junit-report@db71d41eb79864e25ab0337e395c352e84523afe # v4
if: always() # always run even if the previous step fails
with:
report_paths: '**/build/test-results/jvmTest/TEST-*.xml'
report_paths: '**/build/test-results/*[tT]est/TEST-*.xml'

jvm-conflate-partial-drainExclusive-runtime-test:
name: CSR, PTR, DEA JVM Tests
Expand All @@ -470,7 +476,7 @@ jobs:
uses: mikepenz/action-junit-report@db71d41eb79864e25ab0337e395c352e84523afe # v4
if: always() # always run even if the previous step fails
with:
report_paths: '**/build/test-results/jvmTest/TEST-*.xml'
report_paths: '**/build/test-results/*[tT]est/TEST-*.xml'

jvm-all-runtime-test:
name: ALL Optimizations JVM Tests
Expand All @@ -491,7 +497,7 @@ jobs:
uses: mikepenz/action-junit-report@db71d41eb79864e25ab0337e395c352e84523afe # v4
if: always() # always run even if the previous step fails
with:
report_paths: '**/build/test-results/jvmTest/TEST-*.xml'
report_paths: '**/build/test-results/*[tT]est/TEST-*.xml'

ios-tests:
name: iOS Tests
Expand Down
20 changes: 10 additions & 10 deletions artifacts.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
[
{
"gradlePath": ":trace-encoder",
"group": "com.squareup.workflow1",
"artifactId": "trace-encoder",
"description": "Trace Encoder",
"packaging": "jar",
"javaVersion": 8,
"publicationName": "maven"
},
{
"gradlePath": ":workflow-core",
"group": "com.squareup.workflow1",
Expand Down Expand Up @@ -148,7 +139,16 @@
"group": "com.squareup.workflow1",
"artifactId": "workflow-tracing",
"description": "Workflow Tracing",
"packaging": "jar",
"packaging": "aar",
"javaVersion": 8,
"publicationName": "maven"
},
{
"gradlePath": ":workflow-tracing-papa",
"group": "com.squareup.workflow1",
"artifactId": "workflow-tracing-papa",
"description": "Workflow Tracing Papa",
"packaging": "aar",
"javaVersion": 8,
"publicationName": "maven"
},
Expand Down
3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ androidx-activity = "1.8.2"
androidx-appcompat = "1.7.0"
androidx-benchmark = "1.3.3"
androidx-cardview = "1.0.0"
androidx-collection = "1.5.0"
# see https://developer.android.com/jetpack/compose/bom/bom-mapping
androidx-compose-bom = "2025.03.01"
androidx-constraintlayout = "2.1.4"
Expand Down Expand Up @@ -127,6 +128,8 @@ androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "a

androidx-cardview = { module = "androidx.cardview:cardview", version.ref = "androidx-cardview" }

androidx-collection = { module = "androidx.collection:collection", version.ref = "androidx-collection" }

androidx-compose-bom = { module = "androidx.compose:compose-bom", version.ref = "androidx-compose-bom" }

androidx-compose-foundation-layout = { module = "androidx.compose.foundation:foundation-layout" }
Expand Down
1 change: 0 additions & 1 deletion samples/dungeon/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ dependencies {
implementation(project(":samples:dungeon:common"))
implementation(project(":samples:dungeon:timemachine"))
implementation(project(":samples:dungeon:timemachine-shakeable"))
implementation(project(":workflow-tracing"))
implementation(project(":workflow-ui:core-android"))
implementation(project(":workflow-ui:core-common"))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class Component(context: AppCompatActivity) {

val timeMachineModelFactory = TimeMachineModel.Factory(
context,
timeMachineWorkflow,
traceFilesDir = context.filesDir
timeMachineWorkflow
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,30 @@ import androidx.savedstate.SavedStateRegistryOwner
import com.squareup.workflow1.WorkflowExperimentalRuntime
import com.squareup.workflow1.android.renderWorkflowIn
import com.squareup.workflow1.config.AndroidRuntimeConfigTools
import com.squareup.workflow1.diagnostic.tracing.TracingWorkflowInterceptor
import com.squareup.workflow1.ui.Screen
import kotlinx.coroutines.flow.StateFlow
import java.io.File
import kotlin.time.ExperimentalTime

class TimeMachineModel(
private val savedState: SavedStateHandle,
private val workflow: TimeMachineAppWorkflow,
private val traceFilesDir: File
) : ViewModel() {
@OptIn(ExperimentalTime::class, WorkflowExperimentalRuntime::class)
val renderings: StateFlow<Screen> by lazy {
val traceFile = traceFilesDir.resolve("workflow-trace-dungeon.json")

renderWorkflowIn(
workflow = workflow,
prop = "simple_maze.txt",
scope = viewModelScope,
savedStateHandle = savedState,
interceptors = listOf(TracingWorkflowInterceptor(traceFile)),
interceptors = emptyList(),
runtimeConfig = AndroidRuntimeConfigTools.getAppWorkflowRuntimeConfig()
)
}

class Factory(
owner: SavedStateRegistryOwner,
private val workflow: TimeMachineAppWorkflow,
private val traceFilesDir: File
) : AbstractSavedStateViewModelFactory(owner, null) {
override fun <T : ViewModel> create(
key: String,
Expand All @@ -45,7 +40,7 @@ class TimeMachineModel(
): T {
if (modelClass == TimeMachineModel::class.java) {
@Suppress("UNCHECKED_CAST")
return TimeMachineModel(handle, workflow, traceFilesDir) as T
return TimeMachineModel(handle, workflow) as T
}

throw IllegalArgumentException("Unknown ViewModel type $modelClass")
Expand Down
1 change: 0 additions & 1 deletion samples/tictactoe/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ dependencies {

implementation(project(":samples:containers:android"))
implementation(project(":samples:tictactoe:common"))
implementation(project(":workflow-tracing"))
implementation(project(":workflow-ui:core-android"))
implementation(project(":workflow-ui:core-common"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class TicTacToeComponent : ViewModel() {
private val ticTacToeWorkflow = TicTacToeWorkflow(authWorkflow(), gameWorkflow())

fun ticTacToeModelFactory(owner: AppCompatActivity): TicTacToeModel.Factory =
TicTacToeModel.Factory(owner, ticTacToeWorkflow, traceFilesDir = owner.filesDir)
TicTacToeModel.Factory(owner, ticTacToeWorkflow)

companion object {
init {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,23 @@ import com.squareup.sample.mainworkflow.TicTacToeWorkflow
import com.squareup.workflow1.WorkflowExperimentalRuntime
import com.squareup.workflow1.android.renderWorkflowIn
import com.squareup.workflow1.config.AndroidRuntimeConfigTools
import com.squareup.workflow1.diagnostic.tracing.TracingWorkflowInterceptor
import com.squareup.workflow1.ui.Screen
import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.StateFlow
import java.io.File

class TicTacToeModel(
private val savedState: SavedStateHandle,
private val workflow: TicTacToeWorkflow,
private val traceFilesDir: File
) : ViewModel() {
private val running = Job()

val renderings: StateFlow<Screen> by lazy {
val traceFile = traceFilesDir.resolve("workflow-trace-tictactoe.json")

renderWorkflowIn(
workflow = workflow,
scope = viewModelScope,
savedStateHandle = savedState,
interceptors = listOf(TracingWorkflowInterceptor(traceFile)),
interceptors = emptyList(),
runtimeConfig = AndroidRuntimeConfigTools.getAppWorkflowRuntimeConfig()
) {
running.complete()
Expand All @@ -43,7 +39,6 @@ class TicTacToeModel(
class Factory(
owner: SavedStateRegistryOwner,
private val workflow: TicTacToeWorkflow,
private val traceFilesDir: File
) : AbstractSavedStateViewModelFactory(owner, null) {
override fun <T : ViewModel> create(
key: String,
Expand All @@ -52,7 +47,7 @@ class TicTacToeModel(
): T {
if (modelClass == TicTacToeModel::class.java) {
@Suppress("UNCHECKED_CAST")
return TicTacToeModel(handle, workflow, traceFilesDir) as T
return TicTacToeModel(handle, workflow) as T
}

throw IllegalArgumentException("Unknown ViewModel type $modelClass")
Expand Down
1 change: 0 additions & 1 deletion samples/todo-android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ dependencies {
implementation(project(":samples:containers:android"))
implementation(project(":samples:containers:common"))
implementation(project(":workflow-core"))
implementation(project(":workflow-tracing"))
implementation(project(":workflow-ui:core-android"))
implementation(project(":workflow-ui:core-common"))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ import com.squareup.sample.container.overviewdetail.OverviewDetailContainer
import com.squareup.workflow1.WorkflowExperimentalRuntime
import com.squareup.workflow1.android.renderWorkflowIn
import com.squareup.workflow1.config.AndroidRuntimeConfigTools
import com.squareup.workflow1.diagnostic.tracing.TracingWorkflowInterceptor
import com.squareup.workflow1.ui.Screen
import com.squareup.workflow1.ui.ViewRegistry
import com.squareup.workflow1.ui.withRegistry
import com.squareup.workflow1.ui.workflowContentView
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.map
import java.io.File

class ToDoActivity : AppCompatActivity() {

Expand All @@ -31,7 +29,7 @@ class ToDoActivity : AppCompatActivity() {
workflowContentView
.take(
lifecycle,
model.ensureWorkflow(traceFilesDir = filesDir).map { it.withRegistry(viewRegistry) }
model.ensureWorkflow().map { it.withRegistry(viewRegistry) }
)
}

Expand All @@ -43,15 +41,14 @@ class ToDoActivity : AppCompatActivity() {
class ToDoModel(private val savedState: SavedStateHandle) : ViewModel() {
private var renderings: StateFlow<Screen>? = null

fun ensureWorkflow(traceFilesDir: File): StateFlow<Screen> {
fun ensureWorkflow(): StateFlow<Screen> {
if (renderings == null) {
val traceFile = traceFilesDir.resolve("workflow-trace-todo.json")

renderings = renderWorkflowIn(
workflow = TodoListsAppWorkflow,
scope = viewModelScope,
savedStateHandle = savedState,
interceptors = listOf(TracingWorkflowInterceptor(traceFile)),
interceptors = emptyList(),
runtimeConfig = AndroidRuntimeConfigTools.getAppWorkflowRuntimeConfig()
)
}
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ include(
":samples:tictactoe:app",
":samples:tictactoe:common",
":samples:todo-android:app",
":trace-encoder",
":workflow-config:config-android",
":workflow-config:config-jvm",
":workflow-core",
Expand All @@ -68,6 +67,7 @@ include(
":workflow-rx2",
":workflow-testing",
":workflow-tracing",
":workflow-tracing-papa",
":workflow-trace-viewer",
":workflow-ui:compose",
":workflow-ui:compose-tooling",
Expand Down
Loading
Loading