Skip to content

Commit 0851638

Browse files
authored
Add code coverage combination and reporting (#1674)
SUMMARY: Update code coverage support to include results in the job summaries, as well as combine the results from the multiple jobs in the "test-checks.yaml" workflow. Some open questions: * Should the reporting in the summary skip empty files (files with no Python code/statements)? * Current: yes * Should the reporting use different types of sorting (e.g., by coverage)? * Current: file path/name (tool default) * Should the GitHub jobs have coverage summaries for intermediate jobs or just the combined results? * Current: all (though it does seem more verbose than is useful) * Note: The coverage result artifacts will still be attached to the jobs even without summaries, they are currently required for the job that combines the results. * Should coverage be enabled by default for eithe of the workflows (here or another PR)? * Current: no (adds ~1 minute to base test run wall time and ~6-7 minutes to transformers run time) TEST PLAN: For examples, check these runs and the summary for each job in the run: * base: https://github.com/vllm-project/llm-compressor/actions/runs/16471546227 (49% combined coverage) * transformers: https://github.com/vllm-project/llm-compressor/actions/runs/16472609090 (65% coverage) Signed-off-by: Domenic Barbuzzi <[email protected]>
1 parent 0123644 commit 0851638

File tree

2 files changed

+75
-3
lines changed

2 files changed

+75
-3
lines changed

.github/workflows/test-check-transformers.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,9 @@ jobs:
122122
.coverage
123123
coverage-html
124124
coverage.json
125+
include-hidden-files: true
125126
retention-days: 5
127+
- name: "Report coverage"
128+
if: (success() || failure()) && inputs.code_coverage
129+
run: |
130+
coverage report --data-file=".coverage" --skip-empty --format="markdown" > "$GITHUB_STEP_SUMMARY"

.github/workflows/test-check.yaml

Lines changed: 70 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ jobs:
1818

1919
base-tests:
2020
runs-on: ubuntu-22.04
21+
env:
22+
COVERAGE_FILE: ".coverage.base"
2123
steps:
2224
- uses: actions/setup-python@v5
2325
with:
@@ -53,13 +55,20 @@ jobs:
5355
with:
5456
name: base-tests-coverage-results
5557
path: |
56-
.coverage
58+
.coverage*
5759
coverage-html
5860
coverage.json
61+
include-hidden-files: true
5962
retention-days: 5
63+
- name: "Report coverage"
64+
if: (success() || failure()) && inputs.code_coverage
65+
run: |
66+
coverage report --data-file="$COVERAGE_FILE" --skip-empty --format="markdown" > "$GITHUB_STEP_SUMMARY"
6067
6168
pytorch-tests:
6269
runs-on: ubuntu-22.04
70+
env:
71+
COVERAGE_FILE: ".coverage.pytorch"
6372
steps:
6473
- uses: actions/setup-python@v5
6574
with:
@@ -96,14 +105,20 @@ jobs:
96105
with:
97106
name: pytorch-tests-coverage-results
98107
path: |
99-
.coverage
108+
.coverage*
100109
coverage-html
101110
coverage.json
111+
include-hidden-files: true
102112
retention-days: 5
103-
113+
- name: "Report coverage"
114+
if: (success() || failure()) && inputs.code_coverage
115+
run: |
116+
coverage report --data-file="$COVERAGE_FILE" --skip-empty --format="markdown" > "$GITHUB_STEP_SUMMARY"
104117
105118
compat-pytorch-1_9-pytorch-tests:
106119
runs-on: ubuntu-22.04
120+
env:
121+
COVERAGE_FILE: ".coverage.compat-pytorch-1.9"
107122
steps:
108123
- uses: actions/setup-python@v5
109124
with:
@@ -139,8 +154,60 @@ jobs:
139154
uses: actions/upload-artifact@v4
140155
with:
141156
name: compat-pytorch-tests-coverage-results
157+
path: |
158+
.coverage*
159+
coverage-html
160+
coverage.json
161+
include-hidden-files: true
162+
retention-days: 5
163+
- name: "Report coverage"
164+
if: (success() || failure()) && inputs.code_coverage
165+
run: |
166+
coverage report --data-file="$COVERAGE_FILE" --skip-empty --format="markdown" > "$GITHUB_STEP_SUMMARY"
167+
168+
combine-coverage:
169+
runs-on: ubuntu-22.04
170+
needs: [base-tests, pytorch-tests, compat-pytorch-1_9-pytorch-tests]
171+
if: (success() || failure()) && inputs.code_coverage
172+
steps:
173+
- name: "Checkout llm-compressor"
174+
uses: actions/checkout@v4
175+
176+
- name: "Download coverage artifacts"
177+
uses: actions/download-artifact@v4
178+
with:
179+
merge-multiple: true
180+
181+
- uses: actions/setup-python@v5
182+
with:
183+
python-version: '3.12'
184+
185+
- name: "Install dependencies"
186+
run: |
187+
pip3 install -U pip setuptools
188+
pip3 install coverage setuptools-scm
189+
make build # need to build to generate the version.py file
190+
191+
- name: "Combine and report coverage"
192+
run: |
193+
cat << EOF > .coveragerc
194+
[paths]
195+
source =
196+
src/
197+
*/site-packages/
198+
EOF
199+
coverage combine
200+
coverage report --skip-empty --format="markdown" >> "$GITHUB_STEP_SUMMARY"
201+
coverage html --directory coverage-html
202+
coverage json -o coverage.json
203+
204+
- name: "Upload coverage report"
205+
uses: actions/upload-artifact@v4
206+
with:
207+
name: combined-coverage-results
142208
path: |
143209
.coverage
144210
coverage-html
145211
coverage.json
212+
include-hidden-files: true
146213
retention-days: 5

0 commit comments

Comments
 (0)