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

Release: v4.1.0 #229

Merged
merged 37 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
f9966d6
Update Kotlin from 2.0.10 to 2.0.20
ForteScarlet Oct 15, 2024
b14f67d
build(deps): bump log4j from 2.23.1 to 2.24.1
dependabot[bot] Oct 15, 2024
ae19c8c
Update Kotlinx serialization from 1.7.1 to 1.7.3
ForteScarlet Oct 15, 2024
fbf4c3f
Apply apiDump
ForteScarlet Oct 15, 2024
1ac8e30
Merge pull request #221 from simple-robot/dev/update-kt
ForteScarlet Oct 15, 2024
5e2aa6d
Merge pull request #210 from simple-robot/dependabot/gradle/dev/main/…
ForteScarlet Oct 15, 2024
66f115e
Merge pull request #222 from simple-robot/dev/update-kotlinx-serializ…
ForteScarlet Oct 15, 2024
c088fdc
Support for webhook
ForteScarlet Oct 16, 2024
1f44b08
Support for webhook
ForteScarlet Oct 16, 2024
09c839f
Support for webhook
ForteScarlet Oct 16, 2024
36867b7
Merge remote-tracking branch 'origin/dev/support-bot-emit-event' into…
ForteScarlet Oct 16, 2024
b119e44
mark TODO
ForteScarlet Oct 16, 2024
ec7f3a3
ED25519 ?
ForteScarlet Oct 16, 2024
3ff23f5
Support for webhook
ForteScarlet Oct 16, 2024
569445a
fix CI
ForteScarlet Oct 16, 2024
adacd56
Apply apiDump and fix api
ForteScarlet Oct 16, 2024
591513f
fix dead-loop
ForteScarlet Oct 16, 2024
871865e
Merge pull request #223 from simple-robot/dev/support-bot-emit-event
ForteScarlet Oct 16, 2024
5de8fbf
调整 Bot.emitEvent,移除回调、增加返回值
ForteScarlet Oct 17, 2024
0f41613
Merge pull request #225 from simple-robot/dev/EmitResult
ForteScarlet Oct 17, 2024
1d69a4e
optimize: 更安全的 Signal.Dispatch 序列化方案
ForteScarlet Oct 17, 2024
4b14314
fix api check
ForteScarlet Oct 17, 2024
4afbb08
Merge pull request #226 from simple-robot/dev/safer-dispatch-serializ…
ForteScarlet Oct 17, 2024
fdb9596
Samples
ForteScarlet Oct 17, 2024
22770da
fix build
ForteScarlet Oct 17, 2024
244ca7d
Merge pull request #227 from simple-robot/dev/samples-for-webhook
ForteScarlet Oct 17, 2024
83d0bcf
Update CI config
ForteScarlet Oct 17, 2024
ba66b63
Update simbot from 4.6.0 to 4.6.1
ForteScarlet Oct 17, 2024
d8161b1
Merge pull request #228 from simple-robot/dev/update-simbot
ForteScarlet Oct 17, 2024
7464169
more tests
ForteScarlet Oct 17, 2024
e0b25bf
release: v4.1.0
ForteScarlet Oct 17, 2024
9222d02
release: v4.1.0
ForteScarlet Oct 17, 2024
7614dbc
Migration of ed25519 library and release: v4.1.0
ForteScarlet Oct 17, 2024
ef3c24c
release: v4.1.0
ForteScarlet Oct 17, 2024
92ffb86
fix test and release: v4.1.0
ForteScarlet Oct 17, 2024
09c2986
fix test and release: v4.1.0
ForteScarlet Oct 17, 2024
81bfbf5
fix build, remove target watchosX64 and release: v4.1.0
ForteScarlet Oct 17, 2024
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/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ jobs:
- name: Run all tests
run: gradle assemble allTests --stacktrace --warning-mode all

- name: Upload test reports
uses: actions/upload-artifact@v4
if: always()
with:
name: test-reports-${{ runner.os }}
path: '**/build/reports/tests'
retention-days: 7

publish-releases:
name: Publish releases
needs: run-test
Expand Down Expand Up @@ -82,6 +90,17 @@ jobs:
steps:
# 检出仓库代码
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: ${{ env.JAVA_DISTRIBUTION }}
java-version: ${{ env.JAVA_VERSION }}
cache: 'gradle'

- name: Publish releases
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: ${{ env.GRADLE_VERSION }}
arguments: createChangelog

# Create gitHub release
- name: Create Github Release
Expand Down
7 changes: 5 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,17 @@ idea {
}
}


