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

Dependencies upgrade #55

Merged
merged 5 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ ij_kotlin_name_count_to_use_star_import_for_members = 99999
ij_java_names_count_to_use_import_on_demand = 99999

ktlint_code_style = ktlint_official
ktlint_standard_filename = disabled
ktlint_standard_filename = disabled
ktlint_function_signature_body_expression_wrapping = default
ktlint_standard_multiline-expression-wrapping = disabled
ktlint_standard_string-template-indent = disabled
ktlint_function_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = 5
25 changes: 19 additions & 6 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,35 @@ jobs:
build_image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Cache
uses: actions/cache@v4
with:
path: |
./build
./.gradle
~/.gradle/caches
~/.gradle/wrapper
~/.m2/repository
key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@ccb4328a959376b642e027874838f60f8e596de3

- name: Build Project with Gradle
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629
uses: gradle/gradle-build-action@v3
with:
arguments: build

- uses: extractions/setup-just@v1
- uses: extractions/setup-just@v2

- name: Build and publish image with jib
run: just build-push-image
Expand All @@ -34,9 +47,9 @@ jobs:
runs-on: ubuntu-latest
needs: build_image
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: extractions/setup-just@v1
- uses: extractions/setup-just@v2

- uses: azure/setup-helm@v3

Expand Down
21 changes: 17 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,33 @@ jobs:
check_verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: gradle

- name: Cache
uses: actions/cache@v4
with:
path: |
./build
./.gradle
~/.gradle/caches
~/.gradle/wrapper
~/.m2/repository
key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation[email protected]
uses: gradle/actions/wrapper-validation@v3

- name: Build Project with Gradle
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629
uses: gradle/gradle-build-action@v3
with:
arguments: build

Expand Down
93 changes: 47 additions & 46 deletions backend/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

plugins {
application
id("com.github.johnrengelman.shadow") version Versions.SHADOW
id("com.google.cloud.tools.jib") version "3.3.2"
alias(libs.plugins.kotlinJvm)
alias(libs.plugins.jib)
alias(libs.plugins.shadow)
}

group = Artifact.GROUP
Expand Down Expand Up @@ -37,51 +38,50 @@ jib {

dependencies {
implementation(kotlin("stdlib"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.COROUTINES}")

implementation(platform("io.vertx:vertx-stack-depchain:${Versions.VERTX}"))
"io.vertx".let { vertx ->
implementation("$vertx:vertx-core")
implementation("$vertx:vertx-web-graphql")
implementation("$vertx:vertx-auth-jwt")
implementation("$vertx:vertx-sql-client-templates")
implementation("$vertx:vertx-web")
implementation("$vertx:vertx-pg-client")
implementation("$vertx:vertx-lang-kotlin-coroutines")
implementation("$vertx:vertx-lang-kotlin")
implementation("$vertx:vertx-health-check")
implementation("$vertx:vertx-web-client")

testImplementation("$vertx:vertx-junit5")
implementation(libs.kotlinx.coroutines.core)

implementation(platform(libs.vertx.depchain))

with(libs.vertx) {
implementation(core)
implementation(web)
implementation(pgClient)
implementation(coroutines)
implementation(kotlin)
implementation(healthCheck)
implementation(webClient)

testImplementation(junit5)
}

implementation("com.michael-bull.kotlin-result:kotlin-result:${Versions.KOTLIN_RESULT}")
implementation(libs.kotlinResult)

implementation("org.flywaydb:flyway-core:${Versions.FLYWAY}")
implementation("org.postgresql:postgresql:${Versions.POSTGRES}")
implementation("com.ongres.scram:client:${Versions.ONGRESS_SCARM}")
implementation(libs.flyway.core)
implementation(libs.flyway.postgresql)
implementation(libs.postgresql)
implementation(libs.scramOngressClient)

implementation("org.slf4j:slf4j-api:${Versions.SLF4J}")
implementation("org.slf4j:slf4j-simple:${Versions.SLF4J}")
implementation("io.github.microutils:kotlin-logging-jvm:${Versions.JVM_LOGGER}")
implementation(libs.slf4j.api)
implementation(libs.slf4j.simpe)
implementation(libs.kotlinLoggingJvm)

implementation("com.fasterxml.jackson.core:jackson-databind:${Versions.JACKSON}")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:${Versions.JACKSON}")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${Versions.JACKSON}")
implementation(libs.jackson.databind)
implementation(libs.jackson.moduleKotlin)
implementation(libs.jackson.datatype.jsr310)

implementation("org.kodein.di:kodein-di:${Versions.KODEIN_DI}")
implementation(libs.kodein)
implementation(libs.jobrunr)
implementation(libs.jobrunr.kotlin)
implementation(libs.firebaseAdmin)

implementation("org.jobrunr:jobrunr:${Versions.JOB_RUNNER}")
implementation("org.jobrunr:jobrunr-kotlin-1.8-support:${Versions.JOB_RUNNER}")
implementation("com.google.firebase:firebase-admin:9.2.0")
testImplementation(libs.junit.jupiter)
testImplementation(libs.kotest.assertions.core)
testImplementation(libs.mockk)

testImplementation("org.junit.jupiter:junit-jupiter:${Versions.JUNIT_JUPITER}")
testImplementation("io.kotest:kotest-assertions-core:${Versions.KO_TEST}")
testImplementation("io.mockk:mockk:${Versions.MOCKK}")
with("org.testcontainers") {
testImplementation("$this:testcontainers:${Versions.TEST_CONTAINERS}")
testImplementation("$this:junit-jupiter:${Versions.TEST_CONTAINERS}")
testImplementation("$this:postgresql:${Versions.TEST_CONTAINERS}")
with(libs.testcontainers) {
testImplementation(this)
testImplementation(junit)
testImplementation(postgresql)
}
}

Expand All @@ -95,13 +95,14 @@ tasks.withType<ShadowJar> {
}

tasks.withType<JavaExec> {
args = listOf(
"run",
mainVerticleName,
"--redeploy=$watchForChange",
"--launcher-class=$launcherClassName",
"--on-redeploy=$doOnChange"
)
args =
listOf(
"run",
mainVerticleName,
"--redeploy=$watchForChange",
"--launcher-class=$launcherClassName",
"--on-redeploy=$doOnChange",
)
}

tasks.test {
Expand Down
8 changes: 4 additions & 4 deletions backend/src/main/kotlin/me/sujanpoudel/playdeals/Conf.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package me.sujanpoudel.playdeals
enum class Environment {
PRODUCTION,
DEVELOPMENT,
TEST
TEST,
}

data class Conf(
Expand All @@ -12,21 +12,21 @@ data class Conf(
val environment: Environment,
val backgroundTask: BackgroundTask,
val firebaseAuthCredential: String,
val forexApiKey: String
val forexApiKey: String,
) {
data class DB(
val host: String,
val port: Int,
val name: String,
val username: String,
val password: String,
val poolSize: Int
val poolSize: Int,
)

data class BackgroundTask(
val dashboardEnabled: Boolean,
val dashboardUserName: String,
val dashboardPassword: String
val dashboardPassword: String,
)

data class Api(val port: Int, val cors: String)
Expand Down
32 changes: 15 additions & 17 deletions backend/src/main/kotlin/me/sujanpoudel/playdeals/DIConfigurer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import com.google.firebase.messaging.FirebaseMessaging
import io.vertx.core.Vertx
import io.vertx.core.eventbus.DeliveryOptions
import io.vertx.core.json.jackson.DatabindCodec
import io.vertx.pgclient.PgBuilder
import io.vertx.pgclient.PgConnectOptions
import io.vertx.pgclient.PgPool
import io.vertx.sqlclient.PoolOptions
import me.sujanpoudel.playdeals.api.ApiVerticle
import me.sujanpoudel.playdeals.jobs.AndroidAppExpiryCheckScheduler
Expand Down Expand Up @@ -50,10 +50,7 @@ import java.time.Duration

inline fun <reified T : Any> DI.get(tag: String? = null) = direct.instance<T>(tag)

fun configureDI(
vertx: Vertx,
conf: Conf
) = DI {
fun configureDI(vertx: Vertx, conf: Conf) = DI {
bindSingleton { conf }

bindSingleton { ApiVerticle(di = this) }
Expand All @@ -67,7 +64,7 @@ fun configureDI(
MainVerticle(
apiVerticle = instance(),
backgroundJobsVerticle = instance(),
flywayVerticle = instance()
flywayVerticle = instance(),
)
}

Expand All @@ -93,11 +90,12 @@ fun configureDI(
}

bindSingleton {
PgPool.client(vertx, instance<PgConnectOptions>(), PoolOptions().setMaxSize(conf.db.poolSize))
}

bindSingleton {
PgPool.pool(vertx, instance<PgConnectOptions>(), PoolOptions())
PgBuilder
.client()
.using(vertx)
.connectingTo(instance<PgConnectOptions>())
.with(PoolOptions().setMaxSize(conf.db.poolSize))
.build()
}

bindSingleton<JobActivator> {
Expand All @@ -114,7 +112,7 @@ fun configureDI(
setURL("jdbc:postgresql://${conf.db.host}:${conf.db.port}/${conf.db.name}?currentSchema=job_runr")
user = conf.db.username
password = conf.db.password
}
},
)
}

Expand All @@ -125,15 +123,15 @@ fun configureDI(
conf.backgroundTask.dashboardEnabled,
JobRunrDashboardWebServerConfiguration
.usingStandardDashboardConfiguration()
.andBasicAuthentication(conf.backgroundTask.dashboardUserName, conf.backgroundTask.dashboardPassword)
.andBasicAuthentication(conf.backgroundTask.dashboardUserName, conf.backgroundTask.dashboardPassword),
)
.useJobActivator(instance())
.useBackgroundJobServer(
BackgroundJobServerConfiguration.usingStandardBackgroundJobServerConfiguration()
.andDeleteSucceededJobsAfter(Duration.ofMinutes(10))
.andPermanentlyDeleteDeletedJobsAfter(Duration.ofMinutes(10))
.andWorkerCount(1)
.andPollIntervalInSeconds(10)
.andWorkerCount(2)
.andPollIntervalInSeconds(10),
)
.initialize()
}
Expand All @@ -157,13 +155,13 @@ fun configureDI(
AndroidAppExpiryCheckScheduler(
repository = instance(),
requestScheduler = instance(),
storageProvider = instance()
storageProvider = instance(),
)
}
bindSingleton {
ForexFetcher(
di = di,
conf = instance()
conf = instance(),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import io.vertx.kotlin.coroutines.CoroutineVerticle
import org.flywaydb.core.Flyway

class FlywayVerticle(private val flyway: Flyway) : CoroutineVerticle() {

override suspend fun start() {
flyway.migrate()
}
Expand Down
4 changes: 2 additions & 2 deletions backend/src/main/kotlin/me/sujanpoudel/playdeals/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package me.sujanpoudel.playdeals
import com.fasterxml.jackson.databind.ObjectMapper
import com.github.michaelbull.result.getOrThrow
import io.vertx.core.Vertx
import io.vertx.kotlin.coroutines.await
import io.vertx.kotlin.coroutines.coAwait
import kotlinx.coroutines.runBlocking
import me.sujanpoudel.playdeals.common.BootstrapException
import me.sujanpoudel.playdeals.common.buildConf
Expand All @@ -27,5 +27,5 @@ fun main(): Unit = runBlocking {
.onFailure {
logger.error(it) { "Error deploying main verticle" }
vertx.close()
}.await()
}.coAwait()
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
package me.sujanpoudel.playdeals

import io.vertx.kotlin.coroutines.CoroutineVerticle
import io.vertx.kotlin.coroutines.await
import io.vertx.kotlin.coroutines.coAwait
import me.sujanpoudel.playdeals.api.ApiVerticle
import me.sujanpoudel.playdeals.jobs.BackgroundJobsVerticle

class MainVerticle(
private val apiVerticle: ApiVerticle,
private val flywayVerticle: FlywayVerticle,
private val backgroundJobsVerticle: BackgroundJobsVerticle
private val backgroundJobsVerticle: BackgroundJobsVerticle,
) : CoroutineVerticle() {

override suspend fun start() {
vertx.deployVerticle(flywayVerticle).await()
vertx.deployVerticle(backgroundJobsVerticle).await()
vertx.deployVerticle(apiVerticle).await()
vertx.deployVerticle(flywayVerticle).coAwait()
vertx.deployVerticle(backgroundJobsVerticle).coAwait()
vertx.deployVerticle(apiVerticle).coAwait()
}
}
Loading
Loading