Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add github action #8

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add github action
  • Loading branch information
budius committed Nov 5, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit d9a65af9f6ec1c1533bdbaa5776b170c5373ecd6
32 changes: 32 additions & 0 deletions .github/workflows/on_pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Checks and Tests

on:
workflow_dispatch:
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
gradleTask: [assembleDebug testDebugUnitTest, lintDebug, ktlintCheck]
steps:
- name: Git checkout
uses: actions/checkout@v4

- name: Setup Java JDK
uses: actions/[email protected]
with:
java-version: 21
distribution: temurin
cache: 'gradle'

- name: Check Gradle
uses: gradle/actions/wrapper-validation@v3

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Build with Gradle
run: ./gradlew ${{ matrix.gradleTask }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -30,4 +30,6 @@ render.experimental.xml
google-services.json

# Android Profiling
*.hprof
*.hprof

versions.properties
116 changes: 59 additions & 57 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -7,89 +7,91 @@ import kotlin.random.Random
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
// Using gradle conventions instead
alias(libs.plugins.ktLint)
}

// here are some very simple scripts that used to transform the list extracted from wikipedia,
// into the json used on the mock data.
val names by tasks.registering {
group = "pets"
doLast {
val c = file("plain.txt")
.readLines()
.joinToString("\n") {
it
.substringAfter("The ")
.substringBefore('(')
.substringBefore(' ')
.substringBefore(',')
.trim(' ', ',')

}
val c =
file("plain.txt")
.readLines()
.joinToString("\n") {
it
.substringAfter("The ")
.substringBefore('(')
.substringBefore(' ')
.substringBefore(',')
.trim(' ', ',')
}
file("names.txt").writeText(c)
}
}


val description by tasks.registering {
group = "pets"
doLast {
val c = file("plain.txt")
.readLines()
.joinToString("\n") {
it.substringAfter(")")
.trim(' ', ',', '.')
}
val c =
file("plain.txt")
.readLines()
.joinToString("\n") {
it.substringAfter(")")
.trim(' ', ',', '.')
}
file("description.txt").writeText(c)
}
}

val petTemplate =
"""{"id":"ID","name":"NAME","price":"PRICE","description":"DESC","type":"TYPE","dateOfBirth":"BDAY","priority":PRIORITY}"""
val petTypes = listOf(
"DOG",
"DOG",
"DOG",
"DOG",
"DOG",
"DOG",
"CAT",
"CAT",
"CAT",
"TURTLE",
"TURTLE",
"TURTLE",
"PARROT"
)
val petTypes =
listOf(
"DOG",
"DOG",
"DOG",
"DOG",
"DOG",
"DOG",
"CAT",
"CAT",
"CAT",
"TURTLE",
"TURTLE",
"TURTLE",
"PARROT",
)
val pets by tasks.registering {
group = "pets"
doLast {
val names = file("names.txt").readLines()
val desc = file("description.txt").readLines()
val data = buildList(names.size) {
repeat(names.size) { index ->
val name = names[index]
val description = desc[index]

val bDay =
(LocalDateTime.now() - Duration.ofDays(10L + Random.nextLong(3000)))
.toInstant(ZoneOffset.UTC)
.toString()
val data =
buildList(names.size) {
repeat(names.size) { index ->
val name = names[index]
val description = desc[index]

val prio = Random.nextFloat()
add(
prio to petTemplate
.replace("ID", UUID.randomUUID().toString())
.replace("NAME", name)
.replace("PRICE", (1200 + Random.nextInt(8000)).toString())
.replace("DESC", description)
.replace("TYPE", petTypes.random())
.replace("BDAY", bDay)
.replace("PRIORITY", prio.toString())
val bDay =
(LocalDateTime.now() - Duration.ofDays(10L + Random.nextLong(3000)))
.toInstant(ZoneOffset.UTC)
.toString()

)

}
}.sortedBy { it.first }.joinToString("\n") { it.second }
val prio = Random.nextFloat()
add(
prio to
petTemplate
.replace("ID", UUID.randomUUID().toString())
.replace("NAME", name)
.replace("PRICE", (1200 + Random.nextInt(8000)).toString())
.replace("DESC", description)
.replace("TYPE", petTypes.random())
.replace("BDAY", bDay)
.replace("PRIORITY", prio.toString()),
)
}
}.sortedBy { it.first }.joinToString("\n") { it.second }
file("jsons.txt").writeText(data)
}
}
}
2 changes: 1 addition & 1 deletion buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
rootProject.name="buildSrc"
rootProject.name = "buildSrc"

dependencyResolutionManagement {
versionCatalogs {
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/Android.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
internal object Android {
const val COMPILE_SDK = 34
const val TARGET_SDK = 34
const val COMPILE_SDK = 35
const val TARGET_SDK = 35
const val MIN_SDK = 27
}
74 changes: 42 additions & 32 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,27 +1,4 @@
[versions]
agp = "8.6.1"
kotlin = "2.0.20"
coreKtx = "1.15.0"
junit = "4.13.2"
junitVersion = "1.2.1"
espressoCore = "3.6.1"
lifecycleRuntimeKtx = "2.8.7"
activityCompose = "1.9.3"
composeBom = "2024.10.01"
appcompat = "1.7.0"
material = "1.12.0"
viewModel = "2.8.7"
koin = "3.5.0"
coroutines = "1.8.1"
ktor = "2.3.12"
datetime = "0.6.1"
json = "1.7.2"
ksp = "2.0.20-1.0.24"
room = "2.6.1"
truth = "1.4.4"
runner = "1.6.2"
turbine = "1.1.0"
timber = "5.0.1"
## Generated by $ ./gradlew refreshVersionsCatalog

[bundles]

@@ -40,7 +17,48 @@ feature = [
"koin-compose",
]

[plugins]

android-application = { id = "com.android.application", version.ref = "agp" }
android-library = { id = "com.android.library", version.ref = "agp" }
kotlin = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
ktLint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktLint" }

[versions]

agp = "8.7.2"
kotlin = "2.0.21"
coreKtx = "1.15.0"
junit = "4.13.2"
junitVersion = "1.2.1"
espressoCore = "3.6.1"
lifecycleRuntimeKtx = "2.8.7"
activityCompose = "1.9.3"
composeBom = "2024.10.01"
appcompat = "1.7.0"
material = "1.12.0"
viewModel = "2.8.7"
koin = "3.5.6"
##⬆ = "4.0.0"
coroutines = "1.9.0"
ktor = "2.3.12"
##⬆ = "3.0.0"
##⬆ = "3.0.1"
datetime = "0.6.1"
json = "1.7.3"
ksp = "2.0.21-1.0.26"
room = "2.6.1"
truth = "1.4.4"
runner = "1.6.2"
turbine = "1.2.0"
timber = "5.0.1"
ktLint = "12.1.1"

[libraries]

androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
junit = { group = "junit", name = "junit", version.ref = "junit" }
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
@@ -88,11 +106,3 @@ convention-compose = { group = "org.jetbrains.kotlin", name = "compose-compiler-

truth = { module = "com.google.truth:truth", version.ref = "truth" }
turbine = { module = "app.cash.turbine:turbine", version.ref = "turbine" }

[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
android-library = { id = "com.android.library", version.ref = "agp" }
kotlin = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Sep 04 17:27:35 CEST 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
7 changes: 7 additions & 0 deletions services/network/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -3,6 +3,13 @@ plugins {
alias(libs.plugins.kotlin.serialization)
}

android {
lint {
disable += "UnsafeOptInUsageWarning"
disable += "UnsafeOptInUsageError"
}
}

dependencies {

implementation(libs.ktor.client)
16 changes: 15 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -11,6 +11,20 @@ pluginManagement {
gradlePluginPortal()
}
}

plugins {
// See https://jmfayard.github.io/refreshVersions
id("de.fayard.refreshVersions") version "0.60.5"
}

refreshVersions {
rejectVersionIf {
@Suppress("UnstableApiUsage")
candidate.stabilityLevel != de.fayard.refreshVersions.core.StabilityLevel.Stable
}
}

@Suppress("UnstableApiUsage")
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
@@ -31,4 +45,4 @@ include(":repositories:pets:")
include(":repositories:cart:")

include(":services:network:")
include(":services:database:")
include(":services:database:")