mirror of
https://github.com/Noratrieb/does-it-build.git
synced 2026-01-14 18:35: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
6
build.rs
6
build.rs
|
|
@ -12,6 +12,12 @@ fn main() {
|
||||||
};
|
};
|
||||||
|
|
||||||
println!("cargo:rustc-env=GIT_COMMIT={version}");
|
println!("cargo:rustc-env=GIT_COMMIT={version}");
|
||||||
|
let version_short = if version.len() > 16 {
|
||||||
|
&version[..16]
|
||||||
|
} else {
|
||||||
|
&version
|
||||||
|
};
|
||||||
|
println!("cargo:rustc-env=GIT_COMMIT_SHORT={version_short}");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_get_commit() -> color_eyre::Result<String> {
|
fn try_get_commit() -> color_eyre::Result<String> {
|
||||||
|
|
|
||||||
10
migrations/20250704201048_more-build-metadata.sql
Normal file
10
migrations/20250704201048_more-build-metadata.sql
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
-- Add migration script here
|
||||||
|
|
||||||
|
ALTER TABLE "build_info"
|
||||||
|
ADD COLUMN "build_date" INTEGER NULL;
|
||||||
|
|
||||||
|
ALTER TABLE "build_info"
|
||||||
|
ADD COLUMN "build_duration_ms" INTEGER NULL;
|
||||||
|
|
||||||
|
ALTER TABLE "build_info"
|
||||||
|
ADD COLUMN "does_it_build_version" VARCHAR NULL;
|
||||||
14
src/build.rs
14
src/build.rs
|
|
@ -2,7 +2,7 @@ use std::{
|
||||||
fmt::{Debug, Display},
|
fmt::{Debug, Display},
|
||||||
num::NonZeroUsize,
|
num::NonZeroUsize,
|
||||||
path::Path,
|
path::Path,
|
||||||
time::Duration,
|
time::{Duration, Instant, SystemTime},
|
||||||
};
|
};
|
||||||
|
|
||||||
use color_eyre::{
|
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 tmpdir = tempfile::tempdir().wrap_err("creating temporary directory")?;
|
||||||
|
|
||||||
|
let start_time = Instant::now();
|
||||||
|
|
||||||
let result = build_target(
|
let result = build_target(
|
||||||
tmpdir.path(),
|
tmpdir.path(),
|
||||||
&Toolchain::from_nightly(nightly),
|
&Toolchain::from_nightly(nightly),
|
||||||
|
|
@ -258,6 +260,16 @@ async fn build_single_target(db: &Db, nightly: &str, target: &str, mode: BuildMo
|
||||||
stderr: result.stderr,
|
stderr: result.stderr,
|
||||||
mode,
|
mode,
|
||||||
rustflags: result.rustflags,
|
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?;
|
.await?;
|
||||||
|
|
||||||
|
|
|
||||||
11
src/db.rs
11
src/db.rs
|
|
@ -49,6 +49,9 @@ pub struct FullBuildInfo {
|
||||||
pub stderr: String,
|
pub stderr: String,
|
||||||
pub mode: BuildMode,
|
pub mode: BuildMode,
|
||||||
pub rustflags: Option<String>,
|
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)]
|
#[derive(Debug, PartialEq, Clone, Copy, sqlx::Type, Serialize, Deserialize)]
|
||||||
|
|
@ -107,7 +110,8 @@ impl Db {
|
||||||
|
|
||||||
pub async fn insert(&self, info: FullBuildInfo) -> Result<()> {
|
pub async fn insert(&self, info: FullBuildInfo) -> Result<()> {
|
||||||
sqlx::query(
|
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.nightly)
|
||||||
.bind(info.target)
|
.bind(info.target)
|
||||||
|
|
@ -115,6 +119,9 @@ impl Db {
|
||||||
.bind(info.stderr)
|
.bind(info.stderr)
|
||||||
.bind(info.mode)
|
.bind(info.mode)
|
||||||
.bind(info.rustflags)
|
.bind(info.rustflags)
|
||||||
|
.bind(info.build_date)
|
||||||
|
.bind(info.does_it_build_version)
|
||||||
|
.bind(info.build_duration_ms)
|
||||||
.execute(&self.conn)
|
.execute(&self.conn)
|
||||||
.await
|
.await
|
||||||
.wrap_err("inserting build info into database")?;
|
.wrap_err("inserting build info into database")?;
|
||||||
|
|
@ -214,7 +221,7 @@ impl Db {
|
||||||
mode: BuildMode,
|
mode: BuildMode,
|
||||||
) -> Result<Option<FullBuildInfo>> {
|
) -> Result<Option<FullBuildInfo>> {
|
||||||
let result = sqlx::query_as::<_, 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 = ?",
|
WHERE nightly = ? AND target = ? AND mode = ?",
|
||||||
)
|
)
|
||||||
.bind(nightly)
|
.bind(nightly)
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ use db::Db;
|
||||||
use tracing_subscriber::EnvFilter;
|
use tracing_subscriber::EnvFilter;
|
||||||
|
|
||||||
const VERSION: &str = env!("GIT_COMMIT");
|
const VERSION: &str = env!("GIT_COMMIT");
|
||||||
|
const VERSION_SHORT: &str = env!("GIT_COMMIT_SHORT");
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<()> {
|
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>,
|
rustflags: Option<String>,
|
||||||
version: &'static str,
|
version: &'static str,
|
||||||
status: Status,
|
status: Status,
|
||||||
|
build_date: Option<String>,
|
||||||
|
build_duration_s: Option<f32>,
|
||||||
|
does_it_build_version: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
match state
|
match state
|
||||||
|
|
@ -73,6 +76,19 @@ async fn web_build(State(state): State<AppState>, Query(query): Query<BuildQuery
|
||||||
rustflags: build.rustflags,
|
rustflags: build.rustflags,
|
||||||
version: crate::VERSION,
|
version: crate::VERSION,
|
||||||
status: build.status,
|
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()
|
Html(page.render().unwrap()).into_response()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,3 +2,12 @@
|
||||||
document.querySelectorAll(".number").forEach((elem) => {
|
document.querySelectorAll(".number").forEach((elem) => {
|
||||||
elem.textContent = new Intl.NumberFormat().format(Number(elem.textContent));
|
elem.textContent = new Intl.NumberFormat().format(Number(elem.textContent));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Do some fancy date formatting in your locale, so you can't blame me if the numbers look ass.
|
||||||
|
document.querySelectorAll(".date").forEach((elem) => {
|
||||||
|
console.log("run")
|
||||||
|
elem.textContent = new Intl.DateTimeFormat(undefined, {
|
||||||
|
dateStyle: "short",
|
||||||
|
timeStyle: "short",
|
||||||
|
}).format(new Date(elem.textContent));
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Build {{nightly}} {{target}}</title>
|
<title>Build {{nightly}} {{target}}</title>
|
||||||
<link rel="stylesheet" href="/index.css" />
|
<link rel="stylesheet" href="/index.css" />
|
||||||
|
<script type="module" defer src="index.js"></script>
|
||||||
<style>
|
<style>
|
||||||
.build-indicator-big {
|
.build-indicator-big {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
|
|
@ -21,6 +22,12 @@
|
||||||
<p>
|
<p>
|
||||||
Using rustflags: <b><code>{{rustflags}}</code></b>
|
Using rustflags: <b><code>{{rustflags}}</code></b>
|
||||||
</p>
|
</p>
|
||||||
|
{% endif %} {% if let Some(build_date) = build_date %}
|
||||||
|
<p>Build date: <span class="date">{{build_date}}</span></p>
|
||||||
|
{% endif %} {% if let Some(build_duration_s) = build_duration_s %}
|
||||||
|
<p>Build duration: <span class="number">{{build_duration_s}}</span>s</p>
|
||||||
|
{% endif %} {% if let Some(does_it_build_version) = does_it_build_version %}
|
||||||
|
<p>Builder does-it-build commit: <span>{{does_it_build_version}}</span></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<pre>
|
<pre>
|
||||||
{{stderr}}
|
{{stderr}}
|
||||||
|
|
@ -36,20 +43,8 @@
|
||||||
>
|
>
|
||||||
</p>
|
</p>
|
||||||
<footer class="footer">
|
<footer class="footer">
|
||||||
<span>does-it-build {{version}}</span>
|
|
||||||
<a href="https://github.com/Noratrieb/does-it-build">
|
<a href="https://github.com/Noratrieb/does-it-build">
|
||||||
<svg
|
does-it-build {{version}}
|
||||||
viewBox="0 0 16 16"
|
|
||||||
width="32"
|
|
||||||
height="32"
|
|
||||||
aria-labelledby="github-logo-title"
|
|
||||||
>
|
|
||||||
<title id="github-logo-title">GitHub</title>
|
|
||||||
<path
|
|
||||||
fill="black"
|
|
||||||
d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.012 8.012 0 0 0 16 8c0-4.42-3.58-8-8-8z"
|
|
||||||
></path>
|
|
||||||
</svg>
|
|
||||||
</a>
|
</a>
|
||||||
</footer>
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
|
|
@ -61,20 +61,8 @@
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<footer class="footer">
|
<footer class="footer">
|
||||||
<span>does-it-build {{version}}</span>
|
|
||||||
<a href="https://github.com/Noratrieb/does-it-build">
|
<a href="https://github.com/Noratrieb/does-it-build">
|
||||||
<svg
|
does-it-build {{version}}
|
||||||
viewBox="0 0 16 16"
|
|
||||||
width="32"
|
|
||||||
height="32"
|
|
||||||
aria-labelledby="github-logo-title"
|
|
||||||
>
|
|
||||||
<title id="github-logo-title">GitHub</title>
|
|
||||||
<path
|
|
||||||
fill="black"
|
|
||||||
d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.012 8.012 0 0 0 16 8c0-4.42-3.58-8-8-8z"
|
|
||||||
></path>
|
|
||||||
</svg>
|
|
||||||
</a>
|
</a>
|
||||||
</footer>
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
|
|
@ -86,20 +86,8 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
<footer class="footer">
|
<footer class="footer">
|
||||||
<span>does-it-build {{version}}</span>
|
|
||||||
<a href="https://github.com/Noratrieb/does-it-build">
|
<a href="https://github.com/Noratrieb/does-it-build">
|
||||||
<svg
|
does-it-build {{version}}
|
||||||
viewBox="0 0 16 16"
|
|
||||||
width="32"
|
|
||||||
height="32"
|
|
||||||
aria-labelledby="github-logo-title"
|
|
||||||
>
|
|
||||||
<title id="github-logo-title">GitHub</title>
|
|
||||||
<path
|
|
||||||
fill="black"
|
|
||||||
d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.012 8.012 0 0 0 16 8c0-4.42-3.58-8-8-8z"
|
|
||||||
></path>
|
|
||||||
</svg>
|
|
||||||
</a>
|
</a>
|
||||||
</footer>
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
|
|
@ -67,20 +67,8 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
<footer class="footer">
|
<footer class="footer">
|
||||||
<span>does-it-build {{version}}</span>
|
|
||||||
<a href="https://github.com/Noratrieb/does-it-build">
|
<a href="https://github.com/Noratrieb/does-it-build">
|
||||||
<svg
|
does-it-build {{version}}
|
||||||
viewBox="0 0 16 16"
|
|
||||||
width="32"
|
|
||||||
height="32"
|
|
||||||
aria-labelledby="github-logo-title"
|
|
||||||
>
|
|
||||||
<title id="github-logo-title">GitHub</title>
|
|
||||||
<path
|
|
||||||
fill="black"
|
|
||||||
d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.012 8.012 0 0 0 16 8c0-4.42-3.58-8-8-8z"
|
|
||||||
></path>
|
|
||||||
</svg>
|
|
||||||
</a>
|
</a>
|
||||||
</footer>
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue