From 24f5601e30513ee7feef97b17d56bf2bb288f519 Mon Sep 17 00:00:00 2001 From: Yuri Schimke Date: Sat, 24 Feb 2024 11:00:09 +0000 Subject: [PATCH 1/4] Add build and test workflow --- .github/workflows/build_workflow.main.kts | 35 +++++++++++++++ .github/workflows/build_workflow.yaml | 43 +++++++++++++++++++ .../sample/watchfaces/ClockScreenshotTest.kt | 8 ++++ 3 files changed, 86 insertions(+) create mode 100644 .github/workflows/build_workflow.main.kts create mode 100644 .github/workflows/build_workflow.yaml diff --git a/.github/workflows/build_workflow.main.kts b/.github/workflows/build_workflow.main.kts new file mode 100644 index 0000000..c227572 --- /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.Adopt, 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..f824b18 --- /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: 'adopt' + - 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..5babf24 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,11 @@ abstract class ClockScreenshotTest { abstract val device: WearDevice + @Before + fun check() { + 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") From 693bbc408106e4a4a15c5ba3d40a4624bb68478f Mon Sep 17 00:00:00 2001 From: Yuri Schimke Date: Sat, 24 Feb 2024 11:18:22 +0000 Subject: [PATCH 2/4] Add Fix workflow --- .github/workflows/build_workflow.main.kts | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 .github/workflows/build_workflow.main.kts diff --git a/.github/workflows/build_workflow.main.kts b/.github/workflows/build_workflow.main.kts old mode 100644 new mode 100755 From a7569ab5ab8892f1c917ff6601a18ee6637b2720 Mon Sep 17 00:00:00 2001 From: Louis CAD Date: Sat, 24 Feb 2024 15:14:53 +0100 Subject: [PATCH 3/4] Switch java distribution for GitHub Actions setup-java --- .github/workflows/build_workflow.main.kts | 2 +- .github/workflows/build_workflow.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_workflow.main.kts b/.github/workflows/build_workflow.main.kts index c227572..a5ea783 100755 --- a/.github/workflows/build_workflow.main.kts +++ b/.github/workflows/build_workflow.main.kts @@ -23,7 +23,7 @@ workflow( uses(name = "Check out", action = CheckoutV4()) uses( name = "Setup Java", - action = SetupJavaV4(distribution = SetupJavaV4.Distribution.Adopt, javaVersion = "17") + action = SetupJavaV4(distribution = SetupJavaV4.Distribution.Temurin, javaVersion = "17") ) uses( name = "Build", diff --git a/.github/workflows/build_workflow.yaml b/.github/workflows/build_workflow.yaml index f824b18..eae7377 100644 --- a/.github/workflows/build_workflow.yaml +++ b/.github/workflows/build_workflow.yaml @@ -35,7 +35,7 @@ jobs: uses: 'actions/setup-java@v4' with: java-version: '17' - distribution: 'adopt' + distribution: 'temurin' - id: 'step-2' name: 'Build' uses: 'gradle/gradle-build-action@v3' From 18ad51adfd77d8d0a3eca4c052d0634e347c2c1b Mon Sep 17 00:00:00 2001 From: Yuri Schimke Date: Sat, 24 Feb 2024 15:05:15 +0000 Subject: [PATCH 4/4] Update ClockScreenshotTest.kt --- .../compose/oclock/sample/watchfaces/ClockScreenshotTest.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 5babf24..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 @@ -33,6 +33,8 @@ abstract class ClockScreenshotTest { @Before fun check() { + // Robolectric RNG not supported on Windows + // https://github.com/robolectric/robolectric/issues/8312 assumeFalse(System.getProperty("os.name")?.startsWith("Windows") ?: false) } @@ -50,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 +}