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

count number of icons as stats for idb #37

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2,066 changes: 1,001 additions & 1,065 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions crates/diffbot_lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ edition = "2021"
license = "MIT"

[dependencies]
serde = { version = "1.0.206", features = ["derive"] }
octocrab = "0.39.0"
serde = { version = "1.0.218", features = ["derive"] }
octocrab = "0.43.0"
eyre = "0.6.12"
derive_builder = "0.20.0"
chrono = "0.4.38"
derive_builder = "0.20.2"
chrono = "0.4.39"
sha2 = "0.10.8"
hmac = "0.12.1"
hex = "0.4.3"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["fmt", "time"] }
tracing-panic = "0.1.2"
tracing-loki = "0.2.5"
flume = "0.11.0"
tracing-loki = "0.2.6"
flume = "0.11.1"
async-fs = "2.1.2"

actix-web = "4.9.0"
4 changes: 2 additions & 2 deletions crates/diffbot_lib/src/github/github_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl CheckRun {
) -> Result<Self> {
let inst_id = inst_id.into();
let result: RawCheckRun = octocrab::instance()
.installation(inst_id)
.installation(inst_id)?
.post(
format!("/repos/{full_repo}/check-runs"),
Some(&CreateCheckRun {
Expand Down Expand Up @@ -181,7 +181,7 @@ impl CheckRun {
#[derive(Deserialize)]
struct Empty {}
let _: Empty = octocrab::instance()
.installation(self.installation_id)
.installation(self.installation_id)?
.patch(
format!(
"/repos/{repo}/check-runs/{check_run_id}",
Expand Down
2 changes: 1 addition & 1 deletion crates/diffbot_lib/src/github/graphql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub async fn get_pull_files<I: Into<InstallationId>>(
installation: I,
pull: &super::github_types::PullRequest,
) -> Result<Vec<FileDiff>> {
let crab = octocrab::instance().installation(installation.into());
let crab = octocrab::instance().installation(installation.into())?;

let mut cursor = "".to_string();

Expand Down
26 changes: 13 additions & 13 deletions crates/icondiffbot2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ license = "MIT"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
serde = { version = "1.0.206", features = ["derive"] }
serde_json = "1.0.124"
octocrab = "0.39.0"
serde = { version = "1.0.218", features = ["derive"] }
serde_json = "1.0.139"
octocrab = "0.43.0"
dmm-tools = { git = "https://github.com/jupyterkat/SpacemanDMM/" }
jsonwebtoken = "9.3.0"
reqwest = "0.12.5"
jsonwebtoken = "9.3.1"
reqwest = "0.12.12"
diffbot_lib = { path = "../diffbot_lib" }
eyre = "0.6.12"
simple-eyre = "0.3.1"
rayon = "1.10.0"
toml = "0.8.19"
toml = "0.8.20"
ahash = "0.8.11"
hashbrown = { version = "0.14.5", features = ["rayon"] }
tracing-loki = "0.2.5"
flume = "0.11.0"
mysql_async = "0.34.1"
time = "0.3.36"
secrecy = "0.8.0"
hashbrown = { version = "0.15.2", features = ["rayon"] }
tracing-loki = "0.2.6"
flume = "0.11.1"
mysql_async = "0.35.1"
time = "0.3.37"
secrecy = "0.10.3"
percent-encoding = "2.3.1"

actix-web = "4.9.0"
Expand All @@ -33,5 +33,5 @@ actix-files = "0.6.6"
tikv-jemallocator = "0.6.0"

[dependencies.tracing]
version = "0.1.40"
version = "0.1.41"
features = ["attributes"]
2 changes: 1 addition & 1 deletion crates/icondiffbot2/src/downloading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async fn find_content<S: AsRef<str>>(
) -> Result<Content> {
let (owner, repo) = repo.name_tuple();
let items = octocrab::instance()
.installation(*installation)
.installation(*installation)?
.repos(owner, repo)
.get_content()
.path(
Expand Down
26 changes: 15 additions & 11 deletions crates/icondiffbot2/src/github_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async fn handle_pull_request(
payload.pull_request.number,
);

handle_pull(payload, job_sender, check_run).await?;
let num_icons = handle_pull(payload, job_sender, check_run).await?;

if let Some(ref pool) = pool {
let mut conn = match pool.get_conn().await {
Expand All @@ -54,20 +54,23 @@ async fn handle_pull_request(
check_id,
repo_id,
pr_number,
merge_date
merge_date,
num_icons
)
VALUES(
:check_id,
:repo_id,
:pr_number,
:merge_date
:merge_date,
:num_icons
)
",
params! {
"check_id" => check_id,
"repo_id" => repo_id,
"pr_number" => pr_number,
"merge_date" => None::<time::PrimitiveDateTime>,
"merge_date" => None::<usize>,
"num_icons" => num_icons,
},
)
.await
Expand All @@ -88,14 +91,13 @@ async fn handle_pull_request(
};

let now = time::OffsetDateTime::now_utc();
let now = time::PrimitiveDateTime::new(now.date(), now.time());
if let Err(e) = conn
.exec_drop(
r"UPDATE jobs SET merge_date=:date
WHERE repo_id=:rp_id
AND pr_number=:pr_num",
params! {
"date" => now,
"date" => mysql_async::Value::Date(now.year() as u16, now.month() as u8, now.day(), now.hour(), now.minute(), now.second(), now.microsecond()),
"rp_id" => payload.repository.id,
"pr_num" => payload.pull_request.number,
},
Expand All @@ -115,7 +117,7 @@ async fn handle_pull(
payload: PullRequestEventPayload,
job_sender: DataJobSender,
check_run: CheckRun,
) -> Result<()> {
) -> Result<usize> {
if payload
.pull_request
.title
Expand All @@ -131,7 +133,7 @@ async fn handle_pull(
};

check_run.mark_skipped(output).await?;
return Ok(());
return Ok(0);
}

let conf = &crate::CONFIG.get().unwrap();
Expand All @@ -149,7 +151,7 @@ async fn handle_pull(

check_run.mark_skipped(output).await?;

return Ok(());
return Ok(0);
}

let files = get_pull_files(
Expand All @@ -170,6 +172,8 @@ async fn handle_pull(
})
.collect();

let num_icons_diffed = changed_dmis.len();

if changed_dmis.is_empty() {
let output = Output {
title: "No icon changes",
Expand All @@ -179,7 +183,7 @@ async fn handle_pull(

check_run.mark_skipped(output).await?;

return Ok(());
return Ok(0);
}

check_run.mark_queued().await?;
Expand All @@ -199,7 +203,7 @@ async fn handle_pull(

job_sender.send_async(job).await?;

Ok(())
Ok(num_icons_diffed)
}

#[actix_web::post("/payload")]
Expand Down
1 change: 1 addition & 0 deletions crates/icondiffbot2/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ async fn main() -> eyre::Result<()> {
`repo_id` BIGINT(20) NOT NULL,
`pr_number` INT(11) NOT NULL,
`merge_date` DATETIME NULL DEFAULT NULL,
`num_icons` BIGINT(20) NOT NULL DEFAULT b'0',
`processed` BIT(1) NOT NULL DEFAULT b'0',
PRIMARY KEY (`check_id`) USING BTREE,
INDEX `merge_date` (`processed`) USING BTREE,
Expand Down
6 changes: 3 additions & 3 deletions crates/icondiffbot_test_generator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ license = "MIT"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
octocrab = "0.39.0"
clap = { version = "4.5.15", features = ["derive"] }
tokio = { version = "1.39.2", features = ["full"] }
octocrab = "0.43.0"
clap = { version = "4.5.31", features = ["derive"] }
tokio = { version = "1.43.0", features = ["full"] }
30 changes: 15 additions & 15 deletions crates/mapdiffbot2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@ license = "MIT"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
serde = { version = "1.0.206", features = ["derive"] }
serde_json = { version = "1.0.124" }
toml = "0.8.19"
octocrab = "0.39.0"
serde = { version = "1.0.218", features = ["derive"] }
serde_json = { version = "1.0.139" }
toml = "0.8.20"
octocrab = "0.43.0"
dmm-tools = { git = "https://github.com/jupyterkat/SpacemanDMM/" }
dreammaker = { git = "https://github.com/jupyterkat/SpacemanDMM/" }
ahash = "0.8.11"
path-absolutize = "3.1.1"
jsonwebtoken = "9.3.0"
jsonwebtoken = "9.3.1"
eyre = "0.6.12"
simple-eyre = "0.3.1"
rayon = "1.10.0"
image = "0.25.2"
image = "0.25.5"
diffbot_lib = { path = "../diffbot_lib" }
git2 = "0.19.0"
git2 = "0.20.0"
walkdir = "2.5.0"
delay_timer = "0.11.6"
itertools = "0.13.0"
indexmap = { version = "2.3.0", features = ["rayon"] }
tracing-loki = "0.2.5"
flume = "0.11.0"
object_store = { version = "0.10.2", features = ["azure"] }
mysql_async = "0.34.1"
time = "0.3.36"
secrecy = "0.8.0"
itertools = "0.14.0"
indexmap = { version = "2.7.1", features = ["rayon"] }
tracing-loki = "0.2.6"
flume = "0.11.1"
object_store = { version = "0.11.2", features = ["azure"] }
mysql_async = "0.35.1"
time = "0.3.37"
secrecy = "0.10.3"

actix-web = "4.9.0"
actix-files = "0.6.6"
Expand Down
2 changes: 1 addition & 1 deletion crates/mapdiffbot2/src/git_operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ fn commit_all_stragglers(repo: &Repository) -> Result<()> {
| git2::Status::WT_TYPECHANGE,
)
})
.map_or(false, |_| true);
.is_some_and(|_| true);
if dirty {
let head_commit = repo.head()?.peel_to_commit()?;
repo.index()?
Expand Down
4 changes: 2 additions & 2 deletions crates/mapdiffbot2/src/github_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ async fn handle_pull_request(
"check_id" => check_id,
"repo_id" => repo_id,
"pr_number" => pr_number,
"merge_date" => None::<time::PrimitiveDateTime>,
"merge_date" => None::<usize>,
},
)
.await
Expand All @@ -206,7 +206,7 @@ async fn handle_pull_request(
WHERE repo_id=:rp_id
AND pr_number=:pr_num",
params! {
"date" => now,
"date" => mysql_async::Value::Date(now.year() as u16, now.month() as u8, now.day(), now.hour(), now.minute(), now.second(), now.microsecond()),
"rp_id" => payload.repository.id,
"pr_num" => payload.pull_request.number,
},
Expand Down
35 changes: 23 additions & 12 deletions crates/mapdiffbot2/src/job_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,18 +320,29 @@ fn generate_finished_output<P: AsRef<Path>>(
diff_row = Z_DELETED_TEXT
));
}
crate::rendering::BoundType::Both(bounds) => {
builder.add_text(&format!(
include_str!("../templates/diff_template_mod.txt"),
bounds = bounds.to_string(),
filename = name,
image_before_link = format_args!("[Old]({link_before})"),
image_after_link = format_args!("[New]({link_after})"),
image_diff_link = format_args!("[Diff]({link_diff})"),
old_row = format_args!("![{ROW_DESC}]({link_before})"),
new_row = format_args!("![{ROW_DESC}]({link_after})"),
diff_row = format_args!("![{ROW_DESC}]({link_diff})")
));
crate::rendering::BoundType::Both((base_bound, head_bound)) => {
if base_bound == head_bound {
builder.add_text(&format!(
include_str!("../templates/diff_template_mod.txt"),
bounds = base_bound.to_string(),
filename = name,
image_before_link = format_args!("[Old]({link_before})"),
image_after_link = format_args!("[New]({link_after})"),
image_diff_link = format_args!("[Diff]({link_diff})"),
old_row = format_args!("![{ROW_DESC}]({link_before})"),
new_row = format_args!("![{ROW_DESC}]({link_after})"),
diff_row = format_args!("![{ROW_DESC}]({link_diff})")
));
} else {
builder.add_text(&format!(
include_str!("../templates/diff_template_sizechanged.txt"),
filename = name,
image_before_link = format_args!("[Old]({link_before})"),
image_after_link = format_args!("[New]({link_after})"),
old_row = format_args!("![{ROW_DESC}]({link_before})"),
new_row = format_args!("![{ROW_DESC}]({link_after})"),
));
}
}
}
});
Expand Down
Loading
Loading