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

buf-gradle-plugin build fails on newer Buf CLIs #207

Closed
pkwarren opened this issue Jul 3, 2024 · 2 comments
Closed

buf-gradle-plugin build fails on newer Buf CLIs #207

pkwarren opened this issue Jul 3, 2024 · 2 comments

Comments

@pkwarren
Copy link
Member

pkwarren commented Jul 3, 2024

I attempted to upgrade the plugin from 1.27.1 to 1.34.0 (latest release) and saw these test failuires:

Tests:

  • BreakingWithProtobufGradleTest - normally breaking schema with an ignore
  • BreakingWithWorkspaceTest - normally breaking schema with an ignore

Error:

Execution failed for task ':bufBuild'.
> > arguments: [/Users/pkw/dev/buf-gradle-plugin/build/tmp/test/work/.gradle-test-kit/caches/modules-2/files-2.1/build.buf/buf/1.34.0/fb40b6d9b2d05e0eafcac09f5b443778f3beab81/buf-1.34.0-osx-aarch_64.exe, build, --output, /private/var/folders/zw/8cq3lqwd2cj6fznjw037s7480000gn/T/junit15873435901407493843/build/bufbuild/image.json]
  > exit code: 1
  >    stdout: (empty)
  >    stderr: (below)
  > Failure: cannot have a buf.work.yaml and buf.yaml in the same directory "private/var/folders/zw/8cq3lqwd2cj6fznjw037s7480000gn/T/junit15873435901407493843/build/bufbuild"
  > 

These tests appear to copy a file tree:

buf.yaml
src/main/proto/buf/test/v1/test.proto

into a directory (under build/) consisting of:

buf.work.yaml
buf.yaml
src-main-proto -> ../../src/main/proto

The generated buf.work.yaml contains:

version: v1
directories:
  - src-main-proto

This needs more investigation but ideally for v2 configs we wouldn't need to create any filesystem structure like this during the build. A user should be able to use the plugin entirely from the root buf.yaml file with a config like:

version: v2
modules:
  - path: src/main/proto
lint:
  except:
    - FIELD_NOT_REQUIRED
    - PACKAGE_NO_IMPORT_CYCLE
  disallow_comment_ignores: true
breaking:
  except:
    - EXTENSION_NO_DELETE
    - FIELD_SAME_DEFAULT
  ignore:
    - buf
@pkwarren
Copy link
Member Author

pkwarren commented Jul 3, 2024

Here's the patch I used to run the tests and debug them better:

diff --git a/src/main/kotlin/build/buf/gradle/BufExtension.kt b/src/main/kotlin/build/buf/gradle/BufExtension.kt
index 6c2534a..4774fab 100644
--- a/src/main/kotlin/build/buf/gradle/BufExtension.kt
+++ b/src/main/kotlin/build/buf/gradle/BufExtension.kt
@@ -49,7 +49,7 @@ open class BufExtension {
     /**
      * Specify the version of Buf.
      */
-    var toolVersion = "1.27.1"
+    var toolVersion = "1.34.0"
 
     internal var buildDetails: BuildDetails? = null
 
diff --git a/src/test/kotlin/build/buf/gradle/AbstractBufIntegrationTest.kt b/src/test/kotlin/build/buf/gradle/AbstractBufIntegrationTest.kt
index 921835c..fcaaf6e 100644
--- a/src/test/kotlin/build/buf/gradle/AbstractBufIntegrationTest.kt
+++ b/src/test/kotlin/build/buf/gradle/AbstractBufIntegrationTest.kt
@@ -19,13 +19,14 @@ import org.gradle.language.base.plugins.LifecycleBasePlugin.CHECK_TASK_NAME
 import org.gradle.testkit.runner.GradleRunner
 import org.junit.jupiter.api.BeforeEach
 import org.junit.jupiter.api.TestInfo
+import org.junit.jupiter.api.io.CleanupMode
 import org.junit.jupiter.api.io.TempDir
 import java.io.File
 import java.nio.file.Paths
 import java.util.Locale
 
 abstract class AbstractBufIntegrationTest : IntegrationTest {
-    @TempDir
+    @TempDir(cleanup = CleanupMode.ON_SUCCESS)
     lateinit var projectDir: File
 
     val buildFile
@@ -75,7 +76,7 @@ abstract class AbstractBufIntegrationTest : IntegrationTest {
 
     override fun checkRunner() = gradleRunner().withArguments(CHECK_TASK_NAME)
 
-    fun publishRunner() = gradleRunner().withArguments("publish")
+    fun publishRunner() = gradleRunner().withArguments("publish", "--info")
 
     fun File.replace(
         oldValue: String,

@drice-buf
Copy link
Contributor

Fixed by #213

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

No branches or pull requests

2 participants