-
Notifications
You must be signed in to change notification settings - Fork 45
Unittest proto: First iteration #590
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
Merged
+202
−5
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "mcpServers": { | ||
| "youtrack": { | ||
| "type": "http", | ||
| "url": "https://youtrack.jetbrains.com/mcp", | ||
| "headers": { | ||
| "Authorization": "Bearer ${YOUTRACK_TOKEN}" | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
gradle-conventions/src/main/kotlin/util/tasks/protobufUnittestProtos.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| /* | ||
| * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. | ||
| */ | ||
|
|
||
| package util.tasks | ||
|
|
||
| import org.gradle.api.Project | ||
| import org.gradle.api.tasks.Copy | ||
| import org.gradle.kotlin.dsl.accessors.runtime.addExternalModuleDependencyTo | ||
| import org.gradle.kotlin.dsl.dependencies | ||
| import org.gradle.kotlin.dsl.register | ||
| import util.other.libs | ||
|
|
||
| private const val PROTOBUF_SOURCE_ARCHIVE_CONFIGURATION = "protobufSourceArchive" | ||
| private const val EXTRACT_UNITTEST_PROTOS_TASK = "extractUnittestProtos" | ||
| private const val EXTRACT_UNITTEST_PROTO_IMPORTS_TASK = "extractUnittestProtoImports" | ||
|
|
||
| fun Project.setupProtobufUnittestProtos() { | ||
| val protobufVersion = libs.versions.protobuf.asProvider().get().substringAfter(".") | ||
|
|
||
| // Ivy repository for GitHub releases (source archive has no platform classifier) | ||
| repositories.ivy { | ||
| name = "github-source-archive" | ||
| url = uri("https://github.com") | ||
|
|
||
| patternLayout { | ||
| // https://github.com/protocolbuffers/protobuf/releases/download/v31.1/protobuf-31.1.zip | ||
| artifact("[organisation]/[module]/releases/download/v[revision]/[artifact]-[revision].[ext]") | ||
| } | ||
|
|
||
| metadataSources { artifact() } | ||
| } | ||
|
|
||
| configurations.create(PROTOBUF_SOURCE_ARCHIVE_CONFIGURATION) | ||
|
|
||
| dependencies { | ||
| addExternalModuleDependencyTo( | ||
| dependencyHandler = this, | ||
| targetConfiguration = PROTOBUF_SOURCE_ARCHIVE_CONFIGURATION, | ||
| group = "protocolbuffers", | ||
| name = "protobuf", | ||
| version = protobufVersion, | ||
| classifier = null, | ||
| ext = null, | ||
| configuration = null, | ||
| ) { | ||
| artifact { | ||
| name = "protobuf" | ||
| type = "zip" | ||
| extension = "zip" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| val archivePrefix = "protobuf-$protobufVersion/src/" | ||
|
|
||
| val protosDir = project.layout.buildDirectory.dir("protobuf-unittest-protos") | ||
|
|
||
| // Extract only unittest-related proto files (not well-known types which buf handles natively) | ||
| val extractUnittestProtos = tasks.register<Copy>(EXTRACT_UNITTEST_PROTOS_TASK) { | ||
| val archiveFiles = configurations.getByName(PROTOBUF_SOURCE_ARCHIVE_CONFIGURATION) | ||
|
|
||
| from(archiveFiles.map { zipTree(it) }) | ||
|
|
||
| include( | ||
| "${archivePrefix}google/protobuf/unittest*.proto", | ||
| "${archivePrefix}google/protobuf/map_*unittest*.proto", | ||
| "${archivePrefix}google/protobuf/edition_unittest*.proto", | ||
| ) | ||
|
|
||
| eachFile { | ||
| path = path.removePrefix(archivePrefix) | ||
| } | ||
|
|
||
| includeEmptyDirs = false | ||
| into(protosDir) | ||
| } | ||
|
|
||
| val importsDir = project.layout.buildDirectory.dir("protobuf-unittest-imports") | ||
|
|
||
| // Extract non-WKT import dependencies (e.g., cpp_features.proto) as import-only files | ||
| val extractUnittestProtoImports = tasks.register<Copy>(EXTRACT_UNITTEST_PROTO_IMPORTS_TASK) { | ||
| val archiveFiles = configurations.getByName(PROTOBUF_SOURCE_ARCHIVE_CONFIGURATION) | ||
|
|
||
| from(archiveFiles.map { zipTree(it) }) | ||
|
|
||
| include("${archivePrefix}google/protobuf/cpp_features.proto") | ||
|
|
||
| eachFile { | ||
| path = path.removePrefix(archivePrefix) | ||
| } | ||
|
|
||
| includeEmptyDirs = false | ||
| into(importsDir) | ||
| } | ||
|
|
||
| tasks.matching { it.name == "processMainProtoFiles" }.all { | ||
| dependsOn(extractUnittestProtos) | ||
| } | ||
|
|
||
| tasks.matching { it.name == "processMainProtoFilesImports" }.all { | ||
| dependsOn(extractUnittestProtoImports) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| /* | ||
| * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. | ||
| */ | ||
|
|
||
| @file:OptIn(InternalRpcApi::class) | ||
|
|
||
| import kotlinx.rpc.internal.InternalRpcApi | ||
| import kotlinx.rpc.internal.configureLocalProtocGenDevelopmentDependency | ||
| import kotlinx.rpc.protoc.buf | ||
| import kotlinx.rpc.protoc.generate | ||
| import kotlinx.rpc.protoc.kotlinMultiplatform | ||
| import kotlinx.rpc.protoc.proto | ||
| import kotlinx.rpc.protoc.protoTasks | ||
| import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode | ||
| import util.tasks.setupProtobufUnittestProtos | ||
|
|
||
| plugins { | ||
| alias(libs.plugins.conventions.jvm) | ||
| alias(libs.plugins.kotlinx.rpc) | ||
| } | ||
|
|
||
| kotlin { | ||
| explicitApi = ExplicitApiMode.Disabled | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation(libs.coroutines.core) | ||
| implementation(projects.protobuf.protobufCore) | ||
| } | ||
|
|
||
| setupProtobufUnittestProtos() | ||
| configureLocalProtocGenDevelopmentDependency("Main") | ||
|
|
||
| // Only use the protobuf plugin (no gRPC generation needed for unittest protos) | ||
| // Add the extracted proto files from build directory as a proto source | ||
| sourceSets.main.get().proto { | ||
| srcDir(layout.buildDirectory.dir("protobuf-unittest-protos")) | ||
|
|
||
| // Import non-WKT dependencies (e.g., cpp_features.proto) without generating code for them | ||
| fileImports.from(layout.buildDirectory.dir("protobuf-unittest-imports")) | ||
|
|
||
| // Exclude protos incompatible with buf, exceeding JVM limits, or triggering generator bugs: | ||
| exclude( | ||
| // buf incompatibilities: | ||
| "**/unittest_custom_options.proto", // legacy 'message set wire format' (proto1 feature) | ||
| "**/unittest_lite_edition_2024.proto", // edition "2024" not yet supported | ||
| // JVM method size limit: | ||
| "**/unittest_enormous_descriptor.proto", // generated method exceeds 64KB | ||
| // Generator bugs (incorrect code generation for complex proto2/edition features): | ||
| "**/unittest.proto", // groups, extensions, nested types — many codegen issues | ||
| "**/edition_unittest.proto", // edition 2023 equivalent of unittest.proto | ||
| "**/unittest_optimize_for.proto", // depends on unittest.proto | ||
| "**/unittest_embed_optimize_for.proto", // depends on unittest_optimize_for.proto | ||
| "**/unittest_no_field_presence.proto", // depends on unittest.proto | ||
| "**/unittest_lite_imports_nonlite.proto", // depends on unittest.proto | ||
| "**/map_unittest.proto", // depends on unittest.proto | ||
| ) | ||
|
|
||
| plugins.empty() | ||
| plugin(rpc.protoc.get().plugins.kotlinMultiplatform) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, what can I do with it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically, work with YT from agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can build the whole workflow: find issues -> create reproducer -> try fix -> create PR