Skip to content

Commit

Permalink
build: support build without git (#3309)
Browse files Browse the repository at this point in the history
* build: support build without git

Signed-off-by: tison <[email protected]>

* chore

Signed-off-by: tison <[email protected]>

* address comment

Signed-off-by: tison <[email protected]>

* fix syntax

Signed-off-by: tison <[email protected]>

---------

Signed-off-by: tison <[email protected]>
  • Loading branch information
tisonkun authored Feb 18, 2024
1 parent b889d57 commit 4e04a4e
Show file tree
Hide file tree
Showing 35 changed files with 154 additions and 116 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
# Shares across multiple jobs
shared-key: "check-toml"
- name: Install taplo
run: cargo +stable install taplo-cli --version ^0.8 --locked
run: cargo +stable install taplo-cli --version ^0.9 --locked
- name: Run taplo
run: taplo format --check

Expand Down
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ common-grpc-expr = { path = "src/common/grpc-expr" }
common-macro = { path = "src/common/macro" }
common-mem-prof = { path = "src/common/mem-prof" }
common-meta = { path = "src/common/meta" }
common-pprof = { path = "src/common/pprof" }
common-procedure = { path = "src/common/procedure" }
common-procedure-test = { path = "src/common/procedure-test" }
common-query = { path = "src/common/query" }
Expand Down
4 changes: 2 additions & 2 deletions src/catalog/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ testing = []
[dependencies]
api.workspace = true
arc-swap = "1.0"
arrow-schema.workspace = true
arrow.workspace = true
arrow-schema.workspace = true
async-stream.workspace = true
async-trait = "0.1"
build-data = "0.1"
common-catalog.workspace = true
common-error.workspace = true
common-grpc.workspace = true
Expand All @@ -25,6 +24,7 @@ common-recordbatch.workspace = true
common-runtime.workspace = true
common-telemetry.workspace = true
common-time.workspace = true
common-version.workspace = true
dashmap.workspace = true
datafusion.workspace = true
datatypes.workspace = true
Expand Down
47 changes: 21 additions & 26 deletions src/catalog/src/information_schema/memory_table/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ use datatypes::vectors::{Int64Vector, StringVector};

use crate::information_schema::table_names::*;

const UNKNOWN: &str = "unknown";

/// Find the schema and columns by the table_name, only valid for memory tables.
/// Safety: the user MUST ensure the table schema exists, panic otherwise.
pub fn get_schema_columns(table_name: &str) -> (SchemaRef, Vec<VectorRef>) {
Expand Down Expand Up @@ -72,30 +70,27 @@ pub fn get_schema_columns(table_name: &str) -> (SchemaRef, Vec<VectorRef>) {
],
),

BUILD_INFO => (
string_columns(&[
"GIT_BRANCH",
"GIT_COMMIT",
"GIT_COMMIT_SHORT",
"GIT_DIRTY",
"PKG_VERSION",
]),
vec![
Arc::new(StringVector::from(vec![
build_data::get_git_branch().unwrap_or_else(|_| UNKNOWN.to_string())
])),
Arc::new(StringVector::from(vec![
build_data::get_git_commit().unwrap_or_else(|_| UNKNOWN.to_string())
])),
Arc::new(StringVector::from(vec![
build_data::get_git_commit_short().unwrap_or_else(|_| UNKNOWN.to_string())
])),
Arc::new(StringVector::from(vec![
build_data::get_git_dirty().map_or(UNKNOWN.to_string(), |v| v.to_string())
])),
Arc::new(StringVector::from(vec![option_env!("CARGO_PKG_VERSION")])),
],
),
BUILD_INFO => {
let build_info = common_version::build_info();
(
string_columns(&[
"GIT_BRANCH",
"GIT_COMMIT",
"GIT_COMMIT_SHORT",
"GIT_DIRTY",
"PKG_VERSION",
]),
vec![
Arc::new(StringVector::from(vec![build_info.branch.to_string()])),
Arc::new(StringVector::from(vec![build_info.commit.to_string()])),
Arc::new(StringVector::from(vec![build_info
.commit_short
.to_string()])),
Arc::new(StringVector::from(vec![build_info.dirty.to_string()])),
Arc::new(StringVector::from(vec![build_info.version.to_string()])),
],
)
}

CHARACTER_SETS => (
vec![
Expand Down
2 changes: 1 addition & 1 deletion src/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ prost.workspace = true
rand.workspace = true
session.workspace = true
snafu.workspace = true
tokio-stream = { workspace = true, features = ["net"] }
tokio.workspace = true
tokio-stream = { workspace = true, features = ["net"] }
tonic.workspace = true

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
// limitations under the License.

fn main() {
common_version::setup_git_versions();
common_version::setup_build_info();
}
4 changes: 2 additions & 2 deletions src/common/datasource/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ edition.workspace = true
license.workspace = true

[dependencies]
arrow-schema.workspace = true
arrow.workspace = true
arrow-schema.workspace = true
async-compression = { version = "0.3", features = [
"bzip2",
"gzip",
Expand Down Expand Up @@ -34,8 +34,8 @@ regex = "1.7"
serde.workspace = true
snafu.workspace = true
strum.workspace = true
tokio-util.workspace = true
tokio.workspace = true
tokio-util.workspace = true
url = "2.3"

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion src/common/function/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ license.workspace = true
api.workspace = true
arc-swap = "1.0"
async-trait.workspace = true
build-data = "0.1"
chrono-tz = "0.6"
common-error.workspace = true
common-macro.workspace = true
common-query.workspace = true
common-runtime.workspace = true
common-telemetry.workspace = true
common-time.workspace = true
common-version.workspace = true
datafusion.workspace = true
datatypes.workspace = true
libc = "0.2"
Expand Down
21 changes: 2 additions & 19 deletions src/common/function/src/system/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ use datatypes::vectors::{StringVector, VectorRef};

use crate::function::{Function, FunctionContext};

const DEFAULT_VALUE: &str = "unknown";

/// Generates build information
#[derive(Clone, Debug, Default)]
pub struct BuildFunction;
Expand Down Expand Up @@ -52,15 +50,7 @@ impl Function for BuildFunction {
}

fn eval(&self, _func_ctx: FunctionContext, _columns: &[VectorRef]) -> Result<VectorRef> {
let build_info = format!(
"branch: {}\ncommit: {}\ncommit short: {}\ndirty: {}\nversion: {}",
build_data::get_git_branch().unwrap_or_else(|_| DEFAULT_VALUE.to_string()),
build_data::get_git_commit().unwrap_or_else(|_| DEFAULT_VALUE.to_string()),
build_data::get_git_commit_short().unwrap_or_else(|_| DEFAULT_VALUE.to_string()),
build_data::get_git_dirty().map_or(DEFAULT_VALUE.to_string(), |v| v.to_string()),
env!("CARGO_PKG_VERSION")
);

let build_info = common_version::build_info().to_string();
let v = Arc::new(StringVector::from(vec![build_info]));
Ok(v)
}
Expand All @@ -87,14 +77,7 @@ mod tests {
volatility: Volatility::Immutable
} if valid_types == vec![ConcreteDataType::string_datatype()]
));
let build_info = format!(
"branch: {}\ncommit: {}\ncommit short: {}\ndirty: {}\nversion: {}",
build_data::get_git_branch().unwrap_or_else(|_| DEFAULT_VALUE.to_string()),
build_data::get_git_commit().unwrap_or_else(|_| DEFAULT_VALUE.to_string()),
build_data::get_git_commit_short().unwrap_or_else(|_| DEFAULT_VALUE.to_string()),
build_data::get_git_dirty().map_or(DEFAULT_VALUE.to_string(), |v| v.to_string()),
env!("CARGO_PKG_VERSION")
);
let build_info = common_version::build_info().to_string();
let vector = build.eval(FunctionContext::default(), &[]).unwrap();
let expect: VectorRef = Arc::new(StringVector::from(vec![build_info]));
assert_eq!(expect, vector);
Expand Down
2 changes: 1 addition & 1 deletion src/common/greptimedb-telemetry/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
// limitations under the License.

fn main() {
common_version::setup_git_versions();
common_version::setup_build_info();
}
2 changes: 1 addition & 1 deletion src/common/meta/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ common-wal.workspace = true
datatypes.workspace = true
derive_builder.workspace = true
etcd-client.workspace = true
futures-util.workspace = true
futures.workspace = true
futures-util.workspace = true
hex = { version = "0.4" }
humantime-serde.workspace = true
lazy_static.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion src/common/query/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ common-error.workspace = true
common-macro.workspace = true
common-recordbatch.workspace = true
common-time.workspace = true
datafusion.workspace = true
datafusion-common.workspace = true
datafusion-expr.workspace = true
datafusion.workspace = true
datatypes.workspace = true
serde.workspace = true
snafu.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion src/common/recordbatch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ arc-swap = "1.6"
common-base.workspace = true
common-error.workspace = true
common-macro.workspace = true
datafusion-common.workspace = true
datafusion.workspace = true
datafusion-common.workspace = true
datatypes.workspace = true
futures.workspace = true
paste = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion src/common/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ once_cell.workspace = true
paste.workspace = true
prometheus.workspace = true
snafu.workspace = true
tokio.workspace = true
tokio-metrics = "0.3"
tokio-metrics-collector = "0.2"
tokio-util.workspace = true
tokio.workspace = true

[dev-dependencies]
tokio-test = "0.4"
2 changes: 1 addition & 1 deletion src/common/substrait/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ common-catalog.workspace = true
common-error.workspace = true
common-macro.workspace = true
common-telemetry.workspace = true
datafusion.workspace = true
datafusion-common.workspace = true
datafusion-expr.workspace = true
datafusion-substrait.workspace = true
datafusion.workspace = true
datatypes.workspace = true
futures = "0.3"
promql.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion src/common/time/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ license.workspace = true

[dependencies]
arrow.workspace = true
chrono-tz = "0.8"
chrono.workspace = true
chrono-tz = "0.8"
common-error.workspace = true
common-macro.workspace = true
once_cell.workspace = true
Expand Down
Loading

0 comments on commit 4e04a4e

Please sign in to comment.