-
Notifications
You must be signed in to change notification settings - Fork 304
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
Support embedded go_proto_library #5567
Closed
Closed
Changes from all commits
Commits
Show all changes
3 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
This file contains 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 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
50 changes: 50 additions & 0 deletions
50
aspect/testing/tests/src/com/google/idea/blaze/aspect/go/go_proto_library/BUILD
This file contains 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,50 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
load("@rules_proto//proto:defs.bzl", "proto_library") | ||
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") | ||
load( | ||
"//aspect/testing/rules:intellij_aspect_test_fixture.bzl", | ||
"intellij_aspect_test_fixture", | ||
) | ||
|
||
proto_library( | ||
name = "fooproto_proto", | ||
srcs = ["fooserver.proto"], | ||
visibility = ["//visibility:public"], | ||
deps = ["@com_google_protobuf//:empty_proto"], | ||
) | ||
|
||
go_proto_library( | ||
name = "fooproto_go_proto", | ||
compilers = ["@io_bazel_rules_go//proto:go_grpc"], | ||
importpath = "github.com/bazelbuild/intellij/examples/go/with_proto/proto", | ||
proto = ":fooproto_proto", | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
go_library( | ||
name = "proto", | ||
srcs = ["translators.go"], | ||
embed = [":fooproto_go_proto"], | ||
importpath = "github.com/bazelbuild/intellij/examples/go/with_proto/proto", | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
intellij_aspect_test_fixture( | ||
name = "simple_fixture", | ||
deps = [":proto"], | ||
) | ||
|
||
java_test( | ||
name = "GoTest", | ||
srcs = ["GoTest.java"], | ||
data = [":simple_fixture"], | ||
deps = [ | ||
"//aspect/testing:BazelIntellijAspectTest", | ||
"//aspect/testing:guava", | ||
"//aspect/testing/rules:IntellijAspectTest", | ||
"//aspect/testing/rules:intellij_aspect_test_fixture_java_proto", | ||
"//intellij_platform_sdk:test_libs", | ||
"//proto:intellij_ide_info_java_proto", | ||
"@junit//jar", | ||
], | ||
) |
45 changes: 45 additions & 0 deletions
45
aspect/testing/tests/src/com/google/idea/blaze/aspect/go/go_proto_library/GoTest.java
This file contains 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,45 @@ | ||
/* | ||
* Copyright 2017 The Bazel Authors. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.google.idea.blaze.aspect.go.go_proto_library; | ||
|
||
import static com.google.common.truth.Truth.assertThat; | ||
|
||
import com.google.devtools.intellij.IntellijAspectTestFixtureOuterClass.IntellijAspectTestFixture; | ||
import com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo; | ||
import com.google.idea.blaze.BazelIntellijAspectTest; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.JUnit4; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
|
||
/** Tests go_proto_library */ | ||
@RunWith(JUnit4.class) | ||
public class GoTest extends BazelIntellijAspectTest { | ||
@Test | ||
public void testGoTest() throws Exception { | ||
IntellijAspectTestFixture testFixture = loadTestFixture(":simple_fixture"); | ||
TargetIdeInfo target = findTarget(testFixture, ":proto"); | ||
assertThat(target.getKindString()).isEqualTo("go_library"); | ||
assertThat(relativePathsForArtifacts(target.getGoIdeInfo().getSourcesList())) | ||
.contains(testRelative("translators.go")); | ||
assertThat(relativePathsForArtifacts(target.getGoIdeInfo().getSourcesList())) | ||
.contains(testRelative("fooproto_go_proto_/github.com/bazelbuild/intellij/examples/go/with_proto/proto/fooserver.pb.go")); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
aspect/testing/tests/src/com/google/idea/blaze/aspect/go/go_proto_library/fooserver.proto
This file contains 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,27 @@ | ||
syntax = "proto3"; | ||
|
||
package fooproto; | ||
|
||
import "google/protobuf/empty.proto"; | ||
|
||
service FooService { | ||
rpc SayHello (HelloRequest) returns (HelloReply) {} | ||
// This function exists to validate that the well known types (such as google.protobuf.Empty) | ||
// are picked up by the plugin. | ||
// To validate that they are working, navigate to "External Libraries" > "Go Libraries" > | ||
// "github.com/bazelbuild/intellij/examples/go/with_proto/proto/fooserver.pb.go", | ||
// and validate that "google.golang.org/protobuf/types/known/emptypb" is resolved correctly. | ||
rpc EmptyFunction (google.protobuf.Empty) returns (google.protobuf.Empty); | ||
} | ||
|
||
message HelloRequest { | ||
optional string name = 1; | ||
} | ||
|
||
message HelloReply { | ||
optional string message = 1; | ||
} | ||
|
||
message Time { | ||
string value = 1; | ||
} |
4 changes: 4 additions & 0 deletions
4
aspect/testing/tests/src/com/google/idea/blaze/aspect/go/go_proto_library/setup.bzl
This file contains 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,4 @@ | ||
def setup_tests(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure what this file is for, it doesn't seem to be referenced anywhere. |
||
""" | ||
Setup the dependencies for testing the rules. | ||
""" |
1 change: 1 addition & 0 deletions
1
aspect/testing/tests/src/com/google/idea/blaze/aspect/go/go_proto_library/simple.go
This file contains 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 @@ | ||
package simple | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same with this file, it doesn't seem to be referenced. |
11 changes: 11 additions & 0 deletions
11
aspect/testing/tests/src/com/google/idea/blaze/aspect/go/go_proto_library/translators.go
This file contains 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 @@ | ||
package proto | ||
|
||
import ( | ||
"time" | ||
) | ||
|
||
// Time translation functions. | ||
|
||
func ToProtoTime(t time.Time) Time { | ||
return Time{Value: t.Format(time.RFC3339Nano)} | ||
} |
This file contains 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 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 |
---|---|---|
|
@@ -21,3 +21,7 @@ message HelloRequest { | |
message HelloReply { | ||
optional string message = 1; | ||
} | ||
|
||
message Time { | ||
string value = 1; | ||
} |
This file contains 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 @@ | ||
package proto | ||
|
||
import ( | ||
"time" | ||
) | ||
|
||
// Time translation functions. | ||
|
||
func ToProtoTime(t time.Time) Time { | ||
return Time{Value: t.Format(time.RFC3339Nano)} | ||
} |
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.
This rule seems redundant so deleting here. I had to delete this otherwise I get errors:
See CI build failure: https://buildkite.com/bazel/intellij-plugin-aspect/builds/20467
Here are the duplicated rules:
intellij/WORKSPACE
Lines 320 to 336 in ae7424b