apiValidation {
ignoredPackages.add("*.internal.*")

this.ignoredProjects.addAll(
listOf(
"api-reader",
"intents-processor"
"intents-processor",
"dispatch-serializer-processor",
"webhook-server-ktor",
"webhook-server-spring",
"webhook-server-spring-webflux",
),
)

Expand Down
2 changes: 2 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ val kotlinVersion: String = libs.versions.kotlin.get()
dependencies {
implementation(kotlin("gradle-plugin", kotlinVersion))
implementation(kotlin("serialization", kotlinVersion))
// for plugin.spring
implementation(kotlin("allopen", kotlinVersion))
implementation(libs.bundles.dokka)

// see https://github.com/gradle-nexus/publish-plugin
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/P.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ object P {
override val homepage: String get() = HOMEPAGE


const val VERSION = "4.0.2"
const val NEXT_VERSION = "4.0.3"
const val VERSION = "4.1.0"
const val NEXT_VERSION = "4.1.1"

override val snapshotVersion = "$NEXT_VERSION-SNAPSHOT"
override val version = if (isSnapshot()) snapshotVersion else VERSION
Expand Down
13 changes: 6 additions & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
[versions]
kotlin = "2.0.10"
kotlin = "2.0.20"
kotlinx-coroutines = "1.9.0"
kotlinx-serialization = "1.7.1"
kotlinx-serialization = "1.7.3"
kotlinx-datetime = "0.6.1"
dokka = "1.9.20"
ktor = "2.3.12"
openjdk-jmh = "1.37"
log4j = "2.23.1"
log4j = "2.24.1"
# simbot
simbot = "4.6.0"
suspendTransform = "0.9.0"
simbot = "4.6.1"
suspendTransform = "2.0.20-0.9.3"
gradleCommon = "0.6.0"
# ksp
ksp = "2.0.10-1.0.24"
ksp = "2.0.20-1.0.25"
# https://square.github.io/kotlinpoet/
kotlinPoet = "1.18.1"
# https://detekt.dev/docs/intro
Expand Down
4 changes: 2 additions & 2 deletions internal-processors/api-reader/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ repositories {
}

kotlin {
jvmToolchain(11)
jvmToolchain(JVMConstants.KT_JVM_TARGET_VALUE)
compilerOptions {
javaParameters = true
jvmTarget.set(JvmTarget.JVM_11)
jvmTarget.set(JvmTarget.fromTarget(JVMConstants.KT_JVM_TARGET_VALUE.toString()))
}
}

Expand Down
47 changes: 47 additions & 0 deletions internal-processors/dispatch-serializer-processor/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2024. ForteScarlet.
*
* This file is part of simbot-component-qq-guild.
*
* simbot-component-qq-guild is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* simbot-component-qq-guild is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with simbot-component-qq-guild.
* If not, see <https://www.gnu.org/licenses/>.
*/

import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
kotlin("jvm")
}

repositories {
mavenCentral()
}

kotlin {
jvmToolchain(JVMConstants.KT_JVM_TARGET_VALUE)
compilerOptions {
javaParameters = true
jvmTarget.set(JvmTarget.fromTarget(JVMConstants.KT_JVM_TARGET_VALUE.toString()))
}
}

configJavaCompileWithModule()

dependencies {
api(libs.ksp)
api(libs.kotlinPoet.ksp)
testImplementation(kotlin("test-junit5"))
}

tasks.getByName<Test>("test") {
useJUnitPlatform()
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
/*
* Copyright (c) 2024. ForteScarlet.
*
* This file is part of simbot-component-qq-guild.
*
* simbot-component-qq-guild is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* simbot-component-qq-guild is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with simbot-component-qq-guild.
* If not, see <https://www.gnu.org/licenses/>.
*/

package qg.internal.processors.dispatcherserializer

import com.google.devtools.ksp.getClassDeclarationByName
import com.google.devtools.ksp.isAbstract
import com.google.devtools.ksp.processing.Resolver
import com.google.devtools.ksp.processing.SymbolProcessor
import com.google.devtools.ksp.processing.SymbolProcessorEnvironment
import com.google.devtools.ksp.symbol.KSAnnotated
import com.google.devtools.ksp.symbol.KSClassDeclaration
import com.google.devtools.ksp.symbol.KSFile
import com.google.devtools.ksp.symbol.Modifier
import com.squareup.kotlinpoet.*
import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy
import com.squareup.kotlinpoet.ksp.toClassName
import com.squareup.kotlinpoet.ksp.writeTo
import java.time.Instant
import java.time.ZoneOffset

private const val SIGNAL_DISPATCH_PKG = "love.forte.simbot.qguild.event"
private const val SIGNAL_DISPATCH_SIMPLE_NAME = "Signal.Dispatch"
private const val SIGNAL_DISPATCH_NAME = "$SIGNAL_DISPATCH_PKG.$SIGNAL_DISPATCH_SIMPLE_NAME"

/**
*
* @author ForteScarlet
*/
internal class DispatchSerializerProcessor(
private val environment: SymbolProcessorEnvironment,
) : SymbolProcessor {
private data class SerializableDispatch(
val declaration: KSClassDeclaration,
val typeName: String
)

private lateinit var signalDispatchDeclaration: KSClassDeclaration

private val dispatchSerializableDeclarations = sortedSetOf<SerializableDispatch>(
Comparator.comparing { it.typeName }
)

override fun process(resolver: Resolver): List<KSAnnotated> {
signalDispatchDeclaration = resolver.getClassDeclarationByName(SIGNAL_DISPATCH_NAME)
?: error("Cannot find class declaration $SIGNAL_DISPATCH_NAME")

// find all subtypes,
resolver.getAllFiles()
.flatMap { it.declarations }
.filterIsInstance<KSClassDeclaration>()
.filter {
signalDispatchDeclaration.asStarProjectedType().isAssignableFrom(it.asStarProjectedType())
}
// not abstract
.filter {
!it.isAbstract() && !it.modifiers.contains(Modifier.SEALED)
}
// marked @kotlinx.serialization.Serializable
.filter {
it.annotations.any { anno ->
with(anno.annotationType.resolve().declaration) {
packageName.asString() == "kotlinx.serialization" &&
simpleName.asString() == "Serializable"
}
}
}
.mapNotNull {
// find @love.forte.simbot.qguild.event.DispatchTypeName
val typeNameAnnotation = it.annotations.find { anno ->
with(anno.annotationType.resolve().declaration) {
packageName.asString() == "love.forte.simbot.qguild.event" &&
simpleName.asString() == "DispatchTypeName"
}
} ?: return@mapNotNull null

val argument = typeNameAnnotation.arguments.find { a -> a.name?.asString() == "value" }
?: return@mapNotNull null

val typeName = argument.value as String

SerializableDispatch(it, typeName)
}
.toCollection(dispatchSerializableDeclarations)

return emptyList()
}

override fun finish() {
genResolver()
}

private fun genResolver() {
val orgFiles = mutableListOf<KSFile>()
signalDispatchDeclaration.containingFile?.also(orgFiles::add)

val fileSpecBuilder = FileSpec.builder("love.forte.simbot.qguild.event", "SignalDispatchResolvers.generated")

val funBuilder = FunSpec.builder("resolveDispatchSerializer").apply {
addAnnotation(ClassName("love.forte.simbot.qguild", "Generated"))
addParameter("eventName", String::class)
returns(
ClassName("kotlinx.serialization", "KSerializer")
.parameterizedBy(
WildcardTypeName
.producerOf(
ClassName(SIGNAL_DISPATCH_PKG, SIGNAL_DISPATCH_SIMPLE_NAME)
)
)
.copy(nullable = true)
)

addCode(
CodeBlock.builder().apply {
beginControlFlow("return when(eventName)")
// "" -> Type.serializer()
for (dispatchSerializableDeclaration in dispatchSerializableDeclarations) {
dispatchSerializableDeclaration.declaration.containingFile?.also(orgFiles::add)

addStatement(
"%S -> %T.serializer()",
dispatchSerializableDeclaration.typeName,
dispatchSerializableDeclaration.declaration.toClassName()
)
}
addStatement("else -> null")
endControlFlow()
}.build()
)

addKdoc(
CodeBlock.builder().apply {
addStatement("| event name | target |")
addStatement("| --- | --- |")
for (dispatchSerializableDeclaration in dispatchSerializableDeclarations) {
addStatement(
"| `%S` | [%T] |",
dispatchSerializableDeclaration.typeName,
dispatchSerializableDeclaration.declaration.toClassName()
)
}
addStatement("")
addStatement("@since 4.1.0")
}.build()
)
}

fileSpecBuilder.addFileComment("Auto generated at ${Instant.now().atOffset(ZoneOffset.ofHours(8))}")
fileSpecBuilder.addFunction(funBuilder.build())

fileSpecBuilder.build().writeTo(
environment.codeGenerator,
aggregating = true,
originatingKSFiles = orgFiles
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2024. ForteScarlet.
*
* This file is part of simbot-component-qq-guild.
*
* simbot-component-qq-guild is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* simbot-component-qq-guild is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with simbot-component-qq-guild.
* If not, see <https://www.gnu.org/licenses/>.
*/

package qg.internal.processors.dispatcherserializer

import com.google.devtools.ksp.processing.SymbolProcessor
import com.google.devtools.ksp.processing.SymbolProcessorEnvironment
import com.google.devtools.ksp.processing.SymbolProcessorProvider

/**
*
* @author ForteScarlet
*/
class DispatchSerializerProcessorProvider : SymbolProcessorProvider {
override fun create(environment: SymbolProcessorEnvironment): SymbolProcessor =
DispatchSerializerProcessor(environment)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
qg.internal.processors.dispatcherserializer.DispatchSerializerProcessorProvider
4 changes: 2 additions & 2 deletions internal-processors/intents-processor/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ repositories {
}

kotlin {
jvmToolchain(11)
jvmToolchain(JVMConstants.KT_JVM_TARGET_VALUE)
compilerOptions {
javaParameters = true
jvmTarget.set(JvmTarget.JVM_11)
jvmTarget.set(JvmTarget.fromTarget(JVMConstants.KT_JVM_TARGET_VALUE.toString()))
}
}

Expand Down
Loading
Loading