improvements

This commit is contained in:
nora 2024-09-07 23:29:54 +02:00
parent aacf0f293e
commit d5167446f2
7 changed files with 90 additions and 6 deletions

View file

@ -21,3 +21,6 @@ tempfile = "3.12.0"
tokio = { version = "1.40.0", features = ["full"] } tokio = { version = "1.40.0", features = ["full"] }
tracing = "0.1.40" tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
[build-dependencies]
color-eyre = "0.6.3"

35
build.rs Normal file
View file

@ -0,0 +1,35 @@
fn main() {
// Always rerun.
let version = if let Ok(commit) = try_get_commit() {
match has_no_changes() {
Ok(true) => commit,
Ok(false) => format!("{commit} (*)"),
Err(_) => format!("{commit} (?)"),
}
} else {
"unknown".into()
};
println!("cargo:rustc-env=GIT_COMMIT={version}");
}
fn try_get_commit() -> color_eyre::Result<String> {
let stdout = std::process::Command::new("git")
.arg("rev-parse")
.arg("HEAD")
.output()?
.stdout;
let stdout = String::from_utf8(stdout)?;
Ok(stdout.trim()[0..8].to_owned())
}
fn has_no_changes() -> color_eyre::Result<bool> {
Ok(std::process::Command::new("git")
.args(["diff", "--no-ext-diff", "--quiet", "--exit-code"])
.output()?
.status
.success())
}

View file

@ -6,6 +6,8 @@ mod web;
use color_eyre::{eyre::WrapErr, Result}; use color_eyre::{eyre::WrapErr, Result};
use db::Db; use db::Db;
const VERSION: &str = env!("GIT_COMMIT");
#[tokio::main] #[tokio::main]
async fn main() -> Result<()> { async fn main() -> Result<()> {
tracing_subscriber::fmt().init(); tracing_subscriber::fmt().init();

View file

@ -25,14 +25,14 @@ pub async fn webserver(db: Db) -> Result<()> {
.route("/trigger-build", post(trigger_build)) .route("/trigger-build", post(trigger_build))
.with_state(AppState { db }); .with_state(AppState { db });
info!("Serving website on port 3000"); info!("Serving website on port 3000 (commit {})", crate::VERSION);
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap(); let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
axum::serve(listener, app).await.wrap_err("failed to serve") axum::serve(listener, app).await.wrap_err("failed to serve")
} }
async fn root() -> impl IntoResponse { async fn root() -> impl IntoResponse {
Html(include_str!("../static/index.html")) Html(include_str!("../static/index.html").replace("{{version}}", crate::VERSION))
} }
#[derive(Deserialize)] #[derive(Deserialize)]
@ -52,6 +52,7 @@ async fn build(State(state): State<AppState>, Query(query): Query<BuildQuery>) -
.replace("{{nightly}}", &query.nightly) .replace("{{nightly}}", &query.nightly)
.replace("{{target}}", &query.target) .replace("{{target}}", &query.target)
.replace("{{stderr}}", &build.stderr) .replace("{{stderr}}", &build.stderr)
.replace("{{version}}", crate::VERSION)
.replace("{{status}}", &build.status.to_string()); .replace("{{status}}", &build.status.to_string());
Html(page).into_response() Html(page).into_response()

View file

@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Build</title> <title>Build {{nightly}} {{target}}</title>
<link rel="stylesheet" href="/index.css" /> <link rel="stylesheet" href="/index.css" />
<style> <style>
.build-indicator-big { .build-indicator-big {
@ -17,5 +17,22 @@
<pre> <pre>
{{stderr}} {{stderr}}
</pre> </pre>
<footer class="footer">
<span>does-it-build {{version}}</span>
<a href="https://github.com/Noratrieb/does-it-build">
<svg
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>
</footer>
</body> </body>
</html> </html>

View file

@ -24,3 +24,10 @@ td {
color: black; color: black;
text-decoration: none; text-decoration: none;
} }
.footer {
margin-top: 20px;
display: flex;
align-items: center;
gap: 10px;
}

View file

@ -3,18 +3,20 @@
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Target state</title> <title>Does it build?</title>
<link rel="stylesheet" href="/index.css" /> <link rel="stylesheet" href="/index.css" />
</head> </head>
<body> <body>
<h1>Target state</h1> <h1>Does it build?</h1>
<p>Builds every target with:
<pre>cargo build --release -Zbuild-std=core</pre></p>
<p>Does therefore currently not check for the std build status.</p>
<!--<form id="nightly-form"> <!--<form id="nightly-form">
<h2>Force manual build</h2> <h2>Force manual build</h2>
<label for="nightly-date-field">Nightly date</label> <label for="nightly-date-field">Nightly date</label>
<input id="nightly-date-field" placeholder="2024-08-05" type="text" /> <input id="nightly-date-field" placeholder="2024-08-05" type="text" />
<input type="submit" /> <input type="submit" />
</form>--> </form>-->
<h2>Historical target state</h2>
<label for="target-filter">Target Filter</label> <label for="target-filter">Target Filter</label>
<input id="target-filter" /> <input id="target-filter" />
<label for="target-filter-failed">Filter failed</label> <label for="target-filter-failed">Filter failed</label>
@ -25,6 +27,23 @@
<td>loading...</td> <td>loading...</td>
</tr> </tr>
</table> </table>
<footer class="footer">
<span>does-it-build {{version}}</span>
<a href="https://github.com/Noratrieb/does-it-build">
<svg
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>
</footer>
<script> <script>
let data = []; let data = [];
let filter = localStorage.getItem("filter") ?? ""; let filter = localStorage.getItem("filter") ?? "";