Skip to content

Commit 3cb0f26

Browse files
authored
Update all major versions (#209)
* kotlin-assert * Bump all versions * Upload sarif if available
1 parent 920b609 commit 3cb0f26

File tree

22 files changed

+93
-131
lines changed

22 files changed

+93
-131
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
path: '**/build/reports/**'
3535

3636
- name: Upload Code Scanning code analysis report
37-
if: always()
37+
if: ${{ hashFiles('build/reports/detekt/main.sarif') != '' }}
3838
uses: github/codeql-action/upload-sarif@v3
3939
with:
4040
sarif_file: 'build/reports/detekt/main.sarif'

build.gradle.kts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
44
application
55
alias(libs.plugins.kotest.multiplatform)
66
id(libs.plugins.kotlin.jvm.pluginId)
7-
alias(libs.plugins.dokka)
8-
id(libs.plugins.detekt.pluginId)
97
alias(libs.plugins.kover)
108
alias(libs.plugins.kotlinx.serialization)
119
alias(libs.plugins.sqldelight)
1210
alias(libs.plugins.ktor)
1311
alias(libs.plugins.spotless)
14-
alias(libs.plugins.power.assert)
12+
alias(libs.plugins.kotlin.assert)
1513
}
1614

1715
application {
@@ -27,20 +25,13 @@ sqldelight {
2725
}
2826
}
2927

30-
allprojects {
31-
extra.set("dokka.outputDirectory", rootDir.resolve("docs"))
32-
setupDetekt()
33-
}
34-
3528
repositories {
3629
mavenCentral()
3730
}
3831

3932
tasks {
4033
withType<KotlinCompile>().configureEach {
41-
kotlinOptions {
42-
freeCompilerArgs = freeCompilerArgs + "-Xcontext-receivers"
43-
}
34+
kotlin.compilerOptions.freeCompilerArgs.add("-Xcontext-receivers")
4435
}
4536

4637
test {

config/detekt/detekt.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ processors:
1515
console-reports:
1616
active: true
1717
exclude:
18-
- 'ProjectStatisticsReport'
19-
- 'ComplexityReport'
20-
- 'NotificationReport'
21-
- 'FindingsReport'
22-
- 'FileBasedFindingsReport'
18+
- 'ProjectStatisticsReport'
19+
- 'ComplexityReport'
20+
- 'NotificationReport'
21+
- 'FindingsReport'
22+
- 'FileBasedFindingsReport'
2323
# - 'LiteFindingsReport'
2424

2525
output-reports:
@@ -687,4 +687,4 @@ style:
687687
active: true
688688
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
689689
excludeImports:
690-
- 'java.util.*'
690+
- 'java.util.*'

docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ services:
44
image: postgres:latest
55
restart: always
66
ports:
7-
- 5432:5432
7+
- "5432:5432"
88
container_name: ktor-arrow-example-database
99
environment:
1010
- POSTGRES_USER=postgres

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ projects.group = "io.github.nomisrev"
44
projects.version = "0.0.1"
55

66
org.gradle.jvmargs="-XX:MaxMetaspaceSize=512m"
7+
io.ktor.development=true

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

libs.versions.toml

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,23 @@
11
[versions]
2-
arrow = "1.2.1"
3-
arrowGradleConfig = "0.11.0"
2+
arrow = "2.0.1"
43
coroutines = "1.7.3"
5-
dokka = "1.9.10"
6-
kotlin = "1.9.20"
7-
kotest = "5.8.0"
8-
kotest-plugin = "5.8.0"
9-
kover = "0.7.4"
10-
detekt = "1.23.3"
11-
ktor = "2.3.6"
12-
logback = "1.4.11"
13-
sqldelight="2.0.0"
14-
testcontainers="1.19.3"
15-
hikari="5.1.0"
16-
postgresql="42.7.0"
17-
kjwt="0.9.0"
18-
kotest-arrow="1.4.0"
4+
kotlin = "2.1.10"
5+
kotest = "5.9.1"
6+
kover = "0.9.1"
7+
detekt = "1.23.7"
8+
ktor = "3.1.0"
9+
logback = "1.5.16"
10+
sqldelight="2.0.2"
11+
testcontainers="1.20.4"
12+
hikari="6.2.1"
13+
postgresql="42.7.5"
14+
kjwt="1.0.0"
15+
kotest-arrow="2.0.0"
1916
kotest-testcontainers="2.0.2"
20-
slugify="3.0.6"
17+
slugify="3.0.7"
2118
suspendapp="0.4.0"
22-
cohort="2.3.0"
23-
spotless="6.22.0"
24-
power-assert = "0.13.0"
19+
cohort="2.6.1"
20+
spotless="7.0.2"
2521

2622
[libraries]
2723
arrow-core = { module = "io.arrow-kt:arrow-core", version.ref = "arrow" }
@@ -31,7 +27,6 @@ suspendapp = { module = "io.arrow-kt:suspendapp", version.ref = "suspendapp" }
3127
suspendapp-ktor = { module = "io.arrow-kt:suspendapp-ktor", version.ref = "suspendapp" }
3228
coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm", version.ref = "coroutines" }
3329
coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" }
34-
dokka-core = { module = "org.jetbrains.dokka:dokka-core", version.ref = "dokka" }
3530
kotest-assertionsCore = { module = "io.kotest:kotest-assertions-core", version.ref = "kotest" }
3631
kotest-frameworkEngine = { module = "io.kotest:kotest-framework-engine", version.ref = "kotest" }
3732
kotest-property = { module = "io.kotest:kotest-property", version.ref = "kotest" }
@@ -44,7 +39,7 @@ ktor-server-core = { module = "io.ktor:ktor-server-core", version.ref = "ktor" }
4439
ktor-server-cors = { module = "io.ktor:ktor-server-cors", version.ref = "ktor" }
4540
ktor-server-defaultheaders = { module = "io.ktor:ktor-server-default-headers", version.ref = "ktor" }
4641
ktor-server-netty = { module = "io.ktor:ktor-server-netty", version.ref = "ktor" }
47-
ktor-server-tests = { module = "io.ktor:ktor-server-tests", version.ref = "ktor" }
42+
ktor-server-tests = { module = "io.ktor:ktor-server-test-host", version.ref = "ktor" }
4843
ktor-server-auth = { module = "io.ktor:ktor-server-auth", version.ref = "ktor" }
4944
ktor-server-auth-jwt = { module = "io.ktor:ktor-server-auth-jwt", version.ref = "ktor" }
5045
ktor-server-resources = { module = "io.ktor:ktor-server-resources", version.ref = "ktor" }
@@ -65,7 +60,7 @@ sqldelight-postgresql = { module = "app.cash.sqldelight:postgresql-dialect", ver
6560
postgresql = { module="org.postgresql:postgresql", version.ref="postgresql" }
6661
kjwt-core = { module="io.github.nefilim.kjwt:kjwt-core", version.ref="kjwt" }
6762
slugify = { module="com.github.slugify:slugify", version.ref="slugify" }
68-
cohort-core = { module="com.sksamuel.cohort:cohort-core", version.ref="cohort" }
63+
cohort-ktor = { module="com.sksamuel.cohort:cohort-ktor", version.ref="cohort" }
6964
cohort-hikari = { module="com.sksamuel.cohort:cohort-hikari", version.ref="cohort" }
7065

7166
[bundles]
@@ -96,20 +91,17 @@ kotest = [
9691
"kotest-testcontainers"
9792
]
9893
cohort = [
99-
"cohort-core",
94+
"cohort-ktor",
10095
"cohort-hikari"
10196
]
10297

10398
[plugins]
104-
arrowGradleConfig-formatter = { id = "io.arrow-kt.arrow-gradle-config-formatter", version.ref = "arrowGradleConfig" }
105-
arrowGradleConfig-kotlin = { id = "io.arrow-kt.arrow-gradle-config-kotlin", version.ref = "arrowGradleConfig" }
106-
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
10799
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
108-
kotest-multiplatform = { id = "io.kotest.multiplatform", version.ref = "kotest-plugin" }
100+
kotest-multiplatform = { id = "io.kotest.multiplatform", version.ref = "kotest" }
109101
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
102+
kotlin-assert = { id = "org.jetbrains.kotlin.plugin.power-assert", version.ref = "kotlin" }
110103
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
111104
kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
112105
sqldelight = { id = "app.cash.sqldelight", version.ref = "sqldelight" }
113106
ktor = { id = "io.ktor.plugin", version.ref = "ktor" }
114107
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
115-
power-assert = { id = "com.bnorm.power.kotlin-power-assert", version.ref = "power-assert" }

src/main/kotlin/io/github/nomisrev/DomainError.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ data class EmailAlreadyExists(val email: String) : UserError
2828

2929
data class UsernameAlreadyExists(val username: String) : UserError
3030

31-
object PasswordNotMatched : UserError
31+
data object PasswordNotMatched : UserError
3232

3333
sealed interface JwtError : DomainError
3434

src/main/kotlin/io/github/nomisrev/auth/jwt.kt

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,42 @@ package io.github.nomisrev.auth
44

55
import arrow.core.Either
66
import io.github.nomisrev.repo.UserId
7-
import io.github.nomisrev.routes.respond
87
import io.github.nomisrev.service.JwtService
98
import io.ktor.http.HttpStatusCode
109
import io.ktor.http.auth.HttpAuthHeader
11-
import io.ktor.server.application.ApplicationCall
12-
import io.ktor.server.application.call
1310
import io.ktor.server.auth.parseAuthorizationHeader
1411
import io.ktor.server.response.respond
15-
import io.ktor.util.pipeline.PipelineContext
12+
import io.ktor.server.routing.RoutingContext
1613

1714
@JvmInline value class JwtToken(val value: String)
1815

1916
data class JwtContext(val token: JwtToken, val userId: UserId)
2017

2118
// Small middleware to validate JWT token without using Ktor Auth / Nullable principle
22-
suspend inline fun PipelineContext<Unit, ApplicationCall>.jwtAuth(
19+
suspend inline fun RoutingContext.jwtAuth(
2320
jwtService: JwtService,
24-
crossinline body: suspend PipelineContext<Unit, ApplicationCall>.(JwtContext) -> Unit
21+
crossinline body: suspend RoutingContext.(JwtContext) -> Unit
2522
) {
2623
optionalJwtAuth(jwtService) { context ->
2724
context?.let { body(this, it) } ?: call.respond(HttpStatusCode.Unauthorized)
2825
}
2926
}
3027

31-
suspend inline fun PipelineContext<Unit, ApplicationCall>.optionalJwtAuth(
28+
suspend inline fun RoutingContext.optionalJwtAuth(
3229
jwtService: JwtService,
33-
crossinline body: suspend PipelineContext<Unit, ApplicationCall>.(JwtContext?) -> Unit
30+
crossinline body: suspend RoutingContext.(JwtContext?) -> Unit
3431
) {
3532
jwtToken()?.let { token ->
3633
jwtService
3734
.verifyJwtToken(JwtToken(token))
3835
.fold(
39-
{ error -> respond(error) },
36+
{ error -> call.respond(error) },
4037
{ userId -> body(this, JwtContext(JwtToken(token), userId)) }
4138
)
4239
} ?: body(this, null)
4340
}
4441

45-
fun PipelineContext<Unit, ApplicationCall>.jwtToken(): String? =
42+
fun RoutingContext.jwtToken(): String? =
4643
Either.catch { (call.request.parseAuthorizationHeader() as? HttpAuthHeader.Single) }
4744
.getOrNull()
4845
?.blob

src/main/kotlin/io/github/nomisrev/env/Dependencies.kt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package io.github.nomisrev.env
22

3-
import arrow.fx.coroutines.continuations.ResourceScope
3+
import arrow.fx.coroutines.ResourceScope
44
import com.sksamuel.cohort.HealthCheckRegistry
55
import com.sksamuel.cohort.hikari.HikariConnectionsHealthCheck
66
import io.github.nomisrev.repo.TagPersistence
@@ -16,7 +16,6 @@ import io.github.nomisrev.service.articleService
1616
import io.github.nomisrev.service.jwtService
1717
import io.github.nomisrev.service.slugifyGenerator
1818
import io.github.nomisrev.service.userService
19-
import kotlin.time.Duration.Companion.seconds
2019
import kotlinx.coroutines.Dispatchers
2120

2221
class Dependencies(
@@ -41,9 +40,7 @@ suspend fun ResourceScope.dependencies(env: Env): Dependencies {
4140
val userService = userService(userRepo, jwtService)
4241

4342
val checks =
44-
HealthCheckRegistry(Dispatchers.Default) {
45-
register(HikariConnectionsHealthCheck(hikari, 1), 5.seconds)
46-
}
43+
HealthCheckRegistry(Dispatchers.Default) { register(HikariConnectionsHealthCheck(hikari, 1)) }
4744

4845
return Dependencies(
4946
userService = userService,

0 commit comments

Comments
 (0)