From de7eca4ab167f3a61b36f6bbc89685be90f384db Mon Sep 17 00:00:00 2001
From: nils <48135649+Nilstrieb@users.noreply.github.com>
Date: Thu, 29 Sep 2022 08:25:07 +0200
Subject: [PATCH 01/18] Update main.rs
---
src/main.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main.rs b/src/main.rs
index 90d90de..05064d2 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -36,7 +36,7 @@ async fn main() -> color_eyre::Result<()> {
)
.init();
- let (job_queue_send, job_queue_recv) = mpsc::channel();
+ let (job_queue_send, job_queue_recv) = mpsc::channel(); // FIXME: make this a sync_channel because bounds are cool
let sqlite_db = env::var("SQLITE_DB").unwrap_or_else(|_| "bisect.sqlite".to_string());
From f391b59f79393de09a72426565b560db6299283e Mon Sep 17 00:00:00 2001
From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com>
Date: Thu, 29 Sep 2022 18:24:32 +0200
Subject: [PATCH 02/18] run.sh
---
run.sh | 4 ++++
1 file changed, 4 insertions(+)
create mode 100644 run.sh
diff --git a/run.sh b/run.sh
new file mode 100644
index 0000000..561ef51
--- /dev/null
+++ b/run.sh
@@ -0,0 +1,4 @@
+docker run -d --name cargo-bisect-rustc-service --net=internal --restart=always \
+ "-v=/apps/cargo-bisect-rustc-service/db:/app/db" \
+ "-e=SQLITE_DB=/app/db/db.sqlite" \
+ docker.nilstrieb.dev/cargo-bisect-rustc-service:1.3
\ No newline at end of file
From b95c9d4b44bedacadf3abc4a76833568b9867646 Mon Sep 17 00:00:00 2001
From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com>
Date: Thu, 29 Sep 2022 20:14:17 +0200
Subject: [PATCH 03/18] improvements
---
index.html | 32 +++++++++++++++++--
src/bisect.rs | 87 +++++++++++++++++++++++++++++----------------------
src/main.rs | 1 +
3 files changed, 79 insertions(+), 41 deletions(-)
diff --git a/index.html b/index.html
index 6a43da1..daa30e0 100644
--- a/index.html
+++ b/index.html
@@ -34,13 +34,28 @@
cols="80"
placeholder="// Rust code goes here..."
>
-fn main() {}
-
+
+
+
@@ -64,6 +79,7 @@ fn main() {}, conn: Connection) {
Err(_) => return,
};
- info!(id = %job.id, "Starting bisection job");
-
- let mut bisect = Bisection {
- id: job.id,
- code: job.code.clone(),
- status: BisectStatus::InProgress,
- };
-
- match db::add_bisection(&conn, &bisect).wrap_err("insert bisection") {
- Ok(()) => {
- let status = match bisect_job(job) {
- Ok(status) => status,
- Err(err) => {
- error!(?err, "error processing bisection");
- BisectStatus::Error {
- output: err.to_string(),
- }
- }
- };
-
- bisect.status = status;
-
- match db::update_bisection_status(&conn, &bisect) {
- Ok(()) => {}
- Err(err) => error!(?err, "error updating bisection"),
- }
+ match process_job(job, &conn) {
+ Ok(()) => {}
+ Err(err) => {
+ error!(?err, "error processing bisection")
}
- Err(err) => error!(?err, "error inserting bisection"),
}
}
}
-#[tracing::instrument(skip(job), fields(id = %job.id))]
+#[tracing::instrument(skip(job, conn), fields(id = %job.id))]
+pub fn process_job(job: Job, conn: &Connection) -> Result<()> {
+ info!(id = %job.id, "Starting bisection job");
+
+ let mut bisect = Bisection {
+ id: job.id,
+ code: job.code.clone(),
+ status: BisectStatus::InProgress,
+ };
+
+ db::add_bisection(&conn, &bisect).wrap_err("insert bisection")?;
+
+ let status = match bisect_job(job) {
+ Ok(status) => status,
+ Err(err) => {
+ error!(?err, "error processing bisection");
+ BisectStatus::Error {
+ output: format!("Internal error"),
+ }
+ }
+ };
+
+ bisect.status = status;
+
+ db::update_bisection_status(&conn, &bisect).wrap_err("writing bisection result")?;
+
+ trace!(?bisect, "Finished bisection job");
+
+ Ok(())
+}
+
fn bisect_job(job: Job) -> Result {
- let (output, state) = run_bisect_for_file(job.code, job.options.start, job.options.end)?;
+ let (output, state) = run_bisect_for_file(job.code, &job.options)?;
info!(state = %state.status(), "Bisection finished");
process_result(output, state).wrap_err("process result")
@@ -113,7 +120,9 @@ fn process_result(output: Output, state: JobState) -> Result {
match state {
JobState::Failed => {
- let output = stderr.lines().rev().take(10).collect::();
+ let mut output = stderr.lines().rev().take(30).collect::>();
+ output.reverse();
+ let output = output.join("\n");
info!(?output, "output");
Ok(BisectStatus::Error { output })
}
@@ -127,11 +136,7 @@ fn process_result(output: Output, state: JobState) -> Result {
}
}
-fn run_bisect_for_file(
- input: String,
- start: chrono::NaiveDate,
- end: Option,
-) -> Result<(Output, JobState)> {
+fn run_bisect_for_file(input: String, options: &Options) -> Result<(Output, JobState)> {
let temp_dir = tempdir::TempDir::new("bisect").wrap_err("creating tempdir")?;
let mut cargo_new = Command::new("cargo");
cargo_new
@@ -156,12 +161,18 @@ fn run_bisect_for_file(
bisect.arg("--timeout").arg("30"); // don't hang
bisect.current_dir(&cargo_dir);
- bisect.arg("--start").arg(start.to_string());
+ bisect.arg("--start").arg(options.start.to_string());
- if let Some(end) = end {
+ if let Some(end) = options.end {
bisect.arg("--end").arg(end.to_string());
}
+ bisect
+ .arg("--regress")
+ .arg(options.kind.as_deref().unwrap_or("ice")); // FIXME Make this configurable
+
+ bisect.env("RUST_LOG", "error"); // overwrite RUST_LOG
+
let output = bisect.output().wrap_err("spawning cargo-bisect-rustc")?;
if output.status.success() {
diff --git a/src/main.rs b/src/main.rs
index 90d90de..9e2b075 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -97,6 +97,7 @@ async fn get_bisections(Extension(conn): Extension) -> impl IntoResponse {
pub struct Options {
start: chrono::NaiveDate,
end: Option,
+ kind: Option,
}
#[derive(Debug, Serialize)]
From 41396f19c7b8b6a9ff939447a63f96a9436f56ce Mon Sep 17 00:00:00 2001
From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com>
Date: Thu, 29 Sep 2022 20:19:14 +0200
Subject: [PATCH 04/18] fmt
---
index.html | 2 ++
1 file changed, 2 insertions(+)
diff --git a/index.html b/index.html
index daa30e0..56ff509 100644
--- a/index.html
+++ b/index.html
@@ -56,8 +56,10 @@ impl<T> Struct<T> {
+
+
From ae9f992ef8c9a2b97da0c2a6714ab2b84d8db835 Mon Sep 17 00:00:00 2001
From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com>
Date: Thu, 29 Sep 2022 21:52:56 +0200
Subject: [PATCH 05/18] time and error handling
---
Cargo.lock | 1 +
Cargo.toml | 4 +-
index.html | 101 ++++++++++++++++++++++++++++++++++----------------
src/bisect.rs | 5 ++-
src/db.rs | 19 ++++++----
5 files changed, 88 insertions(+), 42 deletions(-)
diff --git a/Cargo.lock b/Cargo.lock
index b91c155..4e5d009 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -748,6 +748,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01e213bc3ecb39ac32e81e51ebe31fd888a940515173e3a18a35f8c6e896422a"
dependencies = [
"bitflags",
+ "chrono",
"fallible-iterator",
"fallible-streaming-iterator",
"hashlink",
diff --git a/Cargo.toml b/Cargo.toml
index 71c5a81..7c9473a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -7,9 +7,9 @@ edition = "2021"
[dependencies]
axum = "0.5.16"
-chrono = { version = "0.4.22", features = ["serde"] }
+chrono = { version = "0.4.22", features = ["serde", "clock"] }
color-eyre = "0.6.2"
-rusqlite = { version = "0.28.0", features = ["bundled", "uuid"] }
+rusqlite = { version = "0.28.0", features = ["bundled", "uuid", "chrono"] }
serde = { version = "1.0.145", features = ["derive"] }
tempdir = "0.3.7"
tokio = { version = "1.21.2", features = ["full"] }
diff --git a/index.html b/index.html
index 56ff509..d43ef51 100644
--- a/index.html
+++ b/index.html
@@ -19,6 +19,10 @@
columns: 100;
}
+ .error {
+ color: red;
+ }
+
.bisect-btn {
width: 200px;
height: 50px;
@@ -76,66 +80,101 @@ impl<T> Struct<T> {