Skip to content
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

fix: Benchy test without git code cannot output result #1688

Merged
merged 1 commit into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion fil-proofs-tooling/Cargo.toml
lovel8 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ bellperson = "0.24.0"
rand = "0.8"
tempfile = "3.0.8"
cpu-time = "1.0.0"
git2 = "0.14.2"
heim = { git = "https://github.com/heim-rs/heim", rev = "b292f15", features = ["host", "memory", "cpu"] }
async-std = "1.6"
blake2s_simd = "1.0.0"
Expand All @@ -49,6 +48,9 @@ humansize = "1.1.0"
blstrs = "0.6.0"
time = "0.3.9"

[build-dependencies]
vergen = { version = "8.1.1", features = ["build", "git", "gitcl"] }

[features]
default = ["opencl", "measurements"]
cuda = [
Expand Down
8 changes: 8 additions & 0 deletions fil-proofs-tooling/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use std::error::Error;
use vergen::EmitBuilder;

fn main() -> Result<(), Box<dyn Error>> {
// Emits the `VERGEN_GIT_SHA` and `VERGEN_GIT_COMMIT_TIMESTAMP` environment variables.
EmitBuilder::builder().all_git().emit()?;
Ok(())
}
20 changes: 6 additions & 14 deletions fil-proofs-tooling/src/metadata.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use anyhow::{anyhow, Result};
use chrono::{DateTime, TimeZone, Utc};
use git2::Repository;
use chrono::{DateTime, Utc};
use serde::Serialize;

/// Captures metadata about the current setup.
Expand Down Expand Up @@ -32,19 +31,12 @@ pub struct GitMetadata {

impl GitMetadata {
pub fn new() -> Result<Self> {
let repo_path = if let Ok(mdir) = std::env::var("CARGO_MANIFEST_DIR") {
std::path::Path::new(&mdir).into()
} else {
std::env::current_dir()?
};
let repo = Repository::discover(repo_path)?;
let head = repo.head()?;
let commit = head.peel_to_commit()?;
// Unwrap is OK as the given seconds won't be out of range.
let date = Utc.timestamp_opt(commit.time().seconds(), 0).unwrap();

// Unwrap is OK as vergen returns a valid timestamp.
let date = env!("VERGEN_GIT_COMMIT_TIMESTAMP")
.parse::<DateTime<Utc>>()
.expect("VERGEN_GIT_COMMIT_TIMESTAMP error");
Ok(GitMetadata {
hash: commit.id().to_string(),
hash: env!("VERGEN_GIT_SHA").to_string(),
date,
})
}
Expand Down