Skip to content

Commit

Permalink
feat(l1, l2, levm): improve loc reporter (#1264)
Browse files Browse the repository at this point in the history
- Print summary
- Send summary to slack
  • Loading branch information
ilitteri authored Nov 25, 2024
1 parent 1c771bc commit a9d45d6
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 10 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/loc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,27 @@ jobs:
uses: Swatinem/rust-cache@v2

- name: Generate the loc report
id: loc-report
run: make loc
echo "content=$(cat loc_report.md)" >> $GITHUB_OUTPUT

- name: Post results in summary
run: |
echo "# `ethrex` lines of code report:\n\n" >> $GITHUB_STEP_SUMMARY
$(cat loc_report.md) >> $GITHUB_STEP_SUMMARY
- name: Post results to slack
uses: slackapi/[email protected]
with:
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
webhook-type: incoming-webhook
payload: |
blocks:
- type: "header"
text:
type: "plain_text"
text: ethrex lines of code report
- type: "section"
text:
type: "mrkdwn"
text: ${{steps.loc-report.outputs.content}}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,5 @@ tests_v3.0.0.tar.gz
.env

levm_ef_tests_report.txt

loc_report.md
25 changes: 15 additions & 10 deletions cmd/loc/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use colored::Colorize;
use std::path::PathBuf;
use tokei::{Config, LanguageType, Languages};

Expand All @@ -23,14 +22,20 @@ fn main() {
languages.get_statistics(&[ethrex_l2], &[], &config);
let ethrex_l2_loc = &languages.get(&LanguageType::Rust).unwrap();

println!("{}", "ethrex loc summary".bold());
println!("{}", "====================".bold());
println!(
"{}: {:?}",
"ethrex L1".bold(),
ethrex_loc.code - ethrex_l2_loc.code - levm_loc.code
let report = format!(
r#"```
ethrex loc summary
====================
ethrex L1: {}
ethrex L2: {}
levm: {}
ethrex (total): {}
```"#,
ethrex_loc.code - ethrex_l2_loc.code - levm_loc.code,
ethrex_l2_loc.code,
levm_loc.code,
ethrex_loc.code,
);
println!("{}: {:?}", "ethrex L2".bold(), ethrex_l2_loc.code);
println!("{}: {:?}", "levm".bold(), levm_loc.code);
println!("{}: {:?}", "ethrex (total)".bold(), ethrex_loc.code);

std::fs::write("loc_report.md", report).unwrap();
}

0 comments on commit a9d45d6

Please sign in to comment.