Include channel and commit info in the version of pre-release builds (#6819)

This commit is contained in:
Michael Vines 2019-11-10 22:39:13 -07:00 committed by GitHub
parent 5835b3b8eb
commit cfab36cb1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 12 deletions

View File

@ -5,6 +5,24 @@
//! command-line tools to spin up validators and a Rust library //! command-line tools to spin up validators and a Rust library
//! //!
#[macro_export]
macro_rules! version {
() => {
&*format!(
"{}{}",
env!("CARGO_PKG_VERSION"),
if option_env!("CI_TAG").is_none() {
format!(
" [channel={} commit={}]",
option_env!("CHANNEL").unwrap_or("unknown"),
option_env!("CI_COMMIT").unwrap_or("unknown"),
)
} else {
"".to_string()
},
)
};
}
pub mod banking_stage; pub mod banking_stage;
pub mod blob; pub mod blob;
pub mod broadcast_stage; pub mod broadcast_stage;
@ -57,7 +75,6 @@ pub mod streamer;
pub mod tpu; pub mod tpu;
pub mod tvu; pub mod tvu;
pub mod validator; pub mod validator;
pub(crate) mod version;
pub mod weighted_shuffle; pub mod weighted_shuffle;
pub mod window_service; pub mod window_service;

View File

@ -7,7 +7,6 @@ use crate::{
packet::PACKET_DATA_SIZE, packet::PACKET_DATA_SIZE,
storage_stage::StorageState, storage_stage::StorageState,
validator::ValidatorExit, validator::ValidatorExit,
version::VERSION,
}; };
use bincode::serialize; use bincode::serialize;
use jsonrpc_core::{Error, Metadata, Result}; use jsonrpc_core::{Error, Metadata, Result};
@ -922,7 +921,7 @@ impl RpcSol for RpcSolImpl {
fn get_version(&self, _: Self::Metadata) -> Result<RpcVersionInfo> { fn get_version(&self, _: Self::Metadata) -> Result<RpcVersionInfo> {
Ok(RpcVersionInfo { Ok(RpcVersionInfo {
solana_core: VERSION.to_string(), solana_core: crate::version!().to_string(),
}) })
} }
@ -1591,7 +1590,7 @@ pub mod tests {
let expected = json!({ let expected = json!({
"jsonrpc": "2.0", "jsonrpc": "2.0",
"result": { "result": {
"solana-core": VERSION "solana-core": crate::version!().to_string()
}, },
"id": 1 "id": 1
}); });

View File

@ -1 +0,0 @@
pub(crate) const VERSION: &str = env!("CARGO_PKG_VERSION");

View File

@ -18,7 +18,7 @@ fn test_rpc_client() {
assert_eq!( assert_eq!(
client.get_version().unwrap(), client.get_version().unwrap(),
format!("{{\"solana-core\":\"{}\"}}", env!("CARGO_PKG_VERSION")) format!("{{\"solana-core\":\"{}\"}}", solana_core::version!())
); );
assert_eq!(client.get_balance(&bob_pubkey).unwrap(), 0); assert_eq!(client.get_balance(&bob_pubkey).unwrap(), 0);

View File

@ -1,5 +1,5 @@
use bzip2::bufread::BzDecoder; use bzip2::bufread::BzDecoder;
use clap::{crate_description, crate_name, crate_version, value_t, value_t_or_exit, App, Arg}; use clap::{crate_description, crate_name, value_t, value_t_or_exit, App, Arg};
use console::{style, Emoji}; use console::{style, Emoji};
use indicatif::{ProgressBar, ProgressStyle}; use indicatif::{ProgressBar, ProgressStyle};
use log::*; use log::*;
@ -242,7 +242,7 @@ pub fn main() {
&format!("{}-{}", VALIDATOR_PORT_RANGE.0, VALIDATOR_PORT_RANGE.1); &format!("{}-{}", VALIDATOR_PORT_RANGE.0, VALIDATOR_PORT_RANGE.1);
let matches = App::new(crate_name!()).about(crate_description!()) let matches = App::new(crate_name!()).about(crate_description!())
.version(crate_version!()) .version(solana_core::version!())
.arg( .arg(
Arg::with_name("blockstream_unix_socket") Arg::with_name("blockstream_unix_socket")
.long("blockstream") .long("blockstream")
@ -532,11 +532,9 @@ pub fn main() {
.map(|s| Hash::from_str(&s).unwrap()); .map(|s| Hash::from_str(&s).unwrap());
println!( println!(
"{} version {} (branch={}, commit={})", "{} {}",
style(crate_name!()).bold(), style(crate_name!()).bold(),
crate_version!(), solana_core::version!()
option_env!("CI_BRANCH").unwrap_or("unknown"),
option_env!("CI_COMMIT").unwrap_or("unknown")
); );
let _log_redirect = { let _log_redirect = {