diff --git a/.github/workflows/build_workflow.main.kts b/.github/workflows/build_workflow.main.kts new file mode 100755 index 0000000..a5ea783 --- /dev/null +++ b/.github/workflows/build_workflow.main.kts @@ -0,0 +1,35 @@ +#!/usr/bin/env kotlin + +@file:DependsOn("io.github.typesafegithub:github-workflows-kt:1.11.0") + +import io.github.typesafegithub.workflows.actions.actions.CheckoutV4 +import io.github.typesafegithub.workflows.actions.actions.SetupJavaV4 +import io.github.typesafegithub.workflows.actions.gradle.GradleBuildActionV3 +import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest +import io.github.typesafegithub.workflows.domain.triggers.PullRequest +import io.github.typesafegithub.workflows.domain.triggers.Push +import io.github.typesafegithub.workflows.dsl.workflow +import io.github.typesafegithub.workflows.yaml.writeToFile + +workflow( + name = "Build workflow", + on = listOf( + Push(branches = listOf("main")), + PullRequest(), + ), + sourceFile = __FILE__.toPath(), +) { + job(id = "build-and-test", runsOn = UbuntuLatest) { + uses(name = "Check out", action = CheckoutV4()) + uses( + name = "Setup Java", + action = SetupJavaV4(distribution = SetupJavaV4.Distribution.Temurin, javaVersion = "17") + ) + uses( + name = "Build", + action = GradleBuildActionV3( + arguments = "test", + ) + ) + } +}.writeToFile() diff --git a/.github/workflows/build_workflow.yaml b/.github/workflows/build_workflow.yaml new file mode 100644 index 0000000..eae7377 --- /dev/null +++ b/.github/workflows/build_workflow.yaml @@ -0,0 +1,43 @@ +# This file was generated using Kotlin DSL (.github/workflows/build_workflow.main.kts). +# If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file. +# Generated with https://github.com/typesafegithub/github-workflows-kt + +name: 'Build workflow' +on: + push: + branches: + - 'main' + pull_request: {} +jobs: + check_yaml_consistency: + name: 'Check YAML consistency' + runs-on: 'ubuntu-latest' + steps: + - id: 'step-0' + name: 'Check out' + uses: 'actions/checkout@v4' + - id: 'step-1' + name: 'Execute script' + run: 'rm ''.github/workflows/build_workflow.yaml'' && ''.github/workflows/build_workflow.main.kts''' + - id: 'step-2' + name: 'Consistency check' + run: 'git diff --exit-code ''.github/workflows/build_workflow.yaml''' + build-and-test: + runs-on: 'ubuntu-latest' + needs: + - 'check_yaml_consistency' + steps: + - id: 'step-0' + name: 'Check out' + uses: 'actions/checkout@v4' + - id: 'step-1' + name: 'Setup Java' + uses: 'actions/setup-java@v4' + with: + java-version: '17' + distribution: 'temurin' + - id: 'step-2' + name: 'Build' + uses: 'gradle/gradle-build-action@v3' + with: + arguments: 'test' diff --git a/shared/src/test/kotlin/org/splitties/compose/oclock/sample/watchfaces/ClockScreenshotTest.kt b/shared/src/test/kotlin/org/splitties/compose/oclock/sample/watchfaces/ClockScreenshotTest.kt index 9d8688f..1f1c669 100644 --- a/shared/src/test/kotlin/org/splitties/compose/oclock/sample/watchfaces/ClockScreenshotTest.kt +++ b/shared/src/test/kotlin/org/splitties/compose/oclock/sample/watchfaces/ClockScreenshotTest.kt @@ -8,6 +8,9 @@ import androidx.compose.ui.test.onRoot import androidx.test.ext.junit.runners.AndroidJUnit4 import com.github.takahirom.roborazzi.captureRoboImage import kotlinx.coroutines.flow.MutableStateFlow +import org.junit.Assume +import org.junit.Assume.assumeFalse +import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith @@ -28,6 +31,13 @@ abstract class ClockScreenshotTest { abstract val device: WearDevice + @Before + fun check() { + // Robolectric RNG not supported on Windows + // https://github.com/robolectric/robolectric/issues/8312 + assumeFalse(System.getProperty("os.name")?.startsWith("Windows") ?: false) + } + fun runTest(isAmbient: Boolean = false, clock: @Composable () -> Unit) { RuntimeEnvironment.setQualifiers("+w${device.dp}dp-h${device.dp}dp") @@ -42,4 +52,4 @@ abstract class ClockScreenshotTest { composeRule.onRoot() .captureRoboImage("src/test/screenshots/${this.javaClass.simpleName}_${device.id}${if (isAmbient) "_ambient" else ""}.png") } -} \ No newline at end of file +}