Skip to content

Commit

Permalink
add job to count pending TODOs
Browse files Browse the repository at this point in the history
  • Loading branch information
yshavit committed Jun 14, 2024
1 parent fe858ef commit 52f55d5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
28 changes: 27 additions & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,31 @@ jobs:
- name: Upload to gist
run: ./scripts/percent_to_shields_gist coverage "$LINES_PERCENT"
env:
GIST_URL: ${{ vars.GIST_URL }}
GIST_URL: ${{ vars.COVERAGE_GIST_URL }}
GH_TOKEN: ${{ secrets.API_TOKEN }}
- name: Count TODOs
run: |
set -euo pipefail
todos_count="$(
git ls-tree -r --name-only HEAD |
grep --fixed-string -v .github/workflows/coverage.yml |
grep --fixed-string -v README.md |
(xargs grep todo -i -o || true) |
wc -l
)"
if [ "$todos_count" -eq 0 ]; then
color=green
else
color=orange
fi
json_text="$(echo '{}' |
jq -c '{schemaVersion: 1, label: $badge_label, color: $color, message: $message}' \
--arg badge_label "☑ Pending TODOs" --arg color "$color" --arg message "$todos_count")"
percent_coverage="$(cargo llvm-cov --json | jq '.data[].totals.lines.percent')"
printf '::notice title=TODOs Count::%s' "$todos_count"
gh gist edit "$GIST_URL" <(echo "$json_text")
env:
GIST_URL: ${{ vars.TODOS_GIST_URL }}
GH_TOKEN: ${{ secrets.API_TOKEN }}

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
![Code Coverage](https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2Fyshavit%2F53901a0115b596e015a891c41fb0f256%2Fraw%2Fmdq-coverage.json)
![Pending TODOs](https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2Fyshavit%2Fe7a9e9e72651da0d7d2b1fbbe56237d0%2Fraw%2Fa81c8e1ea9b0beb4a937e88d1b9b775eb9dddae8%2Fmdq-todos.json)


0 comments on commit 52f55d5

Please sign in to comment.