-
Notifications
You must be signed in to change notification settings - Fork 33
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
feat(l1, l2, levm): make stats
#1361
Merged
Merged
Changes from 10 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
020935f
Update loc reporter
ilitteri 0a58f7b
Add `make stats` cmd
ilitteri b75f2b5
Merge branch 'main' of github.com:lambdaclass/lambda_ethereum_rust in…
ilitteri 4e4b612
Fix bad merge conflict solving
ilitteri 34505fe
Fix
ilitteri db03fab
Finish hive report printing
ilitteri c84f767
Merge branch 'main' into make_stats
ilitteri ab824f1
Merge branch 'main' into make_stats
ilitteri 1aa871c
Merge branch 'main' into make_stats
ilitteri 05f5fe9
Make target depend on downloading evm ef tests
jrchatruc 763d66d
Refactored `make stats` and deps
ilitteri fd293fc
Merge branch 'main' into make_stats
ilitteri ad820df
Merge branch 'main' into make_stats
ilitteri 89bd27a
Merge branch 'main' into make_stats
ilitteri 0bf1033
Merge branch 'main' into make_stats
jrchatruc 8e4b376
Merge branch 'main' into make_stats
jrchatruc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
use clap::Parser; | ||
use colored::Colorize; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Parser)] | ||
pub struct LinesOfCodeReporterOptions { | ||
#[arg(short, long, value_name = "SUMMARY", default_value = "false")] | ||
pub summary: bool, | ||
} | ||
|
||
#[derive(Default, Serialize, Deserialize, Clone, Copy)] | ||
pub struct LinesOfCodeReport { | ||
pub ethrex: usize, | ||
pub ethrex_l1: usize, | ||
pub ethrex_l2: usize, | ||
pub levm: usize, | ||
} | ||
|
||
pub fn slack_message(old_report: LinesOfCodeReport, new_report: LinesOfCodeReport) -> String { | ||
let ethrex_l1_diff = new_report.ethrex_l1.abs_diff(old_report.ethrex_l1); | ||
let ethrex_l2_diff = new_report.ethrex_l2.abs_diff(old_report.ethrex_l2); | ||
let levm_diff = new_report.levm.abs_diff(old_report.levm); | ||
let ethrex_diff_total = ethrex_l1_diff + ethrex_l2_diff + levm_diff; | ||
|
||
format!( | ||
r#"{{ | ||
"blocks": [ | ||
{{ | ||
"type": "header", | ||
"text": {{ | ||
"type": "plain_text", | ||
"text": "Daily Lines of Code Report" | ||
}} | ||
}}, | ||
{{ | ||
"type": "divider" | ||
}}, | ||
{{ | ||
"type": "section", | ||
"text": {{ | ||
"type": "mrkdwn", | ||
"text": "*ethrex L1:* {} {}\n*ethrex L2:* {} {}\n*levm:* {} {}\n*ethrex (total):* {} {}" | ||
}} | ||
}} | ||
] | ||
}}"#, | ||
new_report.ethrex_l1, | ||
match new_report.ethrex_l1.cmp(&old_report.ethrex_l1) { | ||
std::cmp::Ordering::Greater => format!("(+{ethrex_l1_diff})"), | ||
std::cmp::Ordering::Less => format!("(-{ethrex_l1_diff})"), | ||
std::cmp::Ordering::Equal => "".to_string(), | ||
}, | ||
new_report.ethrex_l2, | ||
match new_report.ethrex_l2.cmp(&old_report.ethrex_l2) { | ||
std::cmp::Ordering::Greater => format!("(+{ethrex_l2_diff})"), | ||
std::cmp::Ordering::Less => format!("(-{ethrex_l2_diff})"), | ||
std::cmp::Ordering::Equal => "".to_string(), | ||
}, | ||
new_report.levm, | ||
match new_report.levm.cmp(&old_report.levm) { | ||
std::cmp::Ordering::Greater => format!("(+{levm_diff})"), | ||
std::cmp::Ordering::Less => format!("(-{levm_diff})"), | ||
std::cmp::Ordering::Equal => "".to_string(), | ||
}, | ||
new_report.ethrex, | ||
match new_report.ethrex.cmp(&old_report.ethrex) { | ||
std::cmp::Ordering::Greater => format!("(+{ethrex_diff_total})"), | ||
std::cmp::Ordering::Less => format!("(-{ethrex_diff_total})"), | ||
std::cmp::Ordering::Equal => "".to_string(), | ||
}, | ||
) | ||
} | ||
|
||
pub fn github_step_summary(old_report: LinesOfCodeReport, new_report: LinesOfCodeReport) -> String { | ||
let ethrex_l1_diff = new_report.ethrex_l1.abs_diff(old_report.ethrex_l1); | ||
let ethrex_l2_diff = new_report.ethrex_l2.abs_diff(old_report.ethrex_l2); | ||
let levm_diff = new_report.levm.abs_diff(old_report.levm); | ||
let ethrex_diff_total = ethrex_l1_diff + ethrex_l2_diff + levm_diff; | ||
|
||
format!( | ||
r#"``` | ||
ethrex loc summary | ||
==================== | ||
ethrex L1: {} {} | ||
ethrex L2: {} {} | ||
levm: {} ({}) | ||
ethrex (total): {} {} | ||
```"#, | ||
new_report.ethrex_l1, | ||
if new_report.ethrex > old_report.ethrex { | ||
format!("(+{ethrex_l1_diff})") | ||
} else { | ||
format!("(-{ethrex_l1_diff})") | ||
}, | ||
new_report.ethrex_l2, | ||
if new_report.ethrex_l2 > old_report.ethrex_l2 { | ||
format!("(+{ethrex_l2_diff})") | ||
} else { | ||
format!("(-{ethrex_l2_diff})") | ||
}, | ||
new_report.levm, | ||
if new_report.levm > old_report.levm { | ||
format!("(+{levm_diff})") | ||
} else { | ||
format!("(-{levm_diff})") | ||
}, | ||
new_report.ethrex, | ||
if new_report.ethrex > old_report.ethrex { | ||
format!("(+{ethrex_diff_total})") | ||
} else { | ||
format!("(-{ethrex_diff_total})") | ||
}, | ||
) | ||
} | ||
|
||
pub fn shell_summary(new_report: LinesOfCodeReport) -> String { | ||
format!( | ||
"{}\n{}\n{} {}\n{} {}\n{} {}\n{} {}", | ||
"Lines of Code".bold(), | ||
"=============".bold(), | ||
"ethrex L1:".bold(), | ||
new_report.ethrex_l1, | ||
"ethrex L2:".bold(), | ||
new_report.ethrex_l2, | ||
"levm:".bold(), | ||
new_report.levm, | ||
"ethrex (total):".bold(), | ||
new_report.ethrex, | ||
) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why don't you add a dependency to
setup-hive
instead of duplicating code?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, I'll refactor it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 763d66d.