Skip to content

Commit bbdd770

Browse files
authored
Add opt-in code coverage to test workflows (#1633)
In order to enable the code coverage, the workflow(s) must be executed manually with the `code_coverage` input set to `true`. This will trigger two additional steps per workflow/job: 1. One step uses a new action to prepare/configure the code coverage 2. The other step uploads the code coverage results to the run as an artifact Runs with the added conditionals removed to force-enable code coverage (since you cannot manually execute a run with `workflow_dispatch` until the workflow is on the primary branch with `workflow_dispatch` defined): https://github.com/vllm-project/llm-compressor/actions/runs/16178848704 https://github.com/vllm-project/llm-compressor/actions/runs/16178848721 One of the transformers job test failures seems like it's related to the datasets changes around remote code, but the others I’m not sure about – though they shouldn’t be related to this PR. --------- Signed-off-by: Domenic Barbuzzi <dbarbuzz@redhat.com>
1 parent f28a9d5 commit bbdd770

File tree

3 files changed

+86
-2
lines changed

3 files changed

+86
-2
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: prepare code coverage
2+
description: installs code coverage dependencies and exports an updated 'PYTEST_ADDOPTS' env var
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- run: |-
8+
# install dependencies
9+
pip3 install coverage pytest-cov https://github.com/neuralmagic/pytest-nm-releng/archive/v0.4.0.tar.gz
10+
11+
# generate and source flags
12+
FLAGS_FILE="coverage_flags.sh"
13+
nmre-generate-coverage-flags --package "llmcompressor" --output-file "$FLAGS_FILE"
14+
source "$FLAGS_FILE"
15+
rm "$FLAGS_FILE"
16+
17+
# export defined/updated 'PYTEST_ADDOPTS' env var
18+
echo "PYTEST_ADDOPTS=$PYTEST_ADDOPTS" | tee -a "$GITHUB_ENV"
19+
shell: bash

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

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
name: Test Checks (Transformers)
22
on:
33
pull_request:
4-
branches: main
4+
branches: [ main ]
55
types: [ labeled, synchronize ]
66
push:
7-
branches: main
7+
branches: [ main ]
8+
workflow_dispatch:
9+
inputs:
10+
code_coverage:
11+
description: if enabled, code coverage metrics will be collected during the test run
12+
type: boolean
13+
default: false
814

915
env:
1016
CADENCE: "commit"
@@ -72,6 +78,9 @@ jobs:
7278
BUILD_TYPE=nightly pip3 install .
7379
- name: "Clean compressed-tensors directory"
7480
run: rm -r compressed-tensors/
81+
- name: "⚙️ Prepare code coverage"
82+
if: inputs.code_coverage
83+
uses: ./.github/actions/prepare-code-coverage
7584
- name: "🔬 Running transformers tests"
7685
if: (success() || failure()) && steps.install.outcome == 'success'
7786
run: |
@@ -104,3 +113,13 @@ jobs:
104113
if: (success() || failure()) && steps.install.outcome == 'success'
105114
run: |
106115
pytest -v tests/llmcompressor/transformers/kv_cache
116+
- name: "Upload coverage report"
117+
if: (success() || failure()) && inputs.code_coverage
118+
uses: actions/upload-artifact@v4
119+
with:
120+
name: transformers-tests-coverage-results
121+
path: |
122+
.coverage
123+
coverage-html
124+
coverage.json
125+
retention-days: 5

.github/workflows/test-check.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ on:
44
branches:
55
- main
66
push:
7+
workflow_dispatch:
8+
inputs:
9+
code_coverage:
10+
description: if enabled, code coverage metrics will be collected during the test run
11+
type: boolean
12+
default: false
713

814
env:
915
CADENCE: "commit"
@@ -36,8 +42,21 @@ jobs:
3642
BUILD_TYPE=nightly pip3 install .
3743
- name: "Clean compressed-tensors directory"
3844
run: rm -r compressed-tensors/
45+
- name: "⚙️ Prepare code coverage"
46+
if: inputs.code_coverage
47+
uses: ./.github/actions/prepare-code-coverage
3948
- name: "🔬 Running base tests"
4049
run: make test
50+
- name: "Upload coverage report"
51+
if: (success() || failure()) && inputs.code_coverage
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: base-tests-coverage-results
55+
path: |
56+
.coverage
57+
coverage-html
58+
coverage.json
59+
retention-days: 5
4160

4261
pytorch-tests:
4362
runs-on: ubuntu-22.04
@@ -65,9 +84,23 @@ jobs:
6584
BUILD_TYPE=nightly pip3 install .
6685
- name: "Clean compressed-tensors directory"
6786
run: rm -r compressed-tensors/
87+
- name: "⚙️ Prepare code coverage"
88+
if: inputs.code_coverage
89+
uses: ./.github/actions/prepare-code-coverage
6890
- name: "🔬 Running pytorch tests"
6991
run: |
7092
pytest -v tests/llmcompressor/pytorch
93+
- name: "Upload coverage report"
94+
if: (success() || failure()) && inputs.code_coverage
95+
uses: actions/upload-artifact@v4
96+
with:
97+
name: pytorch-tests-coverage-results
98+
path: |
99+
.coverage
100+
coverage-html
101+
coverage.json
102+
retention-days: 5
103+
71104

72105
compat-pytorch-1_9-pytorch-tests:
73106
runs-on: ubuntu-22.04
@@ -95,6 +128,19 @@ jobs:
95128
BUILD_TYPE=nightly pip3 install .
96129
- name: "Clean compressed-tensors directory"
97130
run: rm -r compressed-tensors/
131+
- name: "⚙️ Prepare code coverage"
132+
if: inputs.code_coverage
133+
uses: ./.github/actions/prepare-code-coverage
98134
- name: "🔬 Running pytorch tests"
99135
run: |
100136
pytest -v tests/llmcompressor/pytorch
137+
- name: "Upload coverage report"
138+
if: (success() || failure()) && inputs.code_coverage
139+
uses: actions/upload-artifact@v4
140+
with:
141+
name: compat-pytorch-tests-coverage-results
142+
path: |
143+
.coverage
144+
coverage-html
145+
coverage.json
146+
retention-days: 5

0 commit comments

Comments
 (0)