-
-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
57b4a1a
commit d5fcbe7
Showing
2 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# script for us in kcov.yml action | ||
|
||
SUMMARY=$(cat zig-out/kcov/kcov-merged/coverage.json) | ||
|
||
PERCENT_COVERED=$(echo $SUMMARY | jq .percent_covered -cr) | ||
COVERED_LINES=$(echo $SUMMARY | jq .covered_lines -cr) | ||
TOTAL_LINES=$(echo $SUMMARY | jq .total_lines -cr) | ||
|
||
echo "## Code Coverage Report\n" | ||
echo "### $PERCENT_COVERED% covered ($COVERED_LINES / $TOTAL_LINES lines)\n" | ||
|
||
echo "<details open><summary>Per-file coverage details</summary><br>\n" | ||
|
||
FILES=$(echo $SUMMARY | jq '.files | sort_by(.percent_covered | tonumber) | .[]' -cr) | ||
|
||
echo "| File | Coverage | |" | ||
echo "| ---- | -------- | - |" | ||
|
||
for FILE in $FILES; do | ||
FILENAME="$(echo $FILE | jq '.file' -cr)" | ||
FILENAME=${FILENAME#*zls/} | ||
FILE_PERCENT_COVERED=$(echo $FILE | jq '.percent_covered' -cr) | ||
FILE_COVERED_LINES=$(echo $FILE | jq '.covered_lines' -cr) | ||
FILE_TOTAL_LINES=$(echo $FILE | jq '.total_lines' -cr) | ||
|
||
FILE_STATUS=$( | ||
if [ $(echo $FILE_PERCENT_COVERED'<25' | bc -l) -eq 1 ]; | ||
then | ||
echo "❗" | ||
elif [ $(echo $FILE_PERCENT_COVERED'<75' | bc -l) -eq 1 ]; | ||
then | ||
echo "⚠️" | ||
else | ||
echo "✅" | ||
fi | ||
) | ||
|
||
echo "| \`$FILENAME\` | $FILE_PERCENT_COVERED% ($FILE_COVERED_LINES / $FILE_TOTAL_LINES lines) | $FILE_STATUS |" | ||
done | ||
|
||
echo "</details>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Code Coverage | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize] | ||
|
||
permissions: | ||
pull-requests: write | ||
|
||
jobs: | ||
coverage: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
submodules: true | ||
|
||
- uses: goto-bus-stop/setup-zig@v2 | ||
with: | ||
version: master | ||
|
||
- run: zig version | ||
- run: zig env | ||
|
||
- name: Build | ||
run: zig build | ||
|
||
- name: Install kcov | ||
run: sudo apt-get install kcov | ||
|
||
- name: Run Tests with kcov | ||
id: kcov | ||
run: | | ||
zig build test -Dgenerate_coverage | ||
.github/workflows/kcov-json-to-summary.sh > zig-out/summary.md | ||
cat zig-out/summary.md > $GITHUB_STEP_SUMMARY | ||
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) | ||
echo "report<<$EOF" >> "$GITHUB_ENV" | ||
cat zig-out/summary.md >> "$GITHUB_ENV" | ||
echo "$EOF" >> "$GITHUB_ENV" | ||
- name: Publish coverage status | ||
uses: thollander/actions-comment-pull-request@v2 | ||
with: | ||
message: | | ||
${{ steps.kcov.outputs.report }} | ||
comment_tag: coverage |