GHA-LoC-Badge
GHA-LoC-Badge copied to clipboard
Action is not discovering any files to count
Thanks for this tool. Would you be able to tell me what I am doing wrong here: https://github.com/dandavison/delta/pull/433? It seems not to be discovering any code to count.
Run shadowmoose/[email protected]
Debugging enabled.
Counted 0 Lines from 0 Files, ignoring 0 Files.
Took: 12
+1
It appears that the line counter does not recurse through the directory you set to scan. Since your code is in src
this might explain why it's not finding it. I tried setting the directory to ./src/
and other variants, but this always results in the error UnhandledPromiseRejectionWarning: TypeError: (s || "").replace is not a function
. Instead, I set my pattern to src/*.jl
(for Julia files) and it worked. A similar approach might work for you.
After some experimenting I managed to get it working as expected.
I think using actions/checkout@v2
rather than v1 did the trick. That's assuming you're using checkout to begin with. 🤷
Below is my yaml workflow file. I hope this is useful or at least points anyone in the right direction.
name: Lines of Code
on:
pull_request:
branches: [ master ]
jobs:
line_counter:
runs-on: ubuntu-latest
name: Initialise
steps:
- name: Checkout
uses: actions/checkout@v2
with:
token: ${{ secrets.PAT }}
- name: Count The Lines
uses: shadowmoose/[email protected]
id: badge
with:
debug: false
directory: ./
badge: .github/cloc.svg
ignore: 'node_modules/|README'
- name: Print the output
run: |
echo "Scanned: ${{ steps.badge.outputs.counted_files }}";
echo "Line Count: ${{ steps.badge.outputs.total_lines }}";
- name: Commit Badge
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Update Lines of Code badge - ${{ steps.badge.outputs.total_lines }}
push_options: '--force'
Outputs to .github/cloc.svg
Getting 0 lines: https://github.com/sparks-baird/matbench-genmetrics/actions/runs/5300322666/jobs/9593826376