From 6bc1e5f9ca3be98dec60c41f3b0a5b445e78b380 Mon Sep 17 00:00:00 2001 From: Julian Figueroa Date: Thu, 29 Jun 2023 18:07:07 -0500 Subject: [PATCH] Fix warning for buf beta graph (#2246) --- private/buf/cmd/buf/imports_test.go | 10 ++++++++++ .../workspace/valid_explicit_deps/buf.work.yaml | 4 ++++ .../workspace/valid_explicit_deps/mod-a/a/v1/a.proto | 9 +++++++++ .../workspace/valid_explicit_deps/mod-a/buf.yaml | 4 ++++ .../workspace/valid_explicit_deps/mod-b/b/v1/b.proto | 5 +++++ .../workspace/valid_explicit_deps/mod-b/buf.yaml | 2 ++ private/bufpkg/bufgraph/builder.go | 1 + 7 files changed, 35 insertions(+) create mode 100644 private/buf/cmd/buf/testdata/imports/success/workspace/valid_explicit_deps/buf.work.yaml create mode 100644 private/buf/cmd/buf/testdata/imports/success/workspace/valid_explicit_deps/mod-a/a/v1/a.proto create mode 100644 private/buf/cmd/buf/testdata/imports/success/workspace/valid_explicit_deps/mod-a/buf.yaml create mode 100644 private/buf/cmd/buf/testdata/imports/success/workspace/valid_explicit_deps/mod-b/b/v1/b.proto create mode 100644 private/buf/cmd/buf/testdata/imports/success/workspace/valid_explicit_deps/mod-b/buf.yaml diff --git a/private/buf/cmd/buf/imports_test.go b/private/buf/cmd/buf/imports_test.go index 4172eef06d..227d6d2e98 100644 --- a/private/buf/cmd/buf/imports_test.go +++ b/private/buf/cmd/buf/imports_test.go @@ -123,6 +123,16 @@ func TestValidImportFromLocalOnlyWorkspaceUnnamedModules(t *testing.T) { ) } +func TestGraphNoWarningsValidImportFromWorkspaceNamedModules(t *testing.T) { + t.Parallel() + testRunStdoutStderr( + t, nil, 0, + "", // no warnings + "beta", "graph", + filepath.Join("testdata", "imports", "success", "workspace", "valid_explicit_deps"), + ) +} + func testRunStderrWithCache(t *testing.T, stdin io.Reader, expectedExitCode int, expectedStderrPartials []string, args ...string) { appcmdtesting.RunCommandExitCodeStderrContains( t, diff --git a/private/buf/cmd/buf/testdata/imports/success/workspace/valid_explicit_deps/buf.work.yaml b/private/buf/cmd/buf/testdata/imports/success/workspace/valid_explicit_deps/buf.work.yaml new file mode 100644 index 0000000000..b6097d12fc --- /dev/null +++ b/private/buf/cmd/buf/testdata/imports/success/workspace/valid_explicit_deps/buf.work.yaml @@ -0,0 +1,4 @@ +version: v1 +directories: + - mod-a + - mod-b diff --git a/private/buf/cmd/buf/testdata/imports/success/workspace/valid_explicit_deps/mod-a/a/v1/a.proto b/private/buf/cmd/buf/testdata/imports/success/workspace/valid_explicit_deps/mod-a/a/v1/a.proto new file mode 100644 index 0000000000..02983d2f94 --- /dev/null +++ b/private/buf/cmd/buf/testdata/imports/success/workspace/valid_explicit_deps/mod-a/a/v1/a.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package a.v1; + +import "b/v1/b.proto"; + +message A { + b.v1.B b = 1; +} diff --git a/private/buf/cmd/buf/testdata/imports/success/workspace/valid_explicit_deps/mod-a/buf.yaml b/private/buf/cmd/buf/testdata/imports/success/workspace/valid_explicit_deps/mod-a/buf.yaml new file mode 100644 index 0000000000..c13d258f2c --- /dev/null +++ b/private/buf/cmd/buf/testdata/imports/success/workspace/valid_explicit_deps/mod-a/buf.yaml @@ -0,0 +1,4 @@ +version: v1 +name: buf.build/foo/mod-a +deps: + - buf.build/foo/mod-b diff --git a/private/buf/cmd/buf/testdata/imports/success/workspace/valid_explicit_deps/mod-b/b/v1/b.proto b/private/buf/cmd/buf/testdata/imports/success/workspace/valid_explicit_deps/mod-b/b/v1/b.proto new file mode 100644 index 0000000000..e6cba8ca87 --- /dev/null +++ b/private/buf/cmd/buf/testdata/imports/success/workspace/valid_explicit_deps/mod-b/b/v1/b.proto @@ -0,0 +1,5 @@ +syntax = "proto3"; + +package b.v1; + +message B {} diff --git a/private/buf/cmd/buf/testdata/imports/success/workspace/valid_explicit_deps/mod-b/buf.yaml b/private/buf/cmd/buf/testdata/imports/success/workspace/valid_explicit_deps/mod-b/buf.yaml new file mode 100644 index 0000000000..e7976dbcbb --- /dev/null +++ b/private/buf/cmd/buf/testdata/imports/success/workspace/valid_explicit_deps/mod-b/buf.yaml @@ -0,0 +1,2 @@ +version: v1 +name: buf.build/foo/mod-b diff --git a/private/bufpkg/bufgraph/builder.go b/private/bufpkg/bufgraph/builder.go index a38d413b2a..c5168102fd 100644 --- a/private/bufpkg/bufgraph/builder.go +++ b/private/bufpkg/bufgraph/builder.go @@ -112,6 +112,7 @@ func (b *builder) buildForModule( ctx, module, bufimagebuild.WithWorkspace(workspace), + bufimagebuild.WithExpectedDirectDependencies(module.DeclaredDirectDependencies()), ) if err != nil { return nil, err