From fe54db3ae6999d474b127fb595b197892e91fc3e Mon Sep 17 00:00:00 2001 From: Lukas Dullinger <129603980+itislu@users.noreply.github.com> Date: Fri, 26 Jul 2024 00:42:17 +0200 Subject: [PATCH] doc: Don't count blank and comment lines --- .github/workflows/lines_of_code.yaml | 30 +++++++++++++--------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/.github/workflows/lines_of_code.yaml b/.github/workflows/lines_of_code.yaml index f45d6f6e..1897aa8c 100644 --- a/.github/workflows/lines_of_code.yaml +++ b/.github/workflows/lines_of_code.yaml @@ -6,7 +6,9 @@ on : branches: - main env: - BADGE_COLOR: 61A + CLOC_DIR : /home/runner/cloc + LINES_OF_CODE: 0 + BADGE_COLOR : 61A jobs: lines_of_code: @@ -17,28 +19,24 @@ jobs: - name: Checkout branch uses: actions/checkout@v4 - - name: Count lines - uses: shadowmoose/GHA-LoC-Badge@1.0.0 - id : loc - with: - directory : ./ - badge : ./doc/images/lines_of_code.svg - patterns : '**/*.c|**/*.h|**/Makefile|**/*.mk|**/*.py|**/*.yaml|**/*.sh|**/*.y|**/*.bnf' - badge_label: 'lines of code' - badge_color: ${{ env.BADGE_COLOR }} - badge_style: classic - debug : true + - name: Install cloc + run : | + git clone git@github.com:AlDanial/cloc.git ${{ env.CLOC_DIR }} + + - name: Count lines by language + run : | + ${{ env.CLOC_DIR }}/cloc --fmt=2 --include-lang='C,C/C++ Header,make,YAML,Python,Bourne Shell,Bourne Again Shell,yacc,Dockerfile' . | tee ${{ env.CLOC_DIR }}/cloc_output.txt + echo "LINES_OF_CODE=$(grep 'SUM:' ${{ env.CLOC_DIR }}/cloc_output.txt | awk '{print $5}')" >> "$GITHUB_ENV" - - name: Print the output + - name: Count lines by file run : | - echo "Scanned: ${{ steps.loc.outputs.counted_files }}"; - echo "Line Count: ${{ steps.loc.outputs.total_lines }}"; + ${{ env.CLOC_DIR }}/cloc --fmt=5 --include-lang='C,C/C++ Header,make,YAML,Python,Bourne Shell,Bourne Again Shell,yacc,Dockerfile' . - name: Create badge uses: RubbaBoy/BYOB@v1 with: name : lines_of_code label : 'lines of code' - status : ${{ steps.loc.outputs.total_lines }} + status : ${{ env.LINES_OF_CODE }} color : ${{ env.BADGE_COLOR }} github_token: ${{ github.token }}