-
Notifications
You must be signed in to change notification settings - Fork 300
chore(hermes): Remove git from build, vendor WH & Google protos #2097
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
Merged
Changes from all commits
Commits
Show all changes
4 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 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 |
---|---|---|
|
@@ -5,6 +5,3 @@ | |
src/network/p2p.pb.go | ||
src/network/p2p.proto | ||
tools/ | ||
|
||
# Ignore Wormhole cloned repo | ||
wormhole*/ |
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 |
---|---|---|
@@ -1,58 +1,28 @@ | ||
use std::{ | ||
env, | ||
path::PathBuf, | ||
process::Command, | ||
}; | ||
use std::path::PathBuf; | ||
|
||
/// Custom build script to compile and include the wormhole protobufs into the source. | ||
/// The wormhole protobufs are vendored from the Wormhole git repository at https://github.com/wormhole-foundation/wormhole.git | ||
/// They reference other protobufs from the Google API repository at https://github.com/googleapis/googleapis.git , which are also vendored. | ||
/// Our copies live in `proto/vendor`. | ||
fn main() { | ||
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); | ||
let proto_dir = PathBuf::from("proto/vendor"); | ||
|
||
// Print OUT_DIR for debugging build issues. | ||
println!("OUT_DIR={}", out_dir.display()); | ||
// Tell cargo to recompile if any .proto files change | ||
println!("cargo:rerun-if-changed=proto/"); | ||
|
||
// We'll use git to pull in protobuf dependencies. This trick lets us use the Rust OUT_DIR | ||
// directory as a mini-repo with wormhole and googleapis as remotes, so we can copy out the | ||
// TREEISH paths we want. | ||
let protobuf_setup = r#" | ||
set -e | ||
git init . | ||
git clean -df | ||
git remote add wormhole https://github.com/wormhole-foundation/wormhole.git || true | ||
git remote add googleapis https://github.com/googleapis/googleapis.git || true | ||
git fetch --depth=1 wormhole main | ||
git fetch --depth=1 googleapis master | ||
git reset | ||
rm -rf proto/ | ||
git read-tree --prefix=proto/ -u wormhole/main:proto | ||
git read-tree --prefix=proto/google/api/ -u googleapis/master:google/api | ||
"#; | ||
|
||
// Run each command to prepare the OUT_DIR with the protobuf definitions. We need to make sure | ||
// to change the working directory to OUT_DIR, otherwise git will complain. | ||
let output = Command::new("sh") | ||
.args(["-c", protobuf_setup]) | ||
.current_dir(&out_dir) | ||
.output() | ||
.expect("failed to run protobuf setup commands"); | ||
if !output.status.success() { | ||
panic!( | ||
"failed to setup protobuf definitions: {}", | ||
String::from_utf8_lossy(&output.stderr) | ||
); | ||
} | ||
|
||
// We build the resulting protobuf definitions using Rust's prost_build crate, which generates | ||
// Rust code from the protobuf definitions. | ||
// Build the wormhole and google protobufs using Rust's prost_build crate. | ||
// The generated Rust code is placed in the OUT_DIR (env var set by cargo). | ||
// `network/wormhole.rs` then includes the generated code into the source while compilation is happening. | ||
tonic_build::configure() | ||
.build_server(false) | ||
.compile( | ||
&[ | ||
out_dir.join("proto/spy/v1/spy.proto"), | ||
out_dir.join("proto/gossip/v1/gossip.proto"), | ||
out_dir.join("proto/node/v1/node.proto"), | ||
out_dir.join("proto/publicrpc/v1/publicrpc.proto"), | ||
proto_dir.join("spy/v1/spy.proto"), | ||
proto_dir.join("gossip/v1/gossip.proto"), | ||
proto_dir.join("node/v1/node.proto"), | ||
proto_dir.join("publicrpc/v1/publicrpc.proto"), | ||
], | ||
&[out_dir.join("proto")], | ||
&[proto_dir], | ||
) | ||
.expect("failed to compile protobuf definitions"); | ||
} |
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,36 @@ | ||
## API Protos | ||
|
||
This folder contains the schema of the configuration model for Google's | ||
internal API serving platform, which handles routing, quotas, monitoring, | ||
logging, and the like. | ||
|
||
Google refers to this configuration colloquially as the "service config", | ||
and the `service.proto` file in this directory is the entry point for | ||
understanding these. | ||
|
||
## Using these protos | ||
|
||
To be honest, we probably open sourced way too much of this (basically by | ||
accident). There are a couple files in here you are most likely to be | ||
Comment on lines
+13
to
+14
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. lmaoo |
||
interested in: `http.proto`, `documentation.proto`, `auth.proto`, and | ||
`annotations.proto`. | ||
|
||
### HTTP and REST | ||
|
||
The `http.proto` file contains the `Http` message (which then is wrapped | ||
in an annotation in `annotations.proto`), which provides a specification | ||
for REST endpoints and verbs (`GET`, `POST`, etc.) on RPC methods. | ||
We recommend use of this annotation for describing the relationship | ||
between RPCs and REST endpoints. | ||
|
||
### Documentation | ||
|
||
The `documentation.proto` file contains a `Documentation` message which | ||
provides a mechanism to fully describe an API, allowing a tool to build | ||
structured documentation artifacts. | ||
|
||
### Authentication | ||
|
||
The `auth.proto` file contains descriptions of both authentication rules | ||
and authentication providers, allowing you to describe what your services | ||
expect and accept from clients. |
31 changes: 31 additions & 0 deletions
31
apps/hermes/server/proto/vendor/google/api/annotations.proto
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,31 @@ | ||
// Copyright 2024 Google LLC | ||
// | ||
// 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. | ||
|
||
syntax = "proto3"; | ||
|
||
package google.api; | ||
|
||
import "google/api/http.proto"; | ||
import "google/protobuf/descriptor.proto"; | ||
|
||
option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; | ||
option java_multiple_files = true; | ||
option java_outer_classname = "AnnotationsProto"; | ||
option java_package = "com.google.api"; | ||
option objc_class_prefix = "GAPI"; | ||
|
||
extend google.protobuf.MethodOptions { | ||
// See `HttpRule`. | ||
HttpRule http = 72295728; | ||
} |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.