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 v2 buf.yaml Generate and Breaking test cases #214

Merged
merged 9 commits into from
Jul 30, 2024

Conversation

drice-buf
Copy link
Contributor

@drice-buf drice-buf commented Jul 26, 2024

Note that BreakingWithProtobufGradleTest/schema_with_multi_directory_workspace is set to use an older Buf version because I have not been able to create a suitable v2 buf.yaml to handle that case correctly.

@drice-buf drice-buf force-pushed the drice/add_buf_v2_tests branch from c109bdc to 96cb31d Compare July 26, 2024 19:45
src/main/kotlin/build/buf/gradle/BreakingTask.kt Outdated Show resolved Hide resolved
"--against",
singleFileFromConfiguration(BUF_BREAKING_CONFIGURATION_NAME),
) {
val args = ArrayList<Any>()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kotlin nit: conventionally one should use mutableListOf<Any>() unless you specifically need an ArrayList.

@drice-buf drice-buf force-pushed the drice/add_buf_v2_tests branch 3 times, most recently from 3c405e1 to 3df659d Compare July 29, 2024 14:39
@drice-buf drice-buf changed the title Add tests exercising v2 buf.yaml syntax Add Breaking tests exercising v2 buf.yaml syntax Jul 29, 2024
@drice-buf drice-buf force-pushed the drice/add_buf_v2_tests branch 6 times, most recently from d4340c5 to baf04c7 Compare July 29, 2024 15:52
@drice-buf drice-buf marked this pull request as ready for review July 29, 2024 16:03
@drice-buf drice-buf force-pushed the drice/add_buf_v2_tests branch from baf04c7 to 6dee0b0 Compare July 29, 2024 16:04
@drice-buf drice-buf changed the title Add Breaking tests exercising v2 buf.yaml syntax Add v2 buf.yaml Generate and Breaking test cases Jul 29, 2024
@drice-buf drice-buf requested a review from jhump July 29, 2024 19:41
val bufYaml = bufYamlGenerator.generate(project.bufConfigFile(), protoDirs)
logger.info("Writing generated buf.yaml:{}\n", bufYaml)
File(bufbuildDir, "buf.yaml").writeText(bufYaml)
if (Version(project.getExtension().toolVersion) < Version("1.32.0")) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we care about Version(project.getExtension().toolVersion) < Version("1.32.0") in more than one place. Could be worth extracting to a constant or helper method of some kind.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -35,6 +36,7 @@ import kotlin.reflect.full.declaredMemberProperties

const val CREATE_SYM_LINKS_TO_MODULES_TASK_NAME = "createSymLinksToModules"
const val WRITE_WORKSPACE_YAML_TASK_NAME = "writeWorkspaceYaml"
const val BUF_CLI_V2_INITIAL_VERSION = "1.32.0"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be internal?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@drice-buf drice-buf force-pushed the drice/add_buf_v2_tests branch from 9293863 to 791f20c Compare July 29, 2024 21:41
andrewparmet
andrewparmet previously approved these changes Jul 29, 2024
@drice-buf drice-buf force-pushed the drice/add_buf_v2_tests branch from 9738cff to 58195cd Compare July 30, 2024 13:47
@drice-buf drice-buf requested a review from andrewparmet July 30, 2024 14:01
@@ -62,7 +62,7 @@ abstract class AbstractBreakingTest : AbstractBufIntegrationTest() {
assertThat(result.output).contains("Cannot configure $BUF_BREAKING_TASK_NAME against latest release and a previous version.")
}

private fun checkBreaking() {
protected fun checkBreaking() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these need to be protected now? I saw a few commits go by with them flip flopping?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They can be private, not sure why my changes were not holding. Should be fixed now.

Comment on lines 32 to 41
protoDirs
.map { dir ->
if (ignores.isEmpty()) {
mapOf("path" to dir)
} else {
mapOf(
"path" to dir,
"breaking" to mapOf("ignore" to ignores.map { "$dir/$it" }),
)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a format change right? Was this the output of running something like gradlew spotlessApply? (If so, maybe we should verify formatting in CI checks -- not an action for this PR, just a comment about a possible future improvement.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a manual change but I can revert to make the PR cleaner

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting is verified in CI.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted

@drice-buf drice-buf merged commit 70c627f into main Jul 30, 2024
8 checks passed
@drice-buf drice-buf deleted the drice/add_buf_v2_tests branch July 30, 2024 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants