Skip to content

Commit

Permalink
Merge pull request #33 from mtrewartha/26-run-ci-on-prs-and-pushes-to…
Browse files Browse the repository at this point in the history
…-main

Add tests workflow for PRs and pushes to main
  • Loading branch information
mtrewartha committed Dec 9, 2023
2 parents 0d8fefa + 5f192af commit 186ab49
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 5 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Checks
on:
pull_request:
push:
branches:
- 'main'
jobs:
tests:
name: 'Tests'
runs-on: ubuntu-latest
steps:
- name: 'Check out the repository'
uses: actions/checkout@v4
- name: 'Set up the JDK'
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'
- name: 'Set up the Android SDK'
uses: android-actions/setup-android@v3
- name: 'Run tests'
uses: gradle/gradle-build-action@v2
with:
arguments: test
- name: 'Publish test report'
uses: mikepenz/action-junit-report@v4
if: success() || failure() # always run even if the previous step fails
with:
report_paths: '**/build/test-results/**/TEST-*.xml'
15 changes: 10 additions & 5 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import java.nio.file.NoSuchFileException
import org.jetbrains.kotlin.konan.properties.loadProperties

plugins {
Expand All @@ -21,11 +22,15 @@ android {

signingConfigs {
create("release") {
val uploadKeystoreProperties = loadProperties(PROPERTIES_FILE_PATH)
storeFile = file(uploadKeystoreProperties.getProperty(PROPERTIES_KEY_STORE_FILE))
storePassword = uploadKeystoreProperties.getProperty(PROPERTIES_KEY_STORE_PASSWORD)
keyAlias = uploadKeystoreProperties.getProperty(PROPERTIES_KEY_ALIAS)
keyPassword = uploadKeystoreProperties.getProperty(PROPERTIES_KEY_PASSWORD)
try {
val uploadKeystoreProperties = loadProperties(PROPERTIES_FILE_PATH)
storeFile = file(uploadKeystoreProperties.getProperty(PROPERTIES_KEY_STORE_FILE))
storePassword = uploadKeystoreProperties.getProperty(PROPERTIES_KEY_STORE_PASSWORD)
keyAlias = uploadKeystoreProperties.getProperty(PROPERTIES_KEY_ALIAS)
keyPassword = uploadKeystoreProperties.getProperty(PROPERTIES_KEY_PASSWORD)
} catch (_: NoSuchFileException) {
// Builds can't be signed for upload to store unless properties file is loaded
}
}
}
compileSdk = libs.versions.android.sdk.compile.get().toInt()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import io.trewartha.positional.data.sun.LibrarySolarTimesRepository
import kotlinx.datetime.LocalDate
import kotlinx.datetime.LocalTime
import kotlinx.datetime.Month
import java.util.TimeZone

private val JAN_1_2000 = LocalDate(2000, Month.JANUARY, 1)
private val MAR_1_2000 = LocalDate(2000, Month.MARCH, 1)
Expand All @@ -16,6 +17,7 @@ private val DEC_1_2000 = LocalDate(2000, Month.DECEMBER, 1)

class LocalSolarTimesRepositorySpec : BehaviorSpec({

lateinit var originalDefaultTimeZone: TimeZone
lateinit var subject: LibrarySolarTimesRepository

val dates = listOf(JAN_1_2000, MAR_1_2000, JUN_1_2000, SEP_1_2000, DEC_1_2000)
Expand All @@ -24,9 +26,15 @@ class LocalSolarTimesRepositorySpec : BehaviorSpec({
val coordinates = Coordinates(46.7867, -92.1005)

beforeTest {
originalDefaultTimeZone = TimeZone.getDefault()
TimeZone.setDefault(TimeZone.getTimeZone("America/Chicago")) // Time zone for Duluth above
subject = LibrarySolarTimesRepository()
}

afterTest {
TimeZone.setDefault(originalDefaultTimeZone)
}

given("a date at a specific location") {
`when`("astronomical dawn is calculated") {
val astronomicalDawns = dates.associateWith { date ->
Expand Down

0 comments on commit 186ab49

Please sign in to comment.