1 Commits
Author SHA1 Message Date
flecomte 9bffcd3267 chore: fix postgresql.secret in ci
Tests / build (push) Successful in 6m11s
Tests / test (push) Failing after 14m7s
Tests / lint (push) Successful in 14m37s
2026-07-31 20:19:04 +02:00
10 changed files with 50 additions and 51 deletions
+1 -4
View File
@@ -105,11 +105,8 @@ jobs:
- name: Grant execute permission to Gradle wrapper
run: chmod +x gradlew
- name: Start CI Docker Compose services
run: ./gradlew ciComposeUp -Pci
- name: Run tests
run: ./gradlew test -x ciComposeUp -Pci --no-daemon
run: ./gradlew test --no-daemon
- name: Upload test reports
if: always()
+24 -33
View File
@@ -1,4 +1,3 @@
import com.avast.gradle.dockercompose.ComposeExtension
import org.jlleitschuh.gradle.ktlint.KtlintExtension
val ktorVersion: Provider<String> = providers.gradleProperty("ktor_version")
@@ -50,38 +49,29 @@ tasks.withType<Test>().configureEach {
useJUnitPlatform()
}
configure<ComposeExtension> {
createNested("test").apply {
useComposeFiles.set(listOf("docker/docker-compose-test.yaml"))
dockerCompose {
val composeFile =
if (project.hasProperty("ci")) {
// Use docker-compose-ci.yaml for the CI
"docker/docker-compose-ci.yaml"
} else {
// Use docker-compose-test.yaml for local tests
"docker/docker-compose-test.yaml"
}
useComposeFiles.set(listOf(composeFile))
setProjectName("event-demo-test")
}
createNested("dev").apply {
useComposeFiles.set(listOf("docker/docker-compose-dev.yaml"))
setProjectName("event-demo-dev")
}
createNested("ci").apply {
useComposeFiles.set(listOf("docker/docker-compose-ci.yaml"))
setProjectName("event-demo-ci")
}
}
tasks.test {
dependsOn("testComposeUp")
dependsOn("composeUp")
dockerCompose.useComposeFiles.set(listOf("docker/docker-compose-test.yaml"))
dockerCompose.setProjectName("event-demo-test")
}
tasks.named("run") {
dependsOn("devComposeUp")
}
tasks.composeUp {
dependsOn("copyEnv")
}
tasks.named("devComposeUp") {
dependsOn("copyEnv")
}
tasks.named("testComposeUp") {
dependsOn("copyEnv")
}
tasks.named("ciComposeUp") {
dependsOn("copyEnv")
dependsOn("composeUp")
dockerCompose.useComposeFiles.set(listOf("docker/docker-compose-test.yaml"))
dockerCompose.setProjectName("event-demo-dev")
}
tasks.register<Copy>("copyEnv") {
@@ -99,12 +89,10 @@ tasks.register<Copy>("copyEnv") {
}
}
val files =
buildList {
add(File("docker/postgresql.secret"))
if (!project.hasProperty("ci")) {
add(File("docker/pgadmin.secret"))
}
}
listOf(
File("docker/pgadmin.secret"),
File("docker/postgresql.secret"),
)
outputs.files(*files.toTypedArray())
doLast {
files.forEach {
@@ -114,6 +102,9 @@ tasks.register<Copy>("copyEnv") {
}
}
}
tasks.composeUp {
dependsOn("copyEnv")
}
dependencies {
implementation("io.ktor:ktor-server-core-jvm")
+3 -1
View File
@@ -1,4 +1,6 @@
name: event-demo-ci
name: event-demo-test
include:
- path:
- parts/docker-compose-databases.yaml
- parts/docker-compose-databases-expose.yaml
- parts/docker-compose-traefik.yaml
-4
View File
@@ -1,4 +0,0 @@
name: event-demo-test
include:
- path:
- docker-compose-test.yaml
+6 -1
View File
@@ -24,6 +24,8 @@ services:
environment:
POSTGRES_PASSWORD_FILE: /run/secrets/postgresql_password
POSTGRES_USER: event-demo
secrets:
- postgresql_password
healthcheck:
test: ["CMD-SHELL", "sh -c 'pg_isready -U event-demo'"]
interval: 1s
@@ -31,7 +33,6 @@ services:
retries: 10
volumes:
- postgresql_data:/var/lib/postgresql
- ../postgresql.secret:/run/secrets/postgresql_password:ro
rabbitmq:
image: rabbitmq:4-management-alpine
@@ -46,6 +47,10 @@ services:
volumes:
- rabbitmq_data:/var/lib/rabbitmq/
secrets:
postgresql_password:
file: ../postgresql.secret
volumes:
redis_data:
redisinsight_data:
@@ -37,8 +37,16 @@ abstract class GameEventManager(
return this
}
protected inline fun <reified G : Game> Game.isStatusOrFail(message: String): G =
this as? G ?: throw CommandException(message)
protected fun <G : Game> Game.isStatusOrFail(
kClass: KClass<G>,
message: String,
): G {
if (kClass.isInstance(this)) {
return this as G
} else {
throw CommandException(message)
}
}
protected fun <T> retry(
mapAttempts: Int = 5,
@@ -20,7 +20,7 @@ class JoinTheGameHandler(
retry {
command
.getGame()
.isStatusOrFail<GameCreated>("The game is started")
.isStatusOrFail(GameCreated::class, "The game is started")
.userJoinTheGame(
userId = command.userId,
name = user.username,
@@ -16,7 +16,7 @@ class PlayCardHandler(
override fun handle(command: PlayCardCommand) {
command
.getGame()
.isStatusOrFail<GameStarted>("The game is not started")
.isStatusOrFail(GameStarted::class, "The game is not started")
.playTheCard(
card = command.payload.card,
playerId = command.payload.playerId,
@@ -16,7 +16,7 @@ class ReadyToPlayHandler(
override fun handle(command: ReadyToPlayCommand) {
command
.getGame()
.isStatusOrFail<GameCreated>("The game is started")
.isStatusOrFail(GameCreated::class, "The game is started")
.setReadyPlayer(command.payload.playerId)
.saveEvents()
.publishEvents()
@@ -18,7 +18,7 @@ class TakeCartFromDrawPileHandler(
override fun handle(command: TakeCartFromDrawPileCommand) {
command
.getGame()
.isStatusOrFail<GameStarted>("The game is not started")
.isStatusOrFail(GameStarted::class, "The game is not started")
.playerTakeCartFromDrawPile(command.payload.playerId, 1)
.saveEvents()
.publishEvents()