Skip to content

Commit 629bbe5

Browse files
Upstream WorkflowRuntimeMonitor; Change RuntimeUpdates API
Upstream from our internal project; including with papa tracing. Adds a bunch of tests for verification of behaviour.
1 parent 610b92a commit 629bbe5

File tree

51 files changed

+4117
-1331
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+4117
-1331
lines changed

.github/workflows/kotlin.yml

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ jobs:
172172
- name: Checkout
173173
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
174174

175-
- name: Check with Gradle
175+
- name: Lint via gradle
176176
uses: ./.github/actions/gradle-task
177177
with:
178178
task: lint
@@ -187,7 +187,7 @@ jobs:
187187
- name: Checkout
188188
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
189189

190-
- name: Check with Gradle
190+
- name: allTests via gradle
191191
uses: ./.github/actions/gradle-task
192192
with:
193193
task: |
@@ -228,18 +228,24 @@ jobs:
228228
- name: Checkout
229229
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
230230

231-
- name: Check with Gradle
231+
- name: jvmTest via Gradle
232232
uses: ./.github/actions/gradle-task
233233
with:
234234
task: jvmTest --continue -Pworkflow.runtime=drainExclusive
235235
restore-cache-key: main-build-artifacts
236236

237+
- name: test via Gradle
238+
uses: ./.github/actions/gradle-task
239+
with:
240+
task: test --continue -Pworkflow.runtime=drainExclusive
241+
restore-cache-key: main-build-artifacts
242+
237243
# Report as GitHub Pull Request Check.
238244
- name: Publish Test Report
239245
uses: mikepenz/action-junit-report@db71d41eb79864e25ab0337e395c352e84523afe # v4
240246
if: always() # always run even if the previous step fails
241247
with:
242-
report_paths: '**/build/test-results/jvmTest/TEST-*.xml'
248+
report_paths: '**/build/test-results/*[tT]est/TEST-*.xml'
243249

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

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

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

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

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

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

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

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

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

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

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

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

496502
ios-tests:
497503
name: iOS Tests

artifacts.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,16 @@
139139
"group": "com.squareup.workflow1",
140140
"artifactId": "workflow-tracing",
141141
"description": "Workflow Tracing",
142-
"packaging": "jar",
142+
"packaging": "aar",
143+
"javaVersion": 8,
144+
"publicationName": "maven"
145+
},
146+
{
147+
"gradlePath": ":workflow-tracing-papa",
148+
"group": "com.squareup.workflow1",
149+
"artifactId": "workflow-tracing-papa",
150+
"description": "Workflow Tracing Papa",
151+
"packaging": "aar",
143152
"javaVersion": 8,
144153
"publicationName": "maven"
145154
},
@@ -206,4 +215,4 @@
206215
"javaVersion": 8,
207216
"publicationName": "maven"
208217
}
209-
]
218+
]

gradle/libs.versions.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ androidx-activity = "1.8.2"
1313
androidx-appcompat = "1.7.0"
1414
androidx-benchmark = "1.3.3"
1515
androidx-cardview = "1.0.0"
16+
androidx-collection = "1.5.0"
1617
# see https://developer.android.com/jetpack/compose/bom/bom-mapping
1718
androidx-compose-bom = "2025.03.01"
1819
androidx-constraintlayout = "2.1.4"
@@ -127,6 +128,8 @@ androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "a
127128

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

131+
androidx-collection = { module = "androidx.collection:collection", version.ref = "androidx-collection" }
132+
130133
androidx-compose-bom = { module = "androidx.compose:compose-bom", version.ref = "androidx-compose-bom" }
131134

132135
androidx-compose-foundation-layout = { module = "androidx.compose.foundation:foundation-layout" }

samples/dungeon/app/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ dependencies {
4747
implementation(project(":samples:dungeon:common"))
4848
implementation(project(":samples:dungeon:timemachine"))
4949
implementation(project(":samples:dungeon:timemachine-shakeable"))
50-
implementation(project(":workflow-tracing"))
5150
implementation(project(":workflow-ui:core-android"))
5251
implementation(project(":workflow-ui:core-common"))
5352

samples/dungeon/app/src/main/java/com/squareup/sample/dungeon/Component.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ class Component(context: AppCompatActivity) {
5656

5757
val timeMachineModelFactory = TimeMachineModel.Factory(
5858
context,
59-
timeMachineWorkflow,
60-
traceFilesDir = context.filesDir
59+
timeMachineWorkflow
6160
)
6261
}

samples/dungeon/app/src/main/java/com/squareup/sample/dungeon/TimeMachineModel.kt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,30 @@ import androidx.savedstate.SavedStateRegistryOwner
88
import com.squareup.workflow1.WorkflowExperimentalRuntime
99
import com.squareup.workflow1.android.renderWorkflowIn
1010
import com.squareup.workflow1.config.AndroidRuntimeConfigTools
11-
import com.squareup.workflow1.diagnostic.tracing.TracingWorkflowInterceptor
1211
import com.squareup.workflow1.ui.Screen
1312
import kotlinx.coroutines.flow.StateFlow
14-
import java.io.File
1513
import kotlin.time.ExperimentalTime
1614

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

2622
renderWorkflowIn(
2723
workflow = workflow,
2824
prop = "simple_maze.txt",
2925
scope = viewModelScope,
3026
savedStateHandle = savedState,
31-
interceptors = listOf(TracingWorkflowInterceptor(traceFile)),
27+
interceptors = emptyList(),
3228
runtimeConfig = AndroidRuntimeConfigTools.getAppWorkflowRuntimeConfig()
3329
)
3430
}
3531

