Skip to content

Commit 6a1fc65

Browse files
authored
chore: fix coverage pr reports and badge generation (#166)
1 parent 1470e49 commit 6a1fc65

File tree

3 files changed

+52
-35
lines changed

3 files changed

+52
-35
lines changed

.github/workflows/on-pr.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ jobs:
3737

3838
code-coverage-report:
3939
name: Code Coverage Report
40-
if: github.event_name == 'pull_request'
4140
runs-on: ubuntu-latest
4241
needs: validate-and-test
4342
permissions:
@@ -49,7 +48,7 @@ jobs:
4948
with:
5049
coverage-artifact-name: "code-coverage"
5150
coverage-file-name: "coverage.out"
52-
root-package: "github.com/NVIDIA/KAI-Scheduler"
51+
root-package: "github.com/NVIDIA/KAI-scheduler"
5352
github-baseline-workflow-ref: update-coverage-badge.yaml
5453

5554
build:

.github/workflows/update-coverage-badge.yaml

Lines changed: 49 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ on:
77
push:
88
branches:
99
- "main"
10-
pull_request:
11-
paths:
12-
- .github/workflows/update-coverage-badge.yaml
1310
workflow_dispatch:
1411

1512
jobs:
@@ -19,7 +16,7 @@ jobs:
1916
permissions:
2017
contents: write
2118
pull-requests: write
22-
19+
2320
steps:
2421
- name: Checkout code
2522
uses: actions/checkout@v4
@@ -62,40 +59,61 @@ jobs:
6259
echo "color=red" >> $GITHUB_OUTPUT
6360
fi
6461
65-
- name: Setup GitHub CLI
62+
- name: Create Coverage Badge SVG
6663
if: github.event_name != 'pull_request'
64+
id: create_badge
6765
run: |
68-
gh auth setup-git
69-
env:
70-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
mkdir -p badges
67+
# Create SVG badge file
68+
cat > badges/coverage.svg << EOF
69+
<svg xmlns="http://www.w3.org/2000/svg" width="106" height="20">
70+
<linearGradient id="b" x2="0" y2="100%">
71+
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
72+
<stop offset="1" stop-opacity=".1"/>
73+
</linearGradient>
74+
<mask id="a">
75+
<rect width="106" height="20" rx="3" fill="#fff"/>
76+
</mask>
77+
<g mask="url(#a)">
78+
<path fill="#555" d="M0 0h61v20H0z"/>
79+
<path fill="#${{ steps.coverage.outputs.color }}" d="M61 0h45v20H61z"/>
80+
<path fill="url(#b)" d="M0 0h106v20H0z"/>
81+
</g>
82+
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
83+
<text x="30.5" y="15" fill="#010101" fill-opacity=".3">coverage</text>
84+
<text x="30.5" y="14">coverage</text>
85+
<text x="82.5" y="15" fill="#010101" fill-opacity=".3">${{ steps.coverage.outputs.percentage }}%</text>
86+
<text x="82.5" y="14">${{ steps.coverage.outputs.percentage }}%</text>
87+
</g>
88+
</svg>
89+
EOF
90+
echo "Created coverage badge SVG"
7191
72-
- name: Update README.md with Coverage Badge
92+
- name: Push Badge to Dedicated Branch
7393
if: github.event_name != 'pull_request'
7494
env:
7595
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7696
run: |
77-
# Create the shields.io URL with the coverage data
78-
BADGE_URL="https://img.shields.io/badge/coverage-${{ steps.coverage.outputs.percentage }}%25-${{ steps.coverage.outputs.color }}"
97+
BADGE_BRANCH="coverage-badge"
7998
80-
# Update the README.md file
81-
sed -i -E "s|(\!\[License\]\([^)]+\))|\1 \![Coverage]($BADGE_URL)|" README.md
99+
# Setup git
100+
git config --local user.email "[email protected]"
101+
git config --local user.name "Coverage Badge Action"
82102
83-
# Check if the README has been modified
84-
if git diff --exit-code README.md; then
85-
echo "No changes to README.md"
103+
# Try to fetch the badge branch, or create it if it doesn't exist
104+
if ! git fetch origin $BADGE_BRANCH; then
105+
# Create an orphan branch for the badge
106+
git checkout --orphan $BADGE_BRANCH
107+
git rm -rf .
86108
else
87-
# Create a new branch
88-
BRANCH_NAME="update-coverage-badge-$(date +%Y%m%d%H%M%S)"
89-
git config --local user.email "[email protected]"
90-
git config --local user.name "Update Coverage Badge Action"
91-
git checkout -b $BRANCH_NAME
92-
git add README.md
93-
git commit -m "docs: update test coverage badge"
94-
git push --set-upstream origin $BRANCH_NAME
95-
96-
# Create a pull request using GitHub CLI
97-
gh pr create --title "Update coverage badge" \
98-
--body "Automatically updates the test coverage badge in README.md" \
99-
--base main \
100-
--head $BRANCH_NAME
101-
fi
109+
git checkout $BADGE_BRANCH
110+
fi
111+
112+
# Copy over just the badge SVG
113+
mkdir -p badges
114+
cp ../badges/coverage.svg badges/
115+
116+
# Commit and push the badge
117+
git add badges/coverage.svg
118+
git commit -m "chore: update coverage badge [skip ci]" || echo "No changes to commit"
119+
git push origin $BADGE_BRANCH

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
1+
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE) [![Coverage](https://github.com/NVIDIA/KAI-Scheduler/raw/coverage-badge/badges/coverage.svg)](https://github.com/NVIDIA/KAI-Scheduler/blob/main/.github/workflows/update-coverage-badge.yaml)
22
# KAI Scheduler
33
KAI Scheduler is a robust, efficient, and scalable [Kubernetes scheduler](https://kubernetes.io/docs/concepts/scheduling-eviction/kube-scheduler/) that optimizes GPU resource allocation for AI and machine learning workloads.
44

@@ -73,7 +73,7 @@ To start scheduling workloads with KAI Scheduler, please continue to [Quick Star
7373
* Graceful rollout of Inference workloads (new revision update using queue temporary over-quota)
7474

7575
## Support and Getting Help
76-
Wed love to hear from you! Here's how to reach out:
76+
We'd love to hear from you! Here's how to reach out:
7777

7878
- Technical Questions, Bugs, and Feature Requests: Please open [an issue on GitHub](https://github.com/NVIDIA/KAI-scheduler/issues/new) for anything related to technical support, bug reports, or feature suggestions. This helps us track and address them efficiently.
7979
- For broader conversations, including roadmap planning, scheduling strategies, and working group coordination, join the [CNCF Slack workspace](https://communityinviter.com/apps/cloud-native/cncf) and visit the [#batch-wg](https://cloud-native.slack.com/archives/C02Q5DFF3MM) channel.

0 commit comments

Comments
 (0)