Skip to content

Commit

Permalink
Unify testing structure and test-cases to maximize the code-use acros…
Browse files Browse the repository at this point in the history
…s the frameworks (#365)
  • Loading branch information
osoykan authored Oct 28, 2024
1 parent 6e34981 commit 9433205
Show file tree
Hide file tree
Showing 96 changed files with 1,779 additions and 2,995 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ ktlint_standard_function-signature = disabled
[{*.kt,*.kts}]
indent_style = space
max_line_length = 140
indent_size = 2
ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL
ij_continuation_indent_size = 2
ij_kotlin_allow_trailing_comma = false
Expand Down
15 changes: 9 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Build

on:
push:
branches: [main]
branches: [ main ]
pull_request:
branches: [main]
branches: [ main ]

jobs:
build-and-test:
Expand All @@ -19,15 +19,18 @@ jobs:
- name: Check out Git repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

- name: Gradle Build and Test
uses: gradle/gradle-build-action@v3.5.0
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
arguments: --build-cache build test jacocoTestReport
gradle-version: current

- name: Gradle Build and Test
run: gradle --build-cache --configuration-cache build test koverXmlReport

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: ./build/reports/kediatr-core/jacoco/test/jacocoTestReport.xml,./build/reports/kediatr-koin-starter/jacoco/test/jacocoTestReport.xml,./build/reports/kediatr-quarkus-starter/jacoco/test/jacocoTestReport.xml,./build/reports/kediatr-spring-boot-2x-starter/jacoco/test/jacocoTestReport.xml,./build/reports/kediatr-spring-boot-3x-starter/jacoco/test/jacocoTestReport.xml
files: '**/build/reports/kover/report.xml'
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
Expand Down
40 changes: 20 additions & 20 deletions .github/workflows/gradle-publish.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Publish to Maven

on:
release:
types: [created]
release:
types: [ created ]

jobs:
publish:
runs-on: ubuntu-latest
Expand All @@ -12,21 +12,21 @@ jobs:
packages: write

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
server-id: github
settings-path: ${{ github.workspace }}
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
server-id: github
settings-path: ${{ github.workspace }}

- name: Publish to Maven Repository
uses: gradle/gradle-build-action@v3.5.0
with:
arguments: --build-cache publish
env:
gpg_private_key: ${{ secrets.gpg_private_key }}
gpg_passphrase: ${{ secrets.gpg_passphrase }}
nexus_username: ${{ secrets.nexus_username }}
nexus_password: ${{ secrets.nexus_password }}
- name: Publish to Maven Repository
uses: gradle/gradle-build-action@v3.5.0
with:
arguments: --build-cache publish
env:
gpg_private_key: ${{ secrets.gpg_private_key }}
gpg_passphrase: ${{ secrets.gpg_passphrase }}
nexus_username: ${{ secrets.nexus_username }}
nexus_password: ${{ secrets.nexus_password }}
55 changes: 36 additions & 19 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@
# What's Changed

## New

* Support for Spring-Boot 3.1.0 #116 by @osoykan in https://github.com/Trendyol/kediatR/pull/117

## Package bumps

* Update dependency io.quarkus:quarkus-bom to v3.0.3.Final by @renovate in https://github.com/Trendyol/kediatR/pull/110
* Update plugin io.quarkus to v3.0.3.Final by @renovate in https://github.com/Trendyol/kediatR/pull/111
* Update dependency org.jetbrains.kotlinx:kotlinx-coroutines-core to v1.7.1 by @renovate in https://github.com/Trendyol/kediatR/pull/114
* Update dependency org.jetbrains.kotlinx:kotlinx-coroutines-test to v1.7.1 by @renovate in https://github.com/Trendyol/kediatR/pull/113
* Update dependency org.jetbrains.kotlinx:kotlinx-coroutines-bom to v1.7.1 by @renovate in https://github.com/Trendyol/kediatR/pull/112
* Update dependency org.jetbrains.kotlinx:kotlinx-coroutines-core to v1.7.1 by @renovate
in https://github.com/Trendyol/kediatR/pull/114
* Update dependency org.jetbrains.kotlinx:kotlinx-coroutines-test to v1.7.1 by @renovate
in https://github.com/Trendyol/kediatR/pull/113
* Update dependency org.jetbrains.kotlinx:kotlinx-coroutines-bom to v1.7.1 by @renovate
in https://github.com/Trendyol/kediatR/pull/112

**Full Changelog**: https://github.com/Trendyol/kediatR/compare/v2.1.0...3.0.0-SNAPSHOT

Expand All @@ -27,10 +32,14 @@
## What's Changed

### Enhancements
* Add possibility to invoke publish method with custom publishStrategy by @awaniak in https://github.com/Trendyol/kediatR/pull/92
* Make the quarkus starter work again with quarkus 3.x.x by @lucas-dclrcq in https://github.com/Trendyol/kediatR/pull/109

* Add possibility to invoke publish method with custom publishStrategy by @awaniak
in https://github.com/Trendyol/kediatR/pull/92
* Make the quarkus starter work again with quarkus 3.x.x by @lucas-dclrcq
in https://github.com/Trendyol/kediatR/pull/109

### New Contributors

* @renovate made their first contribution in https://github.com/Trendyol/kediatR/pull/44
* @awaniak made their first contribution in https://github.com/Trendyol/kediatR/pull/92
* @lucas-dclrcq made their first contribution in https://github.com/Trendyol/kediatR/pull/109
Expand Down Expand Up @@ -93,9 +102,12 @@
* Update plugin io.quarkus to v3.0.1.Final by @renovate in https://github.com/Trendyol/kediatR/pull/102
* Update plugin io.quarkus to v3.0.2.Final by @renovate in https://github.com/Trendyol/kediatR/pull/104
* Update dependency io.quarkus:quarkus-bom to v2.16.7.Final by @renovate in https://github.com/Trendyol/kediatR/pull/105
* Update dependency org.jetbrains.kotlinx:kotlinx-coroutines-core to v1.7.0 by @renovate in https://github.com/Trendyol/kediatR/pull/107
* Update dependency org.jetbrains.kotlinx:kotlinx-coroutines-test to v1.7.0 by @renovate in https://github.com/Trendyol/kediatR/pull/108
* Update dependency org.jetbrains.kotlinx:kotlinx-coroutines-bom to v1.7.0 by @renovate in https://github.com/Trendyol/kediatR/pull/106
* Update dependency org.jetbrains.kotlinx:kotlinx-coroutines-core to v1.7.0 by @renovate
in https://github.com/Trendyol/kediatR/pull/107
* Update dependency org.jetbrains.kotlinx:kotlinx-coroutines-test to v1.7.0 by @renovate
in https://github.com/Trendyol/kediatR/pull/108
* Update dependency org.jetbrains.kotlinx:kotlinx-coroutines-bom to v1.7.0 by @renovate
in https://github.com/Trendyol/kediatR/pull/106

**Full Changelog**: https://github.com/Trendyol/kediatR/compare/v2.0.0...v2.1.0

Expand All @@ -104,32 +116,37 @@
This is the announcement release for 2.0.0; in other words, SNAPSHOT is promoted to release.

# Breaking Changes
- CommandBus renamed to Mediator #25

- CommandBus renamed to Mediator #25
- ` executeCommand.* executeQuery.*, publishNotification.*` renamed to `send`
- Pipeline behavior refactored with decorator pattern #31
- Sync code is deleted; now it supports only async invocation #26
- Pipeline behavior refactored with decorator pattern #31
- Sync code is deleted; now it supports only async invocation #26

### Bug Fixes

- general:
- fix name for pom while publishing ([4cf70ac](https://github.com/Trendyol/kediatR/commit/4cf70ac439ddf694decf779b601693bd902c150c))
- fix name for pom while
publishing ([4cf70ac](https://github.com/Trendyol/kediatR/commit/4cf70ac439ddf694decf779b601693bd902c150c))

## [v2.0-SNAPSHOT](https://github.com/Trendyol/kediatR/releases/tag/v2.0-SNAPSHOT) - 2022-10-19 09:10:36

# Breaking Changes
- CommandBus renamed to Mediator #25
- Pipeline behavior refactored with decorator pattern #31
- Sync code is deleted; now it supports only async invocation #26

- CommandBus renamed to Mediator #25
- Pipeline behavior refactored with decorator pattern #31
- Sync code is deleted; now it supports only async invocation #26

### Bug Fixes

- general:
- fix the code snippet for sample kediatr-core usage ([e7f09ba](https://github.com/Trendyol/kediatR/commit/e7f09ba81cb07bd873dd22a9eca683b8d9b461eb)) ([#23](https://github.com/Trendyol/kediatR/pull/23))
- fix the code snippet for sample kediatr-core
usage ([e7f09ba](https://github.com/Trendyol/kediatR/commit/e7f09ba81cb07bd873dd22a9eca683b8d9b461eb)) ([#23](https://github.com/Trendyol/kediatR/pull/23))

### Refactor

- general:
- refactor gradle ([3005893](https://github.com/Trendyol/kediatR/commit/3005893ece9745af2e78875c5334e10dc8373296))
- refactor gradle ([023651c](https://github.com/Trendyol/kediatR/commit/023651c1b316029afdaa0bf4e3c199ab80515025))
- refactor gradle ([3005893](https://github.com/Trendyol/kediatR/commit/3005893ece9745af2e78875c5334e10dc8373296))
- refactor gradle ([023651c](https://github.com/Trendyol/kediatR/commit/023651c1b316029afdaa0bf4e3c199ab80515025))

\* *This CHANGELOG was automatically generated by [auto-generate-changelog](https://github.com/BobAnkh/auto-generate-changelog)*
\* *This CHANGELOG was automatically generated
by [auto-generate-changelog](https://github.com/BobAnkh/auto-generate-changelog)*
59 changes: 30 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,49 @@

<img style="float: left" alt="Humus! The kediatr mascot" src="/humus.png" alt="drawing" width="80"/>

Mediator implementation in kotlin with native coroutine support. Supports Spring-Boot, Quarkus and Koin dependency providers.
Mediator implementation in kotlin with native coroutine support. Supports Spring-Boot, Quarkus and Koin dependency
providers.

Documentation is available at [https://trendyol.github.io/kediatR/](https://trendyol.github.io/kediatR/)

## Show me the code

```kotlin
class PingCommand: Command // or
class PingQuery: Query<String> // or
class PingNotification: Notification
class PingCommandHandler: CommandHandler<PingCommand> {
override suspend fun handle(command: PingCommand) {
println("Pong!")
}
class PingCommand : Command // or
class PingQuery : Query<String> // or
class PingNotification : Notification
class PingCommandHandler : CommandHandler<PingCommand> {
override suspend fun handle(command: PingCommand) {
println("Pong!")
}
}
class PingQueryHandler: QueryHandler<PingQuery, String> {
override suspend fun handle(query: PingQuery): String {
return "Pong!"
}
class PingQueryHandler : QueryHandler<PingQuery, String> {
override suspend fun handle(query: PingQuery): String {
return "Pong!"
}
}

class PingNotificationHandler: NotificationHandler<PingNotification> {
override suspend fun handle(notification: PingNotification) {
println("Pong!")
}
class PingNotificationHandler : NotificationHandler<PingNotification> {
override suspend fun handle(notification: PingNotification) {
println("Pong!")
}
}

class MeasurePipelineBehaviour: PipelineBehaviour {
override suspend fun <TRequest, TResponse> handle(
request: TRequest,
next: RequestHandlerDelegate<TRequest, TResponse>
): TResponse {
val start = System.currentTimeMillis()
val response = next(request)
val end = System.currentTimeMillis()
println("Request ${request::class.simpleName} took ${end - start} ms")
return response
}
}
class MeasurePipelineBehaviour : PipelineBehaviour {
override suspend fun <TRequest, TResponse> handle(
request: TRequest,
next: RequestHandlerDelegate<TRequest, TResponse>
): TResponse {
val start = System.currentTimeMillis()
val response = next(request)
val end = System.currentTimeMillis()
println("Request ${request::class.simpleName} took ${end - start} ms")
return response
}
}

val mediator = // create mediator instance in-memory or with dependency injection, take a look at the documentation
mediator.send(PingCommand()) // 1..1
mediator.send(PingCommand()) // 1..1
mediator.send(PingQuery()) // 1..1
mediator.send(PingNotification()) // 0..N
```
36 changes: 21 additions & 15 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
group = "com.trendyol"

plugins {
kotlin("jvm") version libs.versions.kotlin.get()
id("kediatr-publishing") apply false
id("com.palantir.git-version") version "3.1.0"
java
kotlin("jvm") version libs.versions.kotlin.get()
java
id("kediatr-publishing") apply false
alias(libs.plugins.spotless)
}

val versionDetails: groovy.lang.Closure<com.palantir.gradle.gitversion.VersionDetails> by extra
val details = versionDetails()
version = details.lastTag
version = properties["version"].toString()

subprojectsOf("projects") {
apply {
plugin("kotlin")
plugin("kediatr-publishing")
plugin("java")
}
apply {
plugin("kotlin")
plugin("kediatr-publishing")
plugin("java")
plugin(rootProject.libs.plugins.spotless.pluginId)
}

java {
withSourcesJar()
withJavadocJar()
spotless {
kotlin {
ktlint()
.setEditorConfigPath(rootProject.layout.projectDirectory.file(".editorconfig"))
}
}

java {
withSourcesJar()
withJavadocJar()
}
}
8 changes: 4 additions & 4 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
plugins {
`kotlin-dsl`
`kotlin-dsl`
}

repositories {
mavenCentral()
google()
gradlePluginPortal()
mavenCentral()
google()
gradlePluginPortal()
}
4 changes: 0 additions & 4 deletions buildSrc/src/main/kotlin/BuildConstants.kt

This file was deleted.

Loading

0 comments on commit 9433205

Please sign in to comment.