Skip to content

Conversation

christiangda
Copy link
Contributor

@christiangda christiangda commented Feb 4, 2025

  • Extend the output format to a markdown table, allowing to show results in the Github action's workflow summary

--> --output-type= output type [values: default,markdown,cloc-xml,sloccount,json] (default: default)

I started to use this go program recently on my Github Action Workflows, and I did a bash hack to convert the --output-type=default output to Markdown table

My hack is:

      - name: Lines of code
        run: |
          echo "## Line of code" >> $GITHUB_STEP_SUMMARY

          go install github.com/hhatto/gocloc/cmd/gocloc@latest
          gocloc --not-match-d=vendor,bin,build,dist,docs,examples,scripts,testdata,tests,tools . \
          | tail -n +2 | sed -e '$ d' | sed 's/^/|/' | sed 's/ \{1,\}/  \|  /g' | sed 's/$/\|/' | tac |sed '2d'| tac | sed 's/---\{5,20\}/--|--/g' \
          | tee -a $GITHUB_STEP_SUMMARY

To show it as:

Screenshot 2025-02-04 at 14 46 20

As a hack, this is fine, but the columns were not aligned as expected, so I decided to make this pull request to do that natively in the code, so now this is the result:

Screenshot 2025-02-04 at 14 47 44

I hope this will be util and accepted

Extend the output format to markdown table allowing to shows results in github action workflows summary
@hhatto hhatto self-requested a review March 24, 2025 14:16
Copy link
Owner

@hhatto hhatto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice feature 👍
LGTM

@hhatto hhatto merged commit f593d50 into hhatto:master Mar 24, 2025
@hhatto
Copy link
Owner

hhatto commented Mar 24, 2025

@christiangda
Sorry for late reply. pull-request is merged.
version 0.7.0 has been released, Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants