From d35651de9d5ae66265af430626fff8ad7d82bf3c Mon Sep 17 00:00:00 2001 From: Mike Trewartha Date: Fri, 8 Dec 2023 22:15:00 -0600 Subject: [PATCH 1/5] Add tests workflow for PRs and pushes to main --- .github/workflows/tests.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..75bf683f --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,29 @@ +name: Tests +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/TEST-*.xml' From f1271592311a63a85512dfa009d75862af1f67b7 Mon Sep 17 00:00:00 2001 From: Mike Trewartha Date: Fri, 8 Dec 2023 22:24:54 -0600 Subject: [PATCH 2/5] Ignore missing upload_keystore.properties --- app/build.gradle.kts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 67e8bad5..275032c4 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,3 +1,4 @@ +import java.nio.file.NoSuchFileException import org.jetbrains.kotlin.konan.properties.loadProperties plugins { @@ -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() From 5f5e88e54316c404814dcb1c8c549b5d39f06eb2 Mon Sep 17 00:00:00 2001 From: Mike Trewartha Date: Fri, 8 Dec 2023 22:26:53 -0600 Subject: [PATCH 3/5] Rename tests workflow to checks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since we’ll eventually run other forms of checks (e.g. lint) --- .github/workflows/{tests.yml => checks.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{tests.yml => checks.yml} (98%) diff --git a/.github/workflows/tests.yml b/.github/workflows/checks.yml similarity index 98% rename from .github/workflows/tests.yml rename to .github/workflows/checks.yml index 75bf683f..d76a35d6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/checks.yml @@ -1,4 +1,4 @@ -name: Tests +name: Checks on: pull_request: push: From b633aaa42bd2b3e81de0451943ae1f176ba53921 Mon Sep 17 00:00:00 2001 From: Mike Trewartha Date: Fri, 8 Dec 2023 22:34:58 -0600 Subject: [PATCH 4/5] Use wildcard for various test report paths --- .github/workflows/checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index d76a35d6..38109f27 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -26,4 +26,4 @@ jobs: uses: mikepenz/action-junit-report@v4 if: success() || failure() # always run even if the previous step fails with: - report_paths: '**/build/test-results/test/TEST-*.xml' + report_paths: '**/build/test-results/**/TEST-*.xml' From 5f192af921918ab49d40af31a0ab7652ffe7b6b1 Mon Sep 17 00:00:00 2001 From: Mike Trewartha Date: Fri, 8 Dec 2023 22:45:44 -0600 Subject: [PATCH 5/5] Set and reset time zone during solar times testing --- .../domain/sun/LocalSolarTimesRepositorySpec.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/src/test/kotlin/io/trewartha/positional/domain/sun/LocalSolarTimesRepositorySpec.kt b/app/src/test/kotlin/io/trewartha/positional/domain/sun/LocalSolarTimesRepositorySpec.kt index 16e727c7..c270ac4b 100644 --- a/app/src/test/kotlin/io/trewartha/positional/domain/sun/LocalSolarTimesRepositorySpec.kt +++ b/app/src/test/kotlin/io/trewartha/positional/domain/sun/LocalSolarTimesRepositorySpec.kt @@ -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) @@ -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) @@ -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 ->