3632
class Factory(
3733
owner: SavedStateRegistryOwner,
3834
private val workflow: TimeMachineAppWorkflow,
39-
private val traceFilesDir: File
4035
) : AbstractSavedStateViewModelFactory(owner, null) {
4136
override fun <T : ViewModel> create(
4237
key: String,
@@ -45,7 +40,7 @@ class TimeMachineModel(
4540
): T {
4641
if (modelClass == TimeMachineModel::class.java) {
4742
@Suppress("UNCHECKED_CAST")
48-
return TimeMachineModel(handle, workflow, traceFilesDir) as T
43+
return TimeMachineModel(handle, workflow) as T
4944
}
5045

5146
throw IllegalArgumentException("Unknown ViewModel type $modelClass")

samples/tictactoe/app/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ dependencies {
3939

4040
implementation(project(":samples:containers:android"))
4141
implementation(project(":samples:tictactoe:common"))
42-
implementation(project(":workflow-tracing"))
4342
implementation(project(":workflow-ui:core-android"))
4443
implementation(project(":workflow-ui:core-common"))
4544
}

samples/tictactoe/app/src/main/java/com/squareup/sample/mainactivity/TicTacToeComponent.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class TicTacToeComponent : ViewModel() {
5555
private val ticTacToeWorkflow = TicTacToeWorkflow(authWorkflow(), gameWorkflow())
5656

5757
fun ticTacToeModelFactory(owner: AppCompatActivity): TicTacToeModel.Factory =
58-
TicTacToeModel.Factory(owner, ticTacToeWorkflow, traceFilesDir = owner.filesDir)
58+
TicTacToeModel.Factory(owner, ticTacToeWorkflow)
5959

6060
companion object {
6161
init {

samples/tictactoe/app/src/main/java/com/squareup/sample/mainactivity/TicTacToeModel.kt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,23 @@ import com.squareup.sample.mainworkflow.TicTacToeWorkflow
1111
import com.squareup.workflow1.WorkflowExperimentalRuntime
1212
import com.squareup.workflow1.android.renderWorkflowIn
1313
import com.squareup.workflow1.config.AndroidRuntimeConfigTools
14-
import com.squareup.workflow1.diagnostic.tracing.TracingWorkflowInterceptor
1514
import com.squareup.workflow1.ui.Screen
1615
import kotlinx.coroutines.Job
1716
import kotlinx.coroutines.flow.StateFlow
18-
import java.io.File
1917

2018
class TicTacToeModel(
2119
private val savedState: SavedStateHandle,
2220
private val workflow: TicTacToeWorkflow,
23-
private val traceFilesDir: File
2421
) : ViewModel() {
2522
private val running = Job()
2623

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

3026
renderWorkflowIn(
3127
workflow = workflow,
3228
scope = viewModelScope,
3329
savedStateHandle = savedState,
34-
interceptors = listOf(TracingWorkflowInterceptor(traceFile)),
30+
interceptors = emptyList(),
3531
runtimeConfig = AndroidRuntimeConfigTools.getAppWorkflowRuntimeConfig()
3632
) {
3733
running.complete()
@@ -43,7 +39,6 @@ class TicTacToeModel(
4339
class Factory(
4440
owner: SavedStateRegistryOwner,
4541
private val workflow: TicTacToeWorkflow,
46-
private val traceFilesDir: File
4742
) : AbstractSavedStateViewModelFactory(owner, null) {
4843
override fun <T : ViewModel> create(
4944
key: String,
@@ -52,7 +47,7 @@ class TicTacToeModel(
5247
): T {
5348
if (modelClass == TicTacToeModel::class.java) {
5449
@Suppress("UNCHECKED_CAST")
55-
return TicTacToeModel(handle, workflow, traceFilesDir) as T
50+
return TicTacToeModel(handle, workflow) as T
5651
}
5752

5853
throw IllegalArgumentException("Unknown ViewModel type $modelClass")

samples/todo-android/app/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ dependencies {
2929
implementation(project(":samples:containers:android"))
3030
implementation(project(":samples:containers:common"))
3131
implementation(project(":workflow-core"))
32-
implementation(project(":workflow-tracing"))
3332
implementation(project(":workflow-ui:core-android"))
3433
implementation(project(":workflow-ui:core-common"))
3534

0 commit comments

Comments
 (0)