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

Provide an info endpoint #25

Merged
merged 1 commit into from
Dec 11, 2023
Merged
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
23 changes: 23 additions & 0 deletions ci-bench-runner/Cargo.lock

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

3 changes: 3 additions & 0 deletions ci-bench-runner/Cargo.toml
Original file line number Diff line number Diff line change
@@ -31,3 +31,6 @@ uuid = { version = "1.4.1", features = ["v4", "serde"] }
ctor = "0.2.5"
reqwest = { version = "0.11.22", default-features = false, features = ["rustls-tls-webpki-roots"] }
wiremock = "0.5.19"

[build-dependencies]
vergen = { version = "8.2.6", features = ["git", "gitcl"] }
6 changes: 5 additions & 1 deletion ci-bench-runner/build.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
fn main() {
fn main() -> Result<(), Box<dyn std::error::Error>> {
// In some cases if new migrations are added without accompanying Rust src changes
// `cargo build` isn't smart enough to detect the need for recompilation to pick up
// the new embedded migrations. This build script is the recommended workaround.
// See <https://docs.rs/sqlx/latest/sqlx/macro.migrate.html#triggering-recompilation-on-migration-changes>
println!("cargo:rerun-if-changed=migrations");

// Expose git-related information through environment variables at compile-time
vergen::EmitBuilder::builder().all_git().emit()?;
Ok(())
}
10 changes: 10 additions & 0 deletions ci-bench-runner/src/lib.rs
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@ use axum::routing::{get, post};
use axum::{Json, Router};
use bencher_client::json::Jwt;
use serde::Deserialize;
use serde_json::json;
use sqlx::migrate::Migrator;
use sqlx::SqliteConnection;
use tokio::sync::Mutex;
@@ -115,6 +116,7 @@ pub async fn server(
// Set up the axum application
let app = Router::new()
.route("/webhooks/github", post(handle_github_webhook))
.route("/info", get(get_server_info))
.route("/jobs/:id", get(get_job_view))
.route(
"/comparisons/:commits/cachegrind-diff/:scenario",
@@ -131,6 +133,14 @@ pub async fn server(
Ok((server, addr))
}

/// Returns git commit information about the binary that is currently deployed
async fn get_server_info() -> Json<serde_json::Value> {
Json(json!({
"git_commit_sha": env!("VERGEN_GIT_SHA").to_string(),
"git_commit_message": env!("VERGEN_GIT_COMMIT_MESSAGE").to_string(),
}))
}

/// Returns information about the job
async fn get_job_view(
State(state): State<Arc<AppState>>,