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

feat: Add git sha to the VRL playground header #18500

Merged
merged 2 commits into from
Sep 8, 2023
Merged
Changes from 1 commit
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
16 changes: 14 additions & 2 deletions lib/vector-vrl/web-playground/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
use std::fs::File;
use std::io::Write;
use std::path::{Path, PathBuf};
use std::process::Command;
use std::{env, fs, io};

fn get_vector_toml_path() -> PathBuf {
Expand All @@ -18,6 +19,16 @@
.to_path_buf()
}

fn get_git_hash() -> String {
let output = Command::new("git")
.args(&["rev-parse", "HEAD"])

Check failure on line 24 in lib/vector-vrl/web-playground/build.rs

View workflow job for this annotation

GitHub Actions / Checks

the borrowed expression implements the required traits
.output()
.unwrap();
pront marked this conversation as resolved.
Show resolved Hide resolved
let mut git_hash = String::from_utf8(output.stdout).unwrap();
git_hash.truncate(8);
git_hash
}

fn write_build_constants(manifest: &Manifest, dest_path: &Path) -> io::Result<()> {
let mut output_file = File::create(dest_path)?;
output_file.write_all(
Expand All @@ -26,14 +37,15 @@

let create_const_statement =
|name, value| format!("pub const {}: &str = \"{}\";\n", name, value);

// TODO: For releases, we should use the manifest.package().version().
// https://github.com/vectordotdev/vector/issues/18425
let vector_version_const = create_const_statement("VECTOR_VERSION", "master");
let vector_version_const = create_const_statement("VECTOR_VERSION", get_git_hash());
output_file
.write_all(vector_version_const.as_bytes())
.expect("Failed to write Vector version constant");

let vrl_version = &manifest
let vrl_version = manifest
.dependencies
.get("vrl")
.unwrap()
Expand Down
Loading