From ebd3df7a342b3b7155edb3213f41938cd4f32e96 Mon Sep 17 00:00:00 2001 From: Lukas Dullinger <129603980+itislu@users.noreply.github.com> Date: Fri, 26 Jul 2024 01:36:35 +0200 Subject: [PATCH 1/2] ci: Add config variables to top of yaml file --- .github/workflows/lines_of_code.yaml | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/.github/workflows/lines_of_code.yaml b/.github/workflows/lines_of_code.yaml index 780c205f..c1ebe637 100644 --- a/.github/workflows/lines_of_code.yaml +++ b/.github/workflows/lines_of_code.yaml @@ -6,9 +6,12 @@ on : branches: - main env: - CLOC_DIR : /home/runner/cloc - LINES_OF_CODE: 0 - BADGE_COLOR : 61A + ID : lines_of_code + LABEL : 'lines of code' + LANGUAGES : 'C,C/C++ Header,make,YAML,Python,Bourne Shell,Bourne Again Shell,yacc,Markdown,Dockerfile' + BADGE_COLOR : 61A + _CLOC_DIR : /home/runner/cloc + _LINES_OF_CODE: 0 jobs: lines_of_code: @@ -21,22 +24,22 @@ jobs: - name: Install cloc run : | - git clone https://github.com/AlDanial/cloc.git ${{ env.CLOC_DIR }} + git clone https://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,Markdown,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" + ${{ env._CLOC_DIR }}/cloc --fmt=2 --include-lang="${{ env.LANGUAGES }}" . | 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: 📑 Count lines by file run : | - ${{ env.CLOC_DIR }}/cloc --fmt=5 --include-lang='C,C/C++ Header,make,YAML,Python,Bourne Shell,Bourne Again Shell,yacc,Markdown,Dockerfile' . + ${{ env._CLOC_DIR }}/cloc --fmt=5 --include-lang="${{ env.LANGUAGES }}" . - name: Create badge uses: RubbaBoy/BYOB@v1 with: - name : lines_of_code - label : 'lines of code' - status : ${{ env.LINES_OF_CODE }} - color : ${{ env.BADGE_COLOR }} - github_token: ${{ github.token }} + name : "${{ env.ID }}" + label : "${{ env.LABEL }}" + status : "${{ env._LINES_OF_CODE }}" + color : "${{ env.BADGE_COLOR }}" + github_token: "${{ github.token }}" From 40448442d73f9310711b2deae7a354629b416d5a Mon Sep 17 00:00:00 2001 From: Lukas Dullinger <129603980+itislu@users.noreply.github.com> Date: Fri, 26 Jul 2024 02:15:02 +0200 Subject: [PATCH 2/2] ci: Add a job summary to lines of code workflow --- .github/workflows/lines_of_code.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/lines_of_code.yaml b/.github/workflows/lines_of_code.yaml index c1ebe637..3037f5bf 100644 --- a/.github/workflows/lines_of_code.yaml +++ b/.github/workflows/lines_of_code.yaml @@ -30,6 +30,7 @@ jobs: run : | ${{ env._CLOC_DIR }}/cloc --fmt=2 --include-lang="${{ env.LANGUAGES }}" . | tee ${{ env._CLOC_DIR }}/cloc_output.txt echo "_LINES_OF_CODE=$(grep 'SUM' ${{ env._CLOC_DIR }}/cloc_output.txt | awk '{print $5}')" >> "$GITHUB_ENV" + ${{ env._CLOC_DIR }}/cloc --md --include-lang="${{ env.LANGUAGES }}" . | tail -n +4 >> $GITHUB_STEP_SUMMARY - name: 📑 Count lines by file run : |