Skip to content
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

[CI] Add job summary to the lines of code workflow #367

Merged
merged 2 commits into from
Jul 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions .github/workflows/lines_of_code.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -21,22 +24,23 @@ 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"
${{ env._CLOC_DIR }}/cloc --md --include-lang="${{ env.LANGUAGES }}" . | tail -n +4 >> $GITHUB_STEP_SUMMARY

- 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 }}"