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 build checks #30

Merged
merged 13 commits into from
Feb 14, 2025
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
19 changes: 19 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Build

on:
workflow_dispatch:
pull_request:
push:
branches:
- main

jobs:
build:
runs-on: macos-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Build project
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew build -PallWarningsAsErrors=true
20 changes: 0 additions & 20 deletions .github/workflows/code_quality.yml

This file was deleted.

6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]
kotlin = "2.0.0"
kotlinDatetime = "0.6.0"
kotlinSerialization = "1.6.3"
kotlin = "2.1.10"
kotlinDatetime = "0.6.2"
kotlinSerialization = "1.8.0"

[libraries]
kotlin-datetime = { group = "org.jetbrains.kotlinx", name = "kotlinx-datetime", version.ref = "kotlinDatetime" }
Expand Down
7 changes: 7 additions & 0 deletions library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ kotlin {
}
}
}

compilerOptions {
val allWarningsAsErrorsArgument = "allWarningsAsErrors"
if (project.hasProperty(allWarningsAsErrorsArgument)) {
allWarningsAsErrors = (project.property(allWarningsAsErrorsArgument) == "true")
}
}
}

publishing {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ object RequestSerializerInterceptor : JsonTransformingSerializer<Request>(Reques
) : Exception(message)

@Suppress("DEPRECATION") // Accept
private val contextActionClassMap = Context.values().associate { context ->
context.contextKey to Action.values().mapNotNull { action ->
private val contextActionClassMap = Context.entries.associate { context ->
context.contextKey to Action.entries.mapNotNull { action ->
val actionClass: KSerializer<out ContextAction>? = when (context) {
Context.System -> null
Context.Authentication -> when (action) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ object ResponseSerializerInterceptor : JsonTransformingSerializer<Response>(Resp
}

@Suppress("DEPRECATION") // Accepted
private val reactionContextClassMap = Reaction.values().associate { reaction ->
private val reactionContextClassMap = Reaction.entries.associate { reaction ->
reaction.reactionKey to when (reaction) {
Reaction.Informed -> createContextMap { context ->
when (context) {
Expand Down Expand Up @@ -234,7 +234,7 @@ object ResponseSerializerInterceptor : JsonTransformingSerializer<Response>(Resp
mapper: (Context) -> KSerializer<out ReactionData>?
): ReactionClassMap {
return ReactionClassMap.ContextBased(
serializerMap = Context.values().mapNotNull { context ->
serializerMap = Context.entries.mapNotNull { context ->
val serializer = mapper(context) ?: return@mapNotNull null
Pair(context, serializer)
}.toMap()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ data class Status(

override fun deserialize(decoder: Decoder): Type {
val typeName = decoder.decodeString()
return Type.values().find { type ->
return Type.entries.find { type ->
type.name.lowercase() == typeName
} ?: Type.Unknown
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ object TimeHelper {
fun LocalDateTime.toInstant(): Instant = toInstant(timeZone)

/**
* Parses [isoDateString] to a date time object. This can e.g. parse values from [currentDateTimeString]
* Parses [isoDateString] to a date time object. This can e.g. parse a value returned by [LocalDateTime.toString]
*/
fun parse(isoDateString: String): LocalDateTime {
return if (isoDateString.length >= 24) {
// Javascript Date.toISOString() for instance returns this
isoDateString.toInstant().toLocalDateTime(timeZone)
Instant.parse(isoDateString).toLocalDateTime(timeZone)
} else {
isoDateString.toLocalDateTime()
LocalDateTime.parse(isoDateString)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ object ModelHelper {
created = created
)

val type = Event.Type.values().firstOrNull { type -> type.typeId == typeId }
val type = Event.Type.entries.firstOrNull { type -> type.typeId == typeId }
?: throw IllegalStateException("Got unknown event type: $typeId")

return when (type) {
Expand Down Expand Up @@ -72,7 +72,7 @@ object ModelHelper {
tournamentId = tournamentId,
teamAId = teamAId,
teamBId = teamBId,
state = Game.State.values().firstOrNull { state -> state.identifier == gameState }
state = Game.State.entries.firstOrNull { state -> state.identifier == gameState }
?: throw IllegalStateException("Got unknown game state: $gameState"),
teamAPoints = teamAPoints,
teamBPoints = teamBPoints,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ sealed interface PendingRequest {
* Finds a [Type] based on the provided parameters or throw an [IllegalArgumentException] if not found
*/
fun findType(contextIdentifier: String, requestIdentifier: String): Type {
val context = PendingRequestContext.values().firstOrNull { context ->
val context = PendingRequestContext.entries.firstOrNull { context ->
context.context.contextKey == contextIdentifier
}

Expand All @@ -160,7 +160,7 @@ sealed interface PendingRequest {
}
null -> throw IllegalArgumentException(
"Context \"$contextIdentifier\" of pending request not found. Available contexts: ${
PendingRequestContext.values().map { availableContext -> availableContext.context.contextKey }
PendingRequestContext.entries.map { availableContext -> availableContext.context.contextKey }
}"
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ sealed interface UserRole {
* Finds a [ContextRole] based on the provided parameters or throw an [IllegalArgumentException] if not found
*/
fun findContext(contextIdentifier: String, roleIdentifier: String): ContextRole {
val context = RoleContext.values().firstOrNull { context ->
val context = RoleContext.entries.firstOrNull { context ->
context.context.contextKey == contextIdentifier
}

Expand All @@ -155,7 +155,7 @@ sealed interface UserRole {
}
null -> throw IllegalArgumentException(
"Context \"$contextIdentifier\" not found. Available contexts: "
+ "${RoleContext.values().map { availableContext -> availableContext.context.contextKey }}"
+ "${RoleContext.entries.map { availableContext -> availableContext.context.contextKey }}"
)
}
}
Expand Down
31 changes: 0 additions & 31 deletions qodana.yaml

This file was deleted.