Skip to content

Commit

Permalink
Fix CI - Regenerate proto files, and selective msrv-patching (#2159)
Browse files Browse the repository at this point in the history
  • Loading branch information
lalitb authored Sep 30, 2024
1 parent 161929d commit 6ed2b43
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,13 @@ pub struct ExportLogsPartialSuccess {
/// Generated client implementations.
#[cfg(feature = "gen-tonic")]
pub mod logs_service_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// Service that can be used to push logs between one Application instrumented with
Expand Down Expand Up @@ -160,8 +166,7 @@ pub mod logs_service_client {
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
Expand All @@ -184,7 +189,13 @@ pub mod logs_service_client {
/// Generated server implementations.
#[cfg(feature = "gen-tonic")]
pub mod logs_service_server {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
/// Generated trait containing gRPC methods that should be implemented for use with LogsServiceServer.
#[async_trait]
Expand Down Expand Up @@ -325,17 +336,19 @@ pub mod logs_service_server {
}
_ => {
Box::pin(async move {
Ok(
http::Response::builder()
.status(200)
.header("grpc-status", tonic::Code::Unimplemented as i32)
.header(
http::header::CONTENT_TYPE,
tonic::metadata::GRPC_CONTENT_TYPE,
)
.body(empty_body())
.unwrap(),
)
let mut response = http::Response::new(empty_body());
let headers = response.headers_mut();
headers
.insert(
tonic::Status::GRPC_STATUS,
(tonic::Code::Unimplemented as i32).into(),
);
headers
.insert(
http::header::CONTENT_TYPE,
tonic::metadata::GRPC_CONTENT_TYPE,
);
Ok(response)
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,13 @@ pub struct ExportMetricsPartialSuccess {
/// Generated client implementations.
#[cfg(feature = "gen-tonic")]
pub mod metrics_service_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// Service that can be used to push metrics between one Application
Expand Down Expand Up @@ -160,8 +166,7 @@ pub mod metrics_service_client {
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
Expand All @@ -184,7 +189,13 @@ pub mod metrics_service_client {
/// Generated server implementations.
#[cfg(feature = "gen-tonic")]
pub mod metrics_service_server {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
/// Generated trait containing gRPC methods that should be implemented for use with MetricsServiceServer.
#[async_trait]
Expand Down Expand Up @@ -325,17 +336,19 @@ pub mod metrics_service_server {
}
_ => {
Box::pin(async move {
Ok(
http::Response::builder()
.status(200)
.header("grpc-status", tonic::Code::Unimplemented as i32)
.header(
http::header::CONTENT_TYPE,
tonic::metadata::GRPC_CONTENT_TYPE,
)
.body(empty_body())
.unwrap(),
)
let mut response = http::Response::new(empty_body());
let headers = response.headers_mut();
headers
.insert(
tonic::Status::GRPC_STATUS,
(tonic::Code::Unimplemented as i32).into(),
);
headers
.insert(
http::header::CONTENT_TYPE,
tonic::metadata::GRPC_CONTENT_TYPE,
);
Ok(response)
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,13 @@ pub struct ExportTracePartialSuccess {
/// Generated client implementations.
#[cfg(feature = "gen-tonic")]
pub mod trace_service_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// Service that can be used to push spans between one Application instrumented with
Expand Down Expand Up @@ -160,8 +166,7 @@ pub mod trace_service_client {
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
Expand All @@ -184,7 +189,13 @@ pub mod trace_service_client {
/// Generated server implementations.
#[cfg(feature = "gen-tonic")]
pub mod trace_service_server {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
/// Generated trait containing gRPC methods that should be implemented for use with TraceServiceServer.
#[async_trait]
Expand Down Expand Up @@ -325,17 +336,19 @@ pub mod trace_service_server {
}
_ => {
Box::pin(async move {
Ok(
http::Response::builder()
.status(200)
.header("grpc-status", tonic::Code::Unimplemented as i32)
.header(
http::header::CONTENT_TYPE,
tonic::metadata::GRPC_CONTENT_TYPE,
)
.body(empty_body())
.unwrap(),
)
let mut response = http::Response::new(empty_body());
let headers = response.headers_mut();
headers
.insert(
tonic::Status::GRPC_STATUS,
(tonic::Code::Unimplemented as i32).into(),
);
headers
.insert(
http::header::CONTENT_TYPE,
tonic::metadata::GRPC_CONTENT_TYPE,
);
Ok(response)
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-proto/tests/grpc_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ fn build_tonic() {

builder
.out_dir(out_dir.path())
.compile(TONIC_PROTO_FILES, TONIC_INCLUDES)
.compile_protos(TONIC_PROTO_FILES, TONIC_INCLUDES)
.expect("cannot compile protobuf using tonic");

let after_build = build_content_map(out_dir.path(), true);
Expand Down
34 changes: 24 additions & 10 deletions scripts/patch_dependencies.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
#!/bin/bash

function patch_version() {
local latest_version=$(cargo search --limit 1 $1 | head -1 | cut -d'"' -f2)
echo "patching $1 from $latest_version to $2"
cargo update -p $1:$latest_version --precise $2
# Function to compare two version numbers
function version_lt() {
[ "$(printf '%s\n' "$1" "$2" | sort -V | head -n1)" != "$2" ]
}

patch_version cc 1.0.105
patch_version url 2.5.0
patch_version hyper-rustls 0.27.2 # 0.27.3 needs rustc v1.70.0
patch_version tokio-util 0.7.11 # 0.7.12 needs rustc v1.70.0
patch_version tokio-stream 0.1.15 # 0.1.16 needs rustc v1.70.0
patch_version tokio 1.38.0 # 1.39 needs msrv bump to rustc 1.70
# Get the current Rust compiler version
rust_version=$(rustc --version | cut -d' ' -f2)

# Target version (Rust 1.71.1)
target_version="1.71.1"

function patch_version() {
local latest_version=$(cargo search --limit 1 $1 | head -1 | cut -d'"' -f2)
echo "patching $1 from $latest_version to $2"
cargo update -p $1:$latest_version --precise $2
}

patch_version cc 1.0.105
patch_version url 2.5.0
if version_lt "$rust_version" "$target_version"; then
patch_version tonic 0.12.2
patch_version hyper-rustls 0.27.2 # 0.27.3 needs rustc v1.70.0
patch_version tokio-util 0.7.11 # 0.7.12 needs rustc v1.70.0
patch_version tokio-stream 0.1.15 # 0.1.16 needs rustc v1.70.0
patch_version tokio 1.38.0 # 1.39 needs msrv bump to rustc 1.70
fi

0 comments on commit 6ed2b43

Please sign in to comment.