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
28 changes: 25 additions & 3 deletions .github/workflows/kotlin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ jobs :
- name : Check with Gradle
uses : ./.github/actions/gradle-task
with :
task : jvmTest --continue -Pworkflow.runtime=baseline-stateChange
task : jvmTest --continue -Pworkflow.runtime=stateChange
restore-cache-key : main-build-artifacts

# Report as GitHub Pull Request Check.
Expand All @@ -222,6 +222,27 @@ jobs :
with :
report_paths : '**/build/test-results/test/TEST-*.xml'

jvm-stable-handlers-test:
name: Stable Event Handlers Only Runtime JVM Tests
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

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

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

jvm-partial-runtime-test:
name: Partial Tree Rendering Only Runtime JVM Tests
runs-on: ubuntu-latest
Expand All @@ -233,7 +254,7 @@ jobs :
- name: Check with Gradle
uses: ./.github/actions/gradle-task
with:
task: jvmTest --continue -Pworkflow.runtime=baseline-partial
task: jvmTest --continue -Pworkflow.runtime=partial
restore-cache-key: main-build-artifacts

# Report as GitHub Pull Request Check.
Expand Down Expand Up @@ -391,7 +412,7 @@ jobs :
### <start-connected-check-shards>
shardNum: [ 1, 2, 3 ]
### <end-connected-check-shards>
runtime : [ conflate, baseline-stateChange, conflate-stateChange, baseline-partial, conflate-partial ]
runtime : [ conflate, stateChange, conflate-stateChange, partial, conflate-partial, stable ]
steps :
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Expand Down Expand Up @@ -421,6 +442,7 @@ jobs :
- js-tests
- jvm-conflate-runtime-test
- jvm-stateChange-runtime-test
- jvm-stable-handlers-test
- jvm-partial-runtime-test
- jvm-conflate-stateChange-runtime-test
- jvm-conflate-partial-runtime-test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,54 @@ import com.squareup.workflow1.RuntimeConfigOptions
import com.squareup.workflow1.RuntimeConfigOptions.CONFLATE_STALE_RENDERINGS
import com.squareup.workflow1.RuntimeConfigOptions.PARTIAL_TREE_RENDERING
import com.squareup.workflow1.RuntimeConfigOptions.RENDER_ONLY_WHEN_STATE_CHANGES
import com.squareup.workflow1.RuntimeConfigOptions.STABLE_EVENT_HANDLERS
import com.squareup.workflow1.WorkflowExperimentalRuntime

public class AndroidRuntimeConfigTools {

public companion object {
/**
* Helper for Configuration for the workflow runtime in an application.
* This allows one to specify a project property from the gradle build to choose a runtime.
* e.g. add "-Pworkflow.runtime=conflate" in your gradle build to build the conflate runtime
* e.g. add `-Pworkflow.runtime=conflate` in your gradle build to build the conflate runtime
* into the application.
*
* Note that this must be specified in the application built for any ui/integration tests. Call
* this function, and then pass that to the call to [renderWorkflowIn] as the [RuntimeConfig].
* this function and pass the result to [renderWorkflowIn][com.squareup.workflow1.renderWorkflowIn]
* as the [RuntimeConfig] parameter.
*
* Current options (can be combined with `-` characters, e.g. `conflate-partial`):
*
* Current options are:
* "conflate" : Process all queued actions before passing rendering
* to the UI layer.
* "baseline" : Original Workflow Runtime. Note that this doesn't need to
* be specified as it is the current default and is assumed by this utility.
* - `conflate` Process all queued actions before passing rendering to the UI layer.
*
* Then, these can be combined (via '-') with:
* "stateChange" : Only re-render when the state of some WorkflowNode has been changed by an
* - `stateChange` Only re-render when the state of some WorkflowNode has been changed by an
* action cascade.
* "partial" : Which includes "stateChange" as well as partial tree rendering, which only
* re-renders each Workflow node if: 1) its state changed; or 2) one of its descendant's state
* changed.
*
* E.g., "baseline-stateChange" to turn on the stateChange option with the baseline runtime.
* - `partial` Partial tree rendering, which only re-renders each Workflow node if: 1) its
* state changed; or 2) one of its descendant's state changed. (This option requires
* `stateChange`, and enables it as well.)
*
* - `stable` Enables stable event handlers (changes the default value of the `remember`
* parameter of `RenderContext.eventHandler` functions from `false` to `true`)
*/
@WorkflowExperimentalRuntime
public fun getAppWorkflowRuntimeConfig(): RuntimeConfig {
return when (BuildConfig.WORKFLOW_RUNTIME) {
"conflate" -> setOf(CONFLATE_STALE_RENDERINGS)
"conflate-stateChange" -> setOf(CONFLATE_STALE_RENDERINGS, RENDER_ONLY_WHEN_STATE_CHANGES)
"baseline-stateChange" -> setOf(RENDER_ONLY_WHEN_STATE_CHANGES)
"conflate-partial" -> setOf(
CONFLATE_STALE_RENDERINGS,
RENDER_ONLY_WHEN_STATE_CHANGES,
PARTIAL_TREE_RENDERING
)
"baseline-partial" -> setOf(RENDER_ONLY_WHEN_STATE_CHANGES, PARTIAL_TREE_RENDERING)
"", "baseline" -> RuntimeConfigOptions.RENDER_PER_ACTION
else ->
throw IllegalArgumentException("Unrecognized config \"${BuildConfig.WORKFLOW_RUNTIME}\"")
val selection = BuildConfig.WORKFLOW_RUNTIME.split("-")
// We used to have a no-op `baseline` option, let's not choke on it.
.filterNot { it == "baseline" || it.isBlank() }
.toSet()

val config = mutableSetOf<RuntimeConfigOptions>()
selection.forEach {
when (it) {
"conflate" -> config.add(CONFLATE_STALE_RENDERINGS)
"stateChange" -> config.add(RENDER_ONLY_WHEN_STATE_CHANGES)
"partial" -> config.addAll(setOf(RENDER_ONLY_WHEN_STATE_CHANGES, PARTIAL_TREE_RENDERING))
"stable" -> config.add(STABLE_EVENT_HANDLERS)
else -> throw IllegalArgumentException("Unrecognized runtime config option \"$it\"")
}
}

return config
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,56 @@ import com.squareup.workflow1.RuntimeConfigOptions
import com.squareup.workflow1.RuntimeConfigOptions.CONFLATE_STALE_RENDERINGS
import com.squareup.workflow1.RuntimeConfigOptions.PARTIAL_TREE_RENDERING
import com.squareup.workflow1.RuntimeConfigOptions.RENDER_ONLY_WHEN_STATE_CHANGES
import com.squareup.workflow1.RuntimeConfigOptions.STABLE_EVENT_HANDLERS
import com.squareup.workflow1.WorkflowExperimentalRuntime

public class JvmTestRuntimeConfigTools {
public companion object {
/**
* Helper for Configuration for the workflow runtime in an application.
* This allows one to specify a project property from the gradle build to choose a runtime.
* e.g. add "-Pworkflow.runtime=conflate" in your gradle build to build the conflate runtime
* e.g. add `-Pworkflow.runtime=conflate` in your gradle build to build the conflate runtime
* into the application.
*
* The [WorkflowTestRuntime] already calls this utility, but if starting your own runtime, then
* call this function and pass the result to the call to [renderWorkflowIn] as the
* [RuntimeConfig].
* The [WorkflowTestRuntime][com.squareup.workflow1.testing.WorkflowTestRuntime]
* and [RenderTester][com.squareup.workflow1.testing.RenderTester] runtimes
* already call this utility. To honor this property from your own runtime call this
* function and pass the result to the call to
* [renderWorkflowIn][com.squareup.workflow1.renderWorkflowIn] as the [RuntimeConfig] parameter.
*
* Current options are:
* "conflate" : Process all queued actions before passing rendering
* to the UI layer.
* "baseline" : Original Workflow Runtime. Note that this doesn't need to
* be specified as it is the current default and is assumed by this utility.
* Current options (can be combined with `-` characters, e.g. `conflate-partial`):
*
* Then, these can be combined (via '-') with:
* "stateChange" : Only re-render when the state of some WorkflowNode has been changed by an
* - `conflate` Process all queued actions before passing rendering to the UI layer.
*
* - `stateChange` Only re-render when the state of some WorkflowNode has been changed by an
* action cascade.
* "partial" : Which includes "stateChange" as well as partial tree rendering, which only
* re-renders each Workflow node if: 1) its state changed; or 2) one of its descendant's state
* changed.
*
* E.g., "baseline-stateChange" to turn on the stateChange option with the baseline runtime.
* - `partial` Partial tree rendering, which only re-renders each Workflow node if: 1) its
* state changed; or 2) one of its descendant's state changed. (This option requires
* `stateChange`, and enables it as well.)
*
* - `stable` Enables stable event handlers (changes the default value of the `remember`
* parameter of `RenderContext.eventHandler` functions from `false` to `true`)
*/
@OptIn(WorkflowExperimentalRuntime::class)
public fun getTestRuntimeConfig(): RuntimeConfig {
return when
(val runtimeConfig = System.getProperty("workflow.runtime", "baseline")) {
"conflate" -> setOf(CONFLATE_STALE_RENDERINGS)
"conflate-stateChange" -> setOf(CONFLATE_STALE_RENDERINGS, RENDER_ONLY_WHEN_STATE_CHANGES)
"baseline-stateChange" -> setOf(RENDER_ONLY_WHEN_STATE_CHANGES)
"conflate-partial" -> setOf(
CONFLATE_STALE_RENDERINGS,
RENDER_ONLY_WHEN_STATE_CHANGES,
PARTIAL_TREE_RENDERING
)
"baseline-partial" -> setOf(RENDER_ONLY_WHEN_STATE_CHANGES, PARTIAL_TREE_RENDERING)
"", "baseline" -> RuntimeConfigOptions.RENDER_PER_ACTION
else ->
throw IllegalArgumentException("Unrecognized config \"$runtimeConfig\"")
val selection = System.getProperty("workflow.runtime", "").split("-")
// We used to have a no-op `baseline` option, let's not choke on it.
.filterNot { it == "baseline" || it.isBlank() }
.toSet()

val config = mutableSetOf<RuntimeConfigOptions>()
selection.forEach {
when (it) {
"conflate" -> config.add(CONFLATE_STALE_RENDERINGS)
"stateChange" -> config.add(RENDER_ONLY_WHEN_STATE_CHANGES)
"partial" -> config.addAll(setOf(RENDER_ONLY_WHEN_STATE_CHANGES, PARTIAL_TREE_RENDERING))
"stable" -> config.add(STABLE_EVENT_HANDLERS)
else -> throw IllegalArgumentException("Unrecognized runtime config option \"$it\"")
}
}

return config
}
}
}
Loading