Skip to content

Commit

Permalink
Add build and test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
yschimke committed Feb 24, 2024
1 parent 682f4af commit 24f5601
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/build_workflow.main.kts
Original file line number Diff line number Diff line change
@@ -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()
43 changes: 43 additions & 0 deletions .github/workflows/build_workflow.yaml
Original file line number Diff line number Diff line change
@@ -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'
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")

Expand Down

0 comments on commit 24f5601

Please sign in to comment.