mirror of
https://github.com/Noratrieb/does-it-build.git
synced 2026-01-14 10:25:01 +01:00
Store more metadata
And other various improvements
This commit is contained in:
parent
f6fac25c6f
commit
7f1702bc28
11 changed files with 75 additions and 55 deletions
14
src/build.rs
14
src/build.rs
|
|
@ -2,7 +2,7 @@ use std::{
|
|||
fmt::{Debug, Display},
|
||||
num::NonZeroUsize,
|
||||
path::Path,
|
||||
time::Duration,
|
||||
time::{Duration, Instant, SystemTime},
|
||||
};
|
||||
|
||||
use color_eyre::{
|
||||
|
|
@ -242,6 +242,8 @@ async fn build_single_target(db: &Db, nightly: &str, target: &str, mode: BuildMo
|
|||
|
||||
let tmpdir = tempfile::tempdir().wrap_err("creating temporary directory")?;
|
||||
|
||||
let start_time = Instant::now();
|
||||
|
||||
let result = build_target(
|
||||
tmpdir.path(),
|
||||
&Toolchain::from_nightly(nightly),
|
||||
|
|
@ -258,6 +260,16 @@ async fn build_single_target(db: &Db, nightly: &str, target: &str, mode: BuildMo
|
|||
stderr: result.stderr,
|
||||
mode,
|
||||
rustflags: result.rustflags,
|
||||
build_date: Some(
|
||||
SystemTime::now()
|
||||
.duration_since(SystemTime::UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_millis()
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
),
|
||||
does_it_build_version: Some(crate::VERSION_SHORT.into()),
|
||||
build_duration_ms: Some(start_time.elapsed().as_millis().try_into().unwrap()),
|
||||
})
|
||||
.await?;
|
||||
|
||||
|
|
|
|||
11
src/db.rs
11
src/db.rs
|
|
@ -49,6 +49,9 @@ pub struct FullBuildInfo {
|
|||
pub stderr: String,
|
||||
pub mode: BuildMode,
|
||||
pub rustflags: Option<String>,
|
||||
pub build_date: Option<i64>,
|
||||
pub does_it_build_version: Option<String>,
|
||||
pub build_duration_ms: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Copy, sqlx::Type, Serialize, Deserialize)]
|
||||
|
|
@ -107,7 +110,8 @@ impl Db {
|
|||
|
||||
pub async fn insert(&self, info: FullBuildInfo) -> Result<()> {
|
||||
sqlx::query(
|
||||
"INSERT INTO build_info (nightly, target, status, stderr, mode, rustflags) VALUES (?, ?, ?, ?, ?, ?);",
|
||||
"INSERT INTO build_info (nightly, target, status, stderr, mode, rustflags, build_date, does_it_build_version, build_duration_ms) \
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);",
|
||||
)
|
||||
.bind(info.nightly)
|
||||
.bind(info.target)
|
||||
|
|
@ -115,6 +119,9 @@ impl Db {
|
|||
.bind(info.stderr)
|
||||
.bind(info.mode)
|
||||
.bind(info.rustflags)
|
||||
.bind(info.build_date)
|
||||
.bind(info.does_it_build_version)
|
||||
.bind(info.build_duration_ms)
|
||||
.execute(&self.conn)
|
||||
.await
|
||||
.wrap_err("inserting build info into database")?;
|
||||
|
|
@ -214,7 +221,7 @@ impl Db {
|
|||
mode: BuildMode,
|
||||
) -> Result<Option<FullBuildInfo>> {
|
||||
let result = sqlx::query_as::<_, FullBuildInfo>(
|
||||
"SELECT nightly, target, status, stderr, mode, rustflags FROM build_info
|
||||
"SELECT nightly, target, status, stderr, mode, rustflags, build_date, does_it_build_version, build_duration_ms FROM build_info
|
||||
WHERE nightly = ? AND target = ? AND mode = ?",
|
||||
)
|
||||
.bind(nightly)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use db::Db;
|
|||
use tracing_subscriber::EnvFilter;
|
||||
|
||||
const VERSION: &str = env!("GIT_COMMIT");
|
||||
const VERSION_SHORT: &str = env!("GIT_COMMIT_SHORT");
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
|
|
|
|||
16
src/web.rs
16
src/web.rs
|
|
@ -53,6 +53,9 @@ async fn web_build(State(state): State<AppState>, Query(query): Query<BuildQuery
|
|||
rustflags: Option<String>,
|
||||
version: &'static str,
|
||||
status: Status,
|
||||
build_date: Option<String>,
|
||||
build_duration_s: Option<f32>,
|
||||
does_it_build_version: Option<String>,
|
||||
}
|
||||
|
||||
match state
|
||||
|
|
@ -73,6 +76,19 @@ async fn web_build(State(state): State<AppState>, Query(query): Query<BuildQuery
|
|||
rustflags: build.rustflags,
|
||||
version: crate::VERSION,
|
||||
status: build.status,
|
||||
build_date: build.build_date.map(|build_date| {
|
||||
time::OffsetDateTime::from_unix_timestamp_nanos(build_date as i128 * 1000000)
|
||||
.map(|build_date| {
|
||||
build_date
|
||||
.format(&time::format_description::well_known::Rfc3339)
|
||||
.unwrap()
|
||||
})
|
||||
.unwrap()
|
||||
}),
|
||||
build_duration_s: build
|
||||
.build_duration_ms
|
||||
.map(|build_duration_ms| (build_duration_ms as f32) / 1000.0),
|
||||
does_it_build_version: build.does_it_build_version,
|
||||
};
|
||||
Html(page.render().unwrap()).into_response()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue