From a9d45d6fa9d4a233b6e035e711aec0a1bc51a799 Mon Sep 17 00:00:00 2001 From: Ivan Litteri <67517699+ilitteri@users.noreply.github.com> Date: Mon, 25 Nov 2024 15:41:51 -0300 Subject: [PATCH] feat(l1, l2, levm): improve loc reporter (#1264) - Print summary - Send summary to slack --- .github/workflows/loc.yaml | 23 +++++++++++++++++++++++ .gitignore | 2 ++ cmd/loc/src/main.rs | 25 +++++++++++++++---------- 3 files changed, 40 insertions(+), 10 deletions(-) diff --git a/.github/workflows/loc.yaml b/.github/workflows/loc.yaml index b8a7046b4b..c26b87b660 100644 --- a/.github/workflows/loc.yaml +++ b/.github/workflows/loc.yaml @@ -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/slack-github-action@v2.0.0 + 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}} diff --git a/.gitignore b/.gitignore index 3ee1c729c2..6cfabcf47c 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,5 @@ tests_v3.0.0.tar.gz .env levm_ef_tests_report.txt + +loc_report.md diff --git a/cmd/loc/src/main.rs b/cmd/loc/src/main.rs index c2a8eb30f6..0b180b3803 100644 --- a/cmd/loc/src/main.rs +++ b/cmd/loc/src/main.rs @@ -1,4 +1,3 @@ -use colored::Colorize; use std::path::PathBuf; use tokei::{Config, LanguageType, Languages}; @@ -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(